File tree Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 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 :
Original file line number Diff line number Diff line change 77
88from mcp_python .types import JSONRPCMessage
99
10-
1110@asynccontextmanager
1211async 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.
Original file line number Diff line number Diff line change @@ -41,23 +41,23 @@ class Meta(BaseModel):
4141 This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications.
4242 """
4343
44-
4544RequestParamsT = TypeVar ("RequestParamsT" , bound = RequestParams )
4645NotificationParamsT = TypeVar ("NotificationParamsT" , bound = NotificationParams )
46+ MethodT = TypeVar ("MethodT" , bound = str )
4747
4848
49- class Request (BaseModel , Generic [RequestParamsT ]):
49+ class Request (BaseModel , Generic [RequestParamsT , MethodT ]):
5050 """Base class for JSON-RPC requests."""
5151
52- method : str
52+ method : MethodT
5353 params : RequestParamsT
5454 model_config = ConfigDict (extra = "allow" )
5555
5656
57- class Notification (BaseModel , Generic [NotificationParamsT ]):
57+ class Notification (BaseModel , Generic [NotificationParamsT , MethodT ]):
5858 """Base class for JSON-RPC notifications."""
5959
60- method : str
60+ method : MethodT
6161 model_config = ConfigDict (extra = "allow" )
6262
6363
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ packages = ["mcp_python"]
2222
2323[tool .pyright ]
2424include = [" mcp_python" , " tests" ]
25- typeCheckingMode = " strict"
2625venvPath = " ."
2726venv = " .venv"
2827
You can’t perform that action at this time.
0 commit comments