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 20
20
CompleteRequest ,
21
21
ErrorData ,
22
22
JSONRPCMessage ,
23
+ ListPromptsRequest ,
24
+ ListPromptsResult ,
23
25
ListResourcesRequest ,
24
26
ListResourcesResult ,
25
27
LoggingLevel ,
@@ -57,8 +59,6 @@ def request_context(self) -> RequestContext:
57
59
return request_ctx .get ()
58
60
59
61
def list_prompts (self ):
60
- from mcp_python .types import ListPromptsRequest , ListPromptsResult
61
-
62
62
def decorator (func : Callable [[], Awaitable [list [Prompt ]]]):
63
63
logger .debug (f"Registering handler for PromptListRequest" )
64
64
@@ -90,7 +90,7 @@ def decorator(
90
90
91
91
async def handler (req : GetPromptRequest ):
92
92
prompt_get = await func (req .params .name , req .params .arguments )
93
- messages = []
93
+ messages : list [ SamplingMessage ] = []
94
94
for message in prompt_get .messages :
95
95
match message .content :
96
96
case str () as text_content :
Original file line number Diff line number Diff line change 7
7
8
8
from mcp_python .types import JSONRPCMessage
9
9
10
-
11
10
@asynccontextmanager
12
11
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
14
13
):
15
14
"""
16
15
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):
41
41
This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications.
42
42
"""
43
43
44
-
45
44
RequestParamsT = TypeVar ("RequestParamsT" , bound = RequestParams )
46
45
NotificationParamsT = TypeVar ("NotificationParamsT" , bound = NotificationParams )
46
+ MethodT = TypeVar ("MethodT" , bound = str )
47
47
48
48
49
- class Request (BaseModel , Generic [RequestParamsT ]):
49
+ class Request (BaseModel , Generic [RequestParamsT , MethodT ]):
50
50
"""Base class for JSON-RPC requests."""
51
51
52
- method : str
52
+ method : MethodT
53
53
params : RequestParamsT
54
54
model_config = ConfigDict (extra = "allow" )
55
55
56
56
57
- class Notification (BaseModel , Generic [NotificationParamsT ]):
57
+ class Notification (BaseModel , Generic [NotificationParamsT , MethodT ]):
58
58
"""Base class for JSON-RPC notifications."""
59
59
60
- method : str
60
+ method : MethodT
61
61
model_config = ConfigDict (extra = "allow" )
62
62
63
63
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ packages = ["mcp_python"]
22
22
23
23
[tool .pyright ]
24
24
include = [" mcp_python" , " tests" ]
25
- typeCheckingMode = " strict"
26
25
venvPath = " ."
27
26
venv = " .venv"
28
27
You can’t perform that action at this time.
0 commit comments