Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mcp_python/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
CompleteRequest,
ErrorData,
JSONRPCMessage,
ListPromptsRequest,
ListPromptsResult,
ListResourcesRequest,
ListResourcesResult,
LoggingLevel,
Expand Down Expand Up @@ -57,8 +59,6 @@ def request_context(self) -> RequestContext:
return request_ctx.get()

def list_prompts(self):
from mcp_python.types import ListPromptsRequest, ListPromptsResult

def decorator(func: Callable[[], Awaitable[list[Prompt]]]):
logger.debug(f"Registering handler for PromptListRequest")

Expand Down Expand Up @@ -90,7 +90,7 @@ def decorator(

async def handler(req: GetPromptRequest):
prompt_get = await func(req.params.name, req.params.arguments)
messages = []
messages: list[SamplingMessage] = []
for message in prompt_get.messages:
match message.content:
case str() as text_content:
Expand Down
3 changes: 1 addition & 2 deletions mcp_python/server/stdio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

from mcp_python.types import JSONRPCMessage


@asynccontextmanager
async def stdio_server(
stdin: anyio.AsyncFile | None = None, stdout: anyio.AsyncFile | None = None
stdin: anyio.AsyncFile[str] | None = None, stdout: anyio.AsyncFile[str] | None = None
):
"""
Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.
Expand Down
10 changes: 5 additions & 5 deletions mcp_python/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ class Meta(BaseModel):
This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications.
"""


RequestParamsT = TypeVar("RequestParamsT", bound=RequestParams)
NotificationParamsT = TypeVar("NotificationParamsT", bound=NotificationParams)
MethodT = TypeVar("MethodT", bound=str)


class Request(BaseModel, Generic[RequestParamsT]):
class Request(BaseModel, Generic[RequestParamsT, MethodT]):
"""Base class for JSON-RPC requests."""

method: str
method: MethodT
params: RequestParamsT
model_config = ConfigDict(extra="allow")


class Notification(BaseModel, Generic[NotificationParamsT]):
class Notification(BaseModel, Generic[NotificationParamsT, MethodT]):
"""Base class for JSON-RPC notifications."""

method: str
method: MethodT
model_config = ConfigDict(extra="allow")


Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ packages = ["mcp_python"]

[tool.pyright]
include = ["mcp_python", "tests"]
typeCheckingMode = "strict"
venvPath = "."
venv = ".venv"

Expand Down