Skip to content

Commit 04ad96e

Browse files
committed
Typing fixes
Strict pyright mode results in a lot of issues regarding non fully determined types, due to Generics. These are some issues I came across today. We are still far from being clean on pyright.
1 parent 34937b7 commit 04ad96e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

mcp_python/server/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
CompleteRequest,
2121
ErrorData,
2222
JSONRPCMessage,
23+
ListPromptsRequest,
24+
ListPromptsResult,
2325
ListResourcesRequest,
2426
ListResourcesResult,
2527
LoggingLevel,
@@ -57,8 +59,6 @@ def request_context(self) -> RequestContext:
5759
return request_ctx.get()
5860

5961
def list_prompts(self):
60-
from mcp_python.types import ListPromptsRequest, ListPromptsResult
61-
6262
def decorator(func: Callable[[], Awaitable[list[Prompt]]]):
6363
logger.debug(f"Registering handler for PromptListRequest")
6464

@@ -90,7 +90,7 @@ def decorator(
9090

9191
async def handler(req: GetPromptRequest):
9292
prompt_get = await func(req.params.name, req.params.arguments)
93-
messages = []
93+
messages: list[SamplingMessage] = []
9494
for message in prompt_get.messages:
9595
match message.content:
9696
case str() as text_content:

mcp_python/server/stdio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
from mcp_python.types import JSONRPCMessage
99

10-
1110
@asynccontextmanager
1211
async def stdio_server(
13-
stdin: anyio.AsyncFile | None = None, stdout: anyio.AsyncFile | None = None
12+
stdin: anyio.AsyncFile[str] | None = None, stdout: anyio.AsyncFile[str] | None = None
1413
):
1514
"""
1615
Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.

0 commit comments

Comments
 (0)