|
16 | 16 | from mcp.client.streamable_http import GetSessionIdCallback, streamablehttp_client |
17 | 17 | from mcp.shared.message import SessionMessage |
18 | 18 | from mcp.types import ( |
| 19 | + AnyUrl, |
19 | 20 | CallToolResult, |
20 | 21 | GetPromptResult, |
21 | 22 | InitializeResult, |
@@ -91,12 +92,12 @@ async def list_resources(self) -> ListResourcesResult: |
91 | 92 | pass |
92 | 93 |
|
93 | 94 | @abc.abstractmethod |
94 | | - async def read_resource(self, uri: str) -> ReadResourceResult: |
| 95 | + async def read_resource(self, uri:AnyUrl) -> ReadResourceResult: |
95 | 96 | """Read the content of a resource by URI.""" |
96 | 97 | pass |
97 | 98 |
|
98 | 99 | @abc.abstractmethod |
99 | | - async def subscribe_resource(self, uri: str, **kwargs) -> AsyncIterator[SessionMessage]: |
| 100 | + async def subscribe_resource(self, uri:AnyUrl, **kwargs) -> AsyncIterator[SessionMessage]: |
100 | 101 | """Subscribe to resource updates.""" |
101 | 102 | pass |
102 | 103 |
|
@@ -354,19 +355,19 @@ async def list_resources(self) -> ListResourcesResult: |
354 | 355 | assert session is not None |
355 | 356 | return await session.list_resources() |
356 | 357 |
|
357 | | - async def read_resource(self, uri: str) -> ReadResourceResult: |
| 358 | + async def read_resource(self, uri: AnyUrl) -> ReadResourceResult: |
358 | 359 | if not self.session: |
359 | 360 | raise UserError("Server not initialized. Make sure you call `connect()` first.") |
360 | 361 | session = self.session |
361 | 362 | assert session is not None |
362 | 363 | return await session.read_resource(uri) |
363 | 364 |
|
364 | | - async def subscribe_resource(self, uri: str, **kwargs) -> AsyncIterator[SessionMessage]: |
| 365 | + async def subscribe_resource(self, uri: AnyUrl, **kwargs) -> AsyncIterator[SessionMessage]: |
365 | 366 | if not self.session: |
366 | 367 | raise UserError("Server not initialized. Make sure you call `connect()` first.") |
367 | 368 | session = self.session |
368 | 369 | assert session is not None |
369 | | - async for msg in session.subscribe_resource(uri, **kwargs): |
| 370 | + async for msg in session.subscribe_resource(uri): |
370 | 371 | yield msg |
371 | 372 |
|
372 | 373 | async def list_prompts( |
|
0 commit comments