From cae5231b6fc5b8a0d7a283dc4067bcc1520c4c1d Mon Sep 17 00:00:00 2001 From: Benjamin Fineran Date: Fri, 11 Jul 2025 18:42:09 +0000 Subject: [PATCH] add type field to client session config BaseModels formatting --- src/mcp/client/session_group.py | 8 +++++++- src/mcp/client/stdio/__init__.py | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mcp/client/session_group.py b/src/mcp/client/session_group.py index 700b5417f..d402ee082 100644 --- a/src/mcp/client/session_group.py +++ b/src/mcp/client/session_group.py @@ -13,7 +13,7 @@ from collections.abc import Callable from datetime import timedelta from types import TracebackType -from typing import Any, TypeAlias +from typing import Any, Literal, TypeAlias import anyio from pydantic import BaseModel @@ -30,6 +30,9 @@ class SseServerParameters(BaseModel): """Parameters for intializing a sse_client.""" + # The type of server connection. + type: Literal["sse"] = "sse" + # The endpoint URL. url: str @@ -46,6 +49,9 @@ class SseServerParameters(BaseModel): class StreamableHttpParameters(BaseModel): """Parameters for intializing a streamablehttp_client.""" + # The type of server connection. + type: Literal["streamable_http"] = "streamable_http" + # The endpoint URL. url: str diff --git a/src/mcp/client/stdio/__init__.py b/src/mcp/client/stdio/__init__.py index 50bceddec..804c2ec2f 100644 --- a/src/mcp/client/stdio/__init__.py +++ b/src/mcp/client/stdio/__init__.py @@ -69,6 +69,9 @@ def get_default_environment() -> dict[str, str]: class StdioServerParameters(BaseModel): + type: Literal["stdio"] = "stdio" + """The type of server connection.""" + command: str """The executable to run to start the server."""