From ed87ae9f06e0bed6eb65d4de5917b42fd754fe50 Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Mon, 11 Nov 2024 12:31:36 +0000 Subject: [PATCH] rename mcp_python to mcp --- pyproject.toml | 10 +-- {mcp_python => src/mcp}/__init__.py | 0 {mcp_python => src/mcp}/client/__init__.py | 0 {mcp_python => src/mcp}/client/__main__.py | 6 +- {mcp_python => src/mcp}/client/session.py | 36 +++++------ {mcp_python => src/mcp}/client/sse.py | 2 +- {mcp_python => src/mcp}/client/stdio.py | 2 +- {mcp_python => src/mcp}/py.typed | 0 {mcp_python => src/mcp}/server/__init__.py | 33 +++++----- {mcp_python => src/mcp}/server/__main__.py | 12 ++-- {mcp_python => src/mcp}/server/session.py | 18 +++--- {mcp_python => src/mcp}/server/sse.py | 2 +- {mcp_python => src/mcp}/server/stdio.py | 2 +- {mcp_python => src/mcp}/server/types.py | 2 +- {mcp_python => src/mcp}/server/websocket.py | 2 +- {mcp_python => src/mcp}/shared/__init__.py | 0 {mcp_python => src/mcp}/shared/context.py | 4 +- {mcp_python => src/mcp}/shared/exceptions.py | 2 +- {mcp_python => src/mcp}/shared/memory.py | 6 +- {mcp_python => src/mcp}/shared/progress.py | 6 +- {mcp_python => src/mcp}/shared/session.py | 4 +- {mcp_python => src/mcp}/shared/version.py | 2 +- {mcp_python => src/mcp}/types.py | 0 tests/client/test_session.py | 4 +- tests/client/test_stdio.py | 4 +- tests/conftest.py | 6 +- tests/server/test_session.py | 12 ++-- tests/server/test_stdio.py | 4 +- tests/shared/test_memory.py | 8 +-- tests/test_types.py | 4 +- uv.lock | 66 ++++++++++---------- 31 files changed, 130 insertions(+), 129 deletions(-) rename {mcp_python => src/mcp}/__init__.py (100%) rename {mcp_python => src/mcp}/client/__init__.py (100%) rename {mcp_python => src/mcp}/client/__main__.py (91%) rename {mcp_python => src/mcp}/client/session.py (90%) rename {mcp_python => src/mcp}/client/sse.py (99%) rename {mcp_python => src/mcp}/client/stdio.py (98%) rename {mcp_python => src/mcp}/py.typed (100%) rename {mcp_python => src/mcp}/server/__init__.py (95%) rename {mcp_python => src/mcp}/server/__main__.py (77%) rename {mcp_python => src/mcp}/server/session.py (94%) rename {mcp_python => src/mcp}/server/sse.py (99%) rename {mcp_python => src/mcp}/server/stdio.py (98%) rename {mcp_python => src/mcp}/server/types.py (96%) rename {mcp_python => src/mcp}/server/websocket.py (98%) rename {mcp_python => src/mcp}/shared/__init__.py (100%) rename {mcp_python => src/mcp}/shared/context.py (71%) rename {mcp_python => src/mcp}/shared/exceptions.py (78%) rename {mcp_python => src/mcp}/shared/memory.py (95%) rename {mcp_python => src/mcp}/shared/progress.py (86%) rename {mcp_python => src/mcp}/shared/session.py (99%) rename {mcp_python => src/mcp}/shared/version.py (53%) rename {mcp_python => src/mcp}/types.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 44f35f080..0b7f059bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling"] build-backend = "hatchling.build" [project] -name = "mcp-python" +name = "mcp" version = "0.7.0.dev" description = "Model Context Protocol implementation for Python" readme = "README.md" @@ -18,10 +18,10 @@ dependencies = [ ] [tool.hatch.build.targets.wheel] -packages = ["mcp_python"] +packages = ["src/mcp"] [tool.pyright] -include = ["mcp_python", "tests"] +include = ["src/mcp", "tests"] venvPath = "." venv = ".venv" @@ -31,14 +31,14 @@ ignore = [] [tool.ruff] line-length = 88 -target-version = "py38" +target-version = "py310" [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] [tool.uv] dev-dependencies = [ - "pyright>=1.1.384", + "pyright>=1.1.378", "pytest>=8.3.3", "ruff>=0.6.9", "trio>=0.26.2", diff --git a/mcp_python/__init__.py b/src/mcp/__init__.py similarity index 100% rename from mcp_python/__init__.py rename to src/mcp/__init__.py diff --git a/mcp_python/client/__init__.py b/src/mcp/client/__init__.py similarity index 100% rename from mcp_python/client/__init__.py rename to src/mcp/client/__init__.py diff --git a/mcp_python/client/__main__.py b/src/mcp/client/__main__.py similarity index 91% rename from mcp_python/client/__main__.py rename to src/mcp/client/__main__.py index e89f5fe15..121e3ff45 100644 --- a/mcp_python/client/__main__.py +++ b/src/mcp/client/__main__.py @@ -6,9 +6,9 @@ import anyio import click -from mcp_python.client.session import ClientSession -from mcp_python.client.sse import sse_client -from mcp_python.client.stdio import StdioServerParameters, stdio_client +from mcp.client.session import ClientSession +from mcp.client.sse import sse_client +from mcp.client.stdio import StdioServerParameters, stdio_client if not sys.warnoptions: import warnings diff --git a/mcp_python/client/session.py b/src/mcp/client/session.py similarity index 90% rename from mcp_python/client/session.py rename to src/mcp/client/session.py index 3f50503e9..a9b8d547a 100644 --- a/mcp_python/client/session.py +++ b/src/mcp/client/session.py @@ -3,9 +3,9 @@ from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream from pydantic import AnyUrl -from mcp_python.shared.session import BaseSession -from mcp_python.shared.version import SUPPORTED_PROTOCOL_VERSIONS -from mcp_python.types import ( +from mcp.shared.session import BaseSession +from mcp.shared.version import SUPPORTED_PROTOCOL_VERSIONS +from mcp.types import ( LATEST_PROTOCOL_VERSION, CallToolResult, ClientCapabilities, @@ -56,7 +56,7 @@ def __init__( ) async def initialize(self) -> InitializeResult: - from mcp_python.types import ( + from mcp.types import ( InitializeRequest, InitializeRequestParams, ) @@ -77,7 +77,7 @@ async def initialize(self) -> InitializeResult: listChanged=True ), ), - clientInfo=Implementation(name="mcp_python", version="0.1.0"), + clientInfo=Implementation(name="mcp", version="0.1.0"), ), ) ), @@ -100,7 +100,7 @@ async def initialize(self) -> InitializeResult: async def send_ping(self) -> EmptyResult: """Send a ping request.""" - from mcp_python.types import PingRequest + from mcp.types import PingRequest return await self.send_request( ClientRequest( @@ -115,7 +115,7 @@ async def send_progress_notification( self, progress_token: str | int, progress: float, total: float | None = None ) -> None: """Send a progress notification.""" - from mcp_python.types import ( + from mcp.types import ( ProgressNotification, ProgressNotificationParams, ) @@ -135,7 +135,7 @@ async def send_progress_notification( async def set_logging_level(self, level: LoggingLevel) -> EmptyResult: """Send a logging/setLevel request.""" - from mcp_python.types import ( + from mcp.types import ( SetLevelRequest, SetLevelRequestParams, ) @@ -152,7 +152,7 @@ async def set_logging_level(self, level: LoggingLevel) -> EmptyResult: async def list_resources(self) -> ListResourcesResult: """Send a resources/list request.""" - from mcp_python.types import ( + from mcp.types import ( ListResourcesRequest, ) @@ -167,7 +167,7 @@ async def list_resources(self) -> ListResourcesResult: async def read_resource(self, uri: AnyUrl) -> ReadResourceResult: """Send a resources/read request.""" - from mcp_python.types import ( + from mcp.types import ( ReadResourceRequest, ReadResourceRequestParams, ) @@ -184,7 +184,7 @@ async def read_resource(self, uri: AnyUrl) -> ReadResourceResult: async def subscribe_resource(self, uri: AnyUrl) -> EmptyResult: """Send a resources/subscribe request.""" - from mcp_python.types import ( + from mcp.types import ( SubscribeRequest, SubscribeRequestParams, ) @@ -201,7 +201,7 @@ async def subscribe_resource(self, uri: AnyUrl) -> EmptyResult: async def unsubscribe_resource(self, uri: AnyUrl) -> EmptyResult: """Send a resources/unsubscribe request.""" - from mcp_python.types import ( + from mcp.types import ( UnsubscribeRequest, UnsubscribeRequestParams, ) @@ -220,7 +220,7 @@ async def call_tool( self, name: str, arguments: dict | None = None ) -> CallToolResult: """Send a tools/call request.""" - from mcp_python.types import ( + from mcp.types import ( CallToolRequest, CallToolRequestParams, ) @@ -237,7 +237,7 @@ async def call_tool( async def list_prompts(self) -> ListPromptsResult: """Send a prompts/list request.""" - from mcp_python.types import ListPromptsRequest + from mcp.types import ListPromptsRequest return await self.send_request( ClientRequest( @@ -252,7 +252,7 @@ async def get_prompt( self, name: str, arguments: dict[str, str] | None = None ) -> GetPromptResult: """Send a prompts/get request.""" - from mcp_python.types import GetPromptRequest, GetPromptRequestParams + from mcp.types import GetPromptRequest, GetPromptRequestParams return await self.send_request( ClientRequest( @@ -268,7 +268,7 @@ async def complete( self, ref: ResourceReference | PromptReference, argument: dict ) -> CompleteResult: """Send a completion/complete request.""" - from mcp_python.types import ( + from mcp.types import ( CompleteRequest, CompleteRequestParams, CompletionArgument, @@ -289,7 +289,7 @@ async def complete( async def list_tools(self) -> ListToolsResult: """Send a tools/list request.""" - from mcp_python.types import ListToolsRequest + from mcp.types import ListToolsRequest return await self.send_request( ClientRequest( @@ -302,7 +302,7 @@ async def list_tools(self) -> ListToolsResult: async def send_roots_list_changed(self) -> None: """Send a roots/list_changed notification.""" - from mcp_python.types import RootsListChangedNotification + from mcp.types import RootsListChangedNotification await self.send_notification( ClientNotification( diff --git a/mcp_python/client/sse.py b/src/mcp/client/sse.py similarity index 99% rename from mcp_python/client/sse.py rename to src/mcp/client/sse.py index 09826a6bd..b5c36db0e 100644 --- a/mcp_python/client/sse.py +++ b/src/mcp/client/sse.py @@ -9,7 +9,7 @@ from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream from httpx_sse import aconnect_sse -from mcp_python.types import JSONRPCMessage +from mcp.types import JSONRPCMessage logger = logging.getLogger(__name__) diff --git a/mcp_python/client/stdio.py b/src/mcp/client/stdio.py similarity index 98% rename from mcp_python/client/stdio.py rename to src/mcp/client/stdio.py index 6fc728f7a..6a29138b3 100644 --- a/mcp_python/client/stdio.py +++ b/src/mcp/client/stdio.py @@ -8,7 +8,7 @@ from anyio.streams.text import TextReceiveStream from pydantic import BaseModel, Field -from mcp_python.types import JSONRPCMessage +from mcp.types import JSONRPCMessage # Environment variables to inherit by default DEFAULT_INHERITED_ENV_VARS = ( diff --git a/mcp_python/py.typed b/src/mcp/py.typed similarity index 100% rename from mcp_python/py.typed rename to src/mcp/py.typed diff --git a/mcp_python/server/__init__.py b/src/mcp/server/__init__.py similarity index 95% rename from mcp_python/server/__init__.py rename to src/mcp/server/__init__.py index a9c1744f3..f7e66a3f0 100644 --- a/mcp_python/server/__init__.py +++ b/src/mcp/server/__init__.py @@ -7,12 +7,12 @@ from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream from pydantic import AnyUrl -from mcp_python.server import types -from mcp_python.server.session import ServerSession -from mcp_python.server.stdio import stdio_server as stdio_server -from mcp_python.shared.context import RequestContext -from mcp_python.shared.session import RequestResponder -from mcp_python.types import ( +from mcp.server import types +from mcp.server.session import ServerSession +from mcp.server.stdio import stdio_server as stdio_server +from mcp.shared.context import RequestContext +from mcp.shared.session import RequestResponder +from mcp.types import ( METHOD_NOT_FOUND, CallToolRequest, ClientNotification, @@ -101,7 +101,7 @@ def pkg_version(package: str) -> str: return types.InitializationOptions( server_name=self.name, - server_version=pkg_version("mcp_python"), + server_version=pkg_version("mcp"), capabilities=self.get_capabilities( notification_options or NotificationOptions(), experimental_capabilities or {}, @@ -168,12 +168,12 @@ async def handler(_: Any): return decorator def get_prompt(self): - from mcp_python.types import ( + from mcp.types import ( GetPromptRequest, GetPromptResult, ImageContent, ) - from mcp_python.types import ( + from mcp.types import ( Role as Role, ) @@ -232,7 +232,7 @@ async def handler(_: Any): return decorator def read_resource(self): - from mcp_python.types import ( + from mcp.types import ( BlobResourceContents, TextResourceContents, ) @@ -270,7 +270,7 @@ async def handler(req: ReadResourceRequest): return decorator def set_logging_level(self): - from mcp_python.types import EmptyResult + from mcp.types import EmptyResult def decorator(func: Callable[[LoggingLevel], Awaitable[None]]): logger.debug("Registering handler for SetLevelRequest") @@ -285,7 +285,7 @@ async def handler(req: SetLevelRequest): return decorator def subscribe_resource(self): - from mcp_python.types import EmptyResult + from mcp.types import EmptyResult def decorator(func: Callable[[AnyUrl], Awaitable[None]]): logger.debug("Registering handler for SubscribeRequest") @@ -300,7 +300,7 @@ async def handler(req: SubscribeRequest): return decorator def unsubscribe_resource(self): - from mcp_python.types import EmptyResult + from mcp.types import EmptyResult def decorator(func: Callable[[AnyUrl], Awaitable[None]]): logger.debug("Registering handler for UnsubscribeRequest") @@ -328,7 +328,7 @@ async def handler(_: Any): return decorator def call_tool(self): - from mcp_python.types import ( + from mcp.types import ( CallToolResult, EmbeddedResource, ImageContent, @@ -337,7 +337,8 @@ def call_tool(self): def decorator( func: Callable[ - ..., Awaitable[Sequence[str | types.ImageContent | types.EmbeddedResource]] + ..., + Awaitable[Sequence[str | types.ImageContent | types.EmbeddedResource]], ], ): logger.debug("Registering handler for CallToolRequest") @@ -397,7 +398,7 @@ async def handler(req: ProgressNotification): def completion(self): """Provides completions for prompts and resource templates""" - from mcp_python.types import CompleteResult, Completion, CompletionArgument + from mcp.types import CompleteResult, Completion, CompletionArgument def decorator( func: Callable[ diff --git a/mcp_python/server/__main__.py b/src/mcp/server/__main__.py similarity index 77% rename from mcp_python/server/__main__.py rename to src/mcp/server/__main__.py index 6cb882258..2313f4651 100644 --- a/mcp_python/server/__main__.py +++ b/src/mcp/server/__main__.py @@ -4,10 +4,10 @@ import anyio -from mcp_python.server.session import ServerSession -from mcp_python.server.stdio import stdio_server -from mcp_python.server.types import InitializationOptions -from mcp_python.types import ServerCapabilities +from mcp.server.session import ServerSession +from mcp.server.stdio import stdio_server +from mcp.server.types import InitializationOptions +from mcp.types import ServerCapabilities if not sys.warnoptions: import warnings @@ -29,14 +29,14 @@ async def receive_loop(session: ServerSession): async def main(): - version = importlib.metadata.version("mcp_python") + version = importlib.metadata.version("mcp") async with stdio_server() as (read_stream, write_stream): async with ( ServerSession( read_stream, write_stream, InitializationOptions( - server_name="mcp_python", + server_name="mcp", server_version=version, capabilities=ServerCapabilities(), ), diff --git a/mcp_python/server/session.py b/src/mcp/server/session.py similarity index 94% rename from mcp_python/server/session.py rename to src/mcp/server/session.py index db7ebc2c2..f6ed1b3c6 100644 --- a/mcp_python/server/session.py +++ b/src/mcp/server/session.py @@ -6,12 +6,12 @@ from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream from pydantic import AnyUrl -from mcp_python.server.types import InitializationOptions -from mcp_python.shared.session import ( +from mcp.server.types import InitializationOptions +from mcp.shared.session import ( BaseSession, RequestResponder, ) -from mcp_python.types import ( +from mcp.types import ( LATEST_PROTOCOL_VERSION, ClientNotification, ClientRequest, @@ -103,7 +103,7 @@ async def send_log_message( self, level: LoggingLevel, data: Any, logger: str | None = None ) -> None: """Send a log message notification.""" - from mcp_python.types import ( + from mcp.types import ( LoggingMessageNotification, LoggingMessageNotificationParams, ) @@ -123,7 +123,7 @@ async def send_log_message( async def send_resource_updated(self, uri: AnyUrl) -> None: """Send a resource updated notification.""" - from mcp_python.types import ( + from mcp.types import ( ResourceUpdatedNotification, ResourceUpdatedNotificationParams, ) @@ -150,7 +150,7 @@ async def create_message( model_preferences: ModelPreferences | None = None, ) -> CreateMessageResult: """Send a sampling/create_message request.""" - from mcp_python.types import ( + from mcp.types import ( CreateMessageRequest, CreateMessageRequestParams, ) @@ -176,7 +176,7 @@ async def create_message( async def list_roots(self) -> ListRootsResult: """Send a roots/list request.""" - from mcp_python.types import ListRootsRequest + from mcp.types import ListRootsRequest return await self.send_request( ServerRequest( @@ -189,7 +189,7 @@ async def list_roots(self) -> ListRootsResult: async def send_ping(self) -> EmptyResult: """Send a ping request.""" - from mcp_python.types import PingRequest + from mcp.types import PingRequest return await self.send_request( ServerRequest( @@ -204,7 +204,7 @@ async def send_progress_notification( self, progress_token: str | int, progress: float, total: float | None = None ) -> None: """Send a progress notification.""" - from mcp_python.types import ProgressNotification, ProgressNotificationParams + from mcp.types import ProgressNotification, ProgressNotificationParams await self.send_notification( ServerNotification( diff --git a/mcp_python/server/sse.py b/src/mcp/server/sse.py similarity index 99% rename from mcp_python/server/sse.py rename to src/mcp/server/sse.py index d261c7141..92ebb7a9a 100644 --- a/mcp_python/server/sse.py +++ b/src/mcp/server/sse.py @@ -12,7 +12,7 @@ from starlette.responses import Response from starlette.types import Receive, Scope, Send -from mcp_python.types import JSONRPCMessage +from mcp.types import JSONRPCMessage logger = logging.getLogger(__name__) diff --git a/mcp_python/server/stdio.py b/src/mcp/server/stdio.py similarity index 98% rename from mcp_python/server/stdio.py rename to src/mcp/server/stdio.py index 31ae41565..29f6bb6a1 100644 --- a/mcp_python/server/stdio.py +++ b/src/mcp/server/stdio.py @@ -5,7 +5,7 @@ import anyio.lowlevel from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream -from mcp_python.types import JSONRPCMessage +from mcp.types import JSONRPCMessage @asynccontextmanager diff --git a/mcp_python/server/types.py b/src/mcp/server/types.py similarity index 96% rename from mcp_python/server/types.py rename to src/mcp/server/types.py index acc5c1ea3..7946a4b30 100644 --- a/mcp_python/server/types.py +++ b/src/mcp/server/types.py @@ -8,7 +8,7 @@ from pydantic import BaseModel -from mcp_python.types import ( +from mcp.types import ( BlobResourceContents, Role, ServerCapabilities, diff --git a/mcp_python/server/websocket.py b/src/mcp/server/websocket.py similarity index 98% rename from mcp_python/server/websocket.py rename to src/mcp/server/websocket.py index 5ba309b5e..2a6d81276 100644 --- a/mcp_python/server/websocket.py +++ b/src/mcp/server/websocket.py @@ -6,7 +6,7 @@ from starlette.types import Receive, Scope, Send from starlette.websockets import WebSocket -from mcp_python.types import JSONRPCMessage +from mcp.types import JSONRPCMessage logger = logging.getLogger(__name__) diff --git a/mcp_python/shared/__init__.py b/src/mcp/shared/__init__.py similarity index 100% rename from mcp_python/shared/__init__.py rename to src/mcp/shared/__init__.py diff --git a/mcp_python/shared/context.py b/src/mcp/shared/context.py similarity index 71% rename from mcp_python/shared/context.py rename to src/mcp/shared/context.py index 20481d653..760d55877 100644 --- a/mcp_python/shared/context.py +++ b/src/mcp/shared/context.py @@ -1,8 +1,8 @@ from dataclasses import dataclass from typing import Generic, TypeVar -from mcp_python.shared.session import BaseSession -from mcp_python.types import RequestId, RequestParams +from mcp.shared.session import BaseSession +from mcp.types import RequestId, RequestParams SessionT = TypeVar("SessionT", bound=BaseSession) diff --git a/mcp_python/shared/exceptions.py b/src/mcp/shared/exceptions.py similarity index 78% rename from mcp_python/shared/exceptions.py rename to src/mcp/shared/exceptions.py index cf98cdff4..d8855b8dc 100644 --- a/mcp_python/shared/exceptions.py +++ b/src/mcp/shared/exceptions.py @@ -1,4 +1,4 @@ -from mcp_python.types import ErrorData +from mcp.types import ErrorData class McpError(Exception): diff --git a/mcp_python/shared/memory.py b/src/mcp/shared/memory.py similarity index 95% rename from mcp_python/shared/memory.py rename to src/mcp/shared/memory.py index 6ebfe9f3b..72549925b 100644 --- a/mcp_python/shared/memory.py +++ b/src/mcp/shared/memory.py @@ -9,9 +9,9 @@ import anyio from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream -from mcp_python.client.session import ClientSession -from mcp_python.server import Server -from mcp_python.types import JSONRPCMessage +from mcp.client.session import ClientSession +from mcp.server import Server +from mcp.types import JSONRPCMessage MessageStream = tuple[ MemoryObjectReceiveStream[JSONRPCMessage | Exception], diff --git a/mcp_python/shared/progress.py b/src/mcp/shared/progress.py similarity index 86% rename from mcp_python/shared/progress.py rename to src/mcp/shared/progress.py index d94740dc0..19ea5ede2 100644 --- a/mcp_python/shared/progress.py +++ b/src/mcp/shared/progress.py @@ -3,9 +3,9 @@ from pydantic import BaseModel -from mcp_python.shared.context import RequestContext -from mcp_python.shared.session import BaseSession -from mcp_python.types import ProgressToken +from mcp.shared.context import RequestContext +from mcp.shared.session import BaseSession +from mcp.types import ProgressToken class Progress(BaseModel): diff --git a/mcp_python/shared/session.py b/src/mcp/shared/session.py similarity index 99% rename from mcp_python/shared/session.py rename to src/mcp/shared/session.py index 95e354b39..0d0905ee3 100644 --- a/mcp_python/shared/session.py +++ b/src/mcp/shared/session.py @@ -8,8 +8,8 @@ from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream from pydantic import BaseModel -from mcp_python.shared.exceptions import McpError -from mcp_python.types import ( +from mcp.shared.exceptions import McpError +from mcp.types import ( ClientNotification, ClientRequest, ClientResult, diff --git a/mcp_python/shared/version.py b/src/mcp/shared/version.py similarity index 53% rename from mcp_python/shared/version.py rename to src/mcp/shared/version.py index 61d1fbeda..51bf3521d 100644 --- a/mcp_python/shared/version.py +++ b/src/mcp/shared/version.py @@ -1,3 +1,3 @@ -from mcp_python.types import LATEST_PROTOCOL_VERSION +from mcp.types import LATEST_PROTOCOL_VERSION SUPPORTED_PROTOCOL_VERSIONS = [1, LATEST_PROTOCOL_VERSION] diff --git a/mcp_python/types.py b/src/mcp/types.py similarity index 100% rename from mcp_python/types.py rename to src/mcp/types.py diff --git a/tests/client/test_session.py b/tests/client/test_session.py index f71a4cbab..d15d16f24 100644 --- a/tests/client/test_session.py +++ b/tests/client/test_session.py @@ -1,8 +1,8 @@ import anyio import pytest -from mcp_python.client.session import ClientSession -from mcp_python.types import ( +from mcp.client.session import ClientSession +from mcp.types import ( LATEST_PROTOCOL_VERSION, ClientNotification, ClientRequest, diff --git a/tests/client/test_stdio.py b/tests/client/test_stdio.py index b5e168bfa..0bdec72d0 100644 --- a/tests/client/test_stdio.py +++ b/tests/client/test_stdio.py @@ -1,7 +1,7 @@ import pytest -from mcp_python.client.stdio import StdioServerParameters, stdio_client -from mcp_python.types import JSONRPCMessage, JSONRPCRequest, JSONRPCResponse +from mcp.client.stdio import StdioServerParameters, stdio_client +from mcp.types import JSONRPCMessage, JSONRPCRequest, JSONRPCResponse @pytest.mark.anyio diff --git a/tests/conftest.py b/tests/conftest.py index 28690b249..10f3ed62a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,9 @@ import pytest from pydantic import AnyUrl -from mcp_python.server import Server -from mcp_python.server.types import InitializationOptions -from mcp_python.types import Resource, ServerCapabilities +from mcp.server import Server +from mcp.server.types import InitializationOptions +from mcp.types import Resource, ServerCapabilities TEST_INITIALIZATION_OPTIONS = InitializationOptions( server_name="my_mcp_server", diff --git a/tests/server/test_session.py b/tests/server/test_session.py index 4813fbdaf..66ac58da3 100644 --- a/tests/server/test_session.py +++ b/tests/server/test_session.py @@ -1,11 +1,11 @@ import anyio import pytest -from mcp_python.client.session import ClientSession -from mcp_python.server import NotificationOptions, Server -from mcp_python.server.session import ServerSession -from mcp_python.server.types import InitializationOptions -from mcp_python.types import ( +from mcp.client.session import ClientSession +from mcp.server import NotificationOptions, Server +from mcp.server.session import ServerSession +from mcp.server.types import InitializationOptions +from mcp.types import ( ClientNotification, InitializedNotification, JSONRPCMessage, @@ -38,7 +38,7 @@ async def run_server(): client_to_server_receive, server_to_client_send, InitializationOptions( - server_name="mcp_python", + server_name="mcp", server_version="0.1.0", capabilities=ServerCapabilities(), ), diff --git a/tests/server/test_stdio.py b/tests/server/test_stdio.py index c07b9b35f..85c5bf219 100644 --- a/tests/server/test_stdio.py +++ b/tests/server/test_stdio.py @@ -3,8 +3,8 @@ import anyio import pytest -from mcp_python.server.stdio import stdio_server -from mcp_python.types import JSONRPCMessage, JSONRPCRequest, JSONRPCResponse +from mcp.server.stdio import stdio_server +from mcp.types import JSONRPCMessage, JSONRPCRequest, JSONRPCResponse @pytest.mark.anyio diff --git a/tests/shared/test_memory.py b/tests/shared/test_memory.py index 60a90de3d..0a0515ca7 100644 --- a/tests/shared/test_memory.py +++ b/tests/shared/test_memory.py @@ -1,12 +1,12 @@ import pytest from typing_extensions import AsyncGenerator -from mcp_python.client.session import ClientSession -from mcp_python.server import Server -from mcp_python.shared.memory import ( +from mcp.client.session import ClientSession +from mcp.server import Server +from mcp.shared.memory import ( create_connected_server_and_client_session, ) -from mcp_python.types import ( +from mcp.types import ( EmptyResult, ) diff --git a/tests/test_types.py b/tests/test_types.py index e2c0ac279..c3981ad3e 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,4 +1,4 @@ -from mcp_python.types import ( +from mcp.types import ( LATEST_PROTOCOL_VERSION, ClientRequest, JSONRPCMessage, @@ -14,7 +14,7 @@ def test_jsonrpc_request(): "params": { "protocolVersion": LATEST_PROTOCOL_VERSION, "capabilities": {"batch": None, "sampling": None}, - "clientInfo": {"name": "mcp_python", "version": "0.1.0"}, + "clientInfo": {"name": "mcp", "version": "0.1.0"}, }, } diff --git a/uv.lock b/uv.lock index 54d5cd69e..35e52f473 100644 --- a/uv.lock +++ b/uv.lock @@ -162,8 +162,8 @@ wheels = [ ] [[package]] -name = "mcp-python" -version = "0.6.1" +name = "mcp" +version = "0.7.0.dev0" source = { editable = "." } dependencies = [ { name = "anyio" }, @@ -194,7 +194,7 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ - { name = "pyright", specifier = ">=1.1.384" }, + { name = "pyright", specifier = ">=1.1.378" }, { name = "pytest", specifier = ">=8.3.3" }, { name = "ruff", specifier = ">=0.6.9" }, { name = "trio", specifier = ">=0.26.2" }, @@ -223,11 +223,11 @@ wheels = [ [[package]] name = "packaging" -version = "24.1" +version = "24.2" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/51/65/50db4dda066951078f0a96cf12f4b9ada6e4b811516bf0262c0f4f7064d4/packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", size = 148788 } +sdist = { url = "https://files.pythonhosted.org/packages/d0/63/68dbb6eb2de9cb10ee4c9c14a0148804425e13c4fb20d61cce69f53106da/packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f", size = 163950 } wheels = [ - { url = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124", size = 53985 }, + { url = "https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", size = 65451 }, ] [[package]] @@ -331,15 +331,15 @@ wheels = [ [[package]] name = "pyright" -version = "1.1.385" +version = "1.1.388" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "nodeenv" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/29/ca/3238db97766ecfd6b2758fb50727a0b433e7b1bb6be0de090ed08b291fff/pyright-1.1.385.tar.gz", hash = "sha256:1bf042b8f080441534aa02101dea30f8fc2efa8f7b6f1ab05197c21317f5bfa7", size = 21971 } +sdist = { url = "https://files.pythonhosted.org/packages/9c/83/e9867538a794638d2d20ac3ab3106a31aca1d9cfea530c9b2921809dae03/pyright-1.1.388.tar.gz", hash = "sha256:0166d19b716b77fd2d9055de29f71d844874dbc6b9d3472ccd22df91db3dfa34", size = 21939 } wheels = [ - { url = "https://files.pythonhosted.org/packages/e3/39/877484412a1079003a7645375b487bd7c422692f4e5b7c2030dea3e83043/pyright-1.1.385-py3-none-any.whl", hash = "sha256:e5b9a1b8d492e13004d822af94d07d235f2c7c158457293b51ab2214c8c5b375", size = 18579 }, + { url = "https://files.pythonhosted.org/packages/03/57/7fb00363b7f267a398c5bdf4f55f3e64f7c2076b2e7d2901b3373d52b6ff/pyright-1.1.388-py3-none-any.whl", hash = "sha256:c7068e9f2c23539c6ac35fc9efac6c6c1b9aa5a0ce97a9a8a6cf0090d7cbf84c", size = 18579 }, ] [[package]] @@ -361,27 +361,27 @@ wheels = [ [[package]] name = "ruff" -version = "0.7.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/2c/c7/f3367d1da5d568192968c5c9e7f3d51fb317b9ac04828493b23d8fce8ce6/ruff-0.7.0.tar.gz", hash = "sha256:47a86360cf62d9cd53ebfb0b5eb0e882193fc191c6d717e8bef4462bc3b9ea2b", size = 3146645 } -wheels = [ - { url = "https://files.pythonhosted.org/packages/48/59/a0275a0913f3539498d116046dd679cd657fe3b7caf5afe1733319414932/ruff-0.7.0-py3-none-linux_armv6l.whl", hash = "sha256:0cdf20c2b6ff98e37df47b2b0bd3a34aaa155f59a11182c1303cce79be715628", size = 10434007 }, - { url = "https://files.pythonhosted.org/packages/cd/94/da0ba5f956d04c90dd899209904210600009dcda039ce840d83eb4298c7d/ruff-0.7.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:496494d350c7fdeb36ca4ef1c9f21d80d182423718782222c29b3e72b3512737", size = 10048066 }, - { url = "https://files.pythonhosted.org/packages/57/1d/e5cc149ecc46e4f203403a79ccd170fad52d316f98b87d0f63b1945567db/ruff-0.7.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:214b88498684e20b6b2b8852c01d50f0651f3cc6118dfa113b4def9f14faaf06", size = 9711389 }, - { url = "https://files.pythonhosted.org/packages/05/67/fb7ea2c869c539725a16c5bc294e9aa34f8b1b6fe702f1d173a5da517c2b/ruff-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:630fce3fefe9844e91ea5bbf7ceadab4f9981f42b704fae011bb8efcaf5d84be", size = 10755174 }, - { url = "https://files.pythonhosted.org/packages/5f/f0/13703bc50536a0613ea3dce991116e5f0917a1f05528c6ab738b33c08d3f/ruff-0.7.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:211d877674e9373d4bb0f1c80f97a0201c61bcd1e9d045b6e9726adc42c156aa", size = 10196040 }, - { url = "https://files.pythonhosted.org/packages/99/c1/77b04ab20324ab03d333522ee55fb0f1c38e3ca0d326b4905f82ce6b6c70/ruff-0.7.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:194d6c46c98c73949a106425ed40a576f52291c12bc21399eb8f13a0f7073495", size = 11033684 }, - { url = "https://files.pythonhosted.org/packages/f2/97/f463334dc4efeea3551cd109163df15561c18a1c3ec13d51643740fd36ba/ruff-0.7.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:82c2579b82b9973a110fab281860403b397c08c403de92de19568f32f7178598", size = 11803700 }, - { url = "https://files.pythonhosted.org/packages/b4/f8/a31d40c4bb92933d376a53e7c5d0245d9b27841357e4820e96d38f54b480/ruff-0.7.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9af971fe85dcd5eaed8f585ddbc6bdbe8c217fb8fcf510ea6bca5bdfff56040e", size = 11347848 }, - { url = "https://files.pythonhosted.org/packages/83/62/0c133b35ddaf91c65c30a56718b80bdef36bfffc35684d29e3a4878e0ea3/ruff-0.7.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b641c7f16939b7d24b7bfc0be4102c56562a18281f84f635604e8a6989948914", size = 12480632 }, - { url = "https://files.pythonhosted.org/packages/46/96/464058dd1d980014fb5aa0a1254e78799efb3096fc7a4823cd66a1621276/ruff-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d71672336e46b34e0c90a790afeac8a31954fd42872c1f6adaea1dff76fd44f9", size = 10941919 }, - { url = "https://files.pythonhosted.org/packages/a0/f7/bda37ec77986a435dde44e1f59374aebf4282a5fa9cf17735315b847141f/ruff-0.7.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ab7d98c7eed355166f367597e513a6c82408df4181a937628dbec79abb2a1fe4", size = 10745519 }, - { url = "https://files.pythonhosted.org/packages/c2/33/5f77fc317027c057b61a848020a47442a1cbf12e592df0e41e21f4d0f3bd/ruff-0.7.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1eb54986f770f49edb14f71d33312d79e00e629a57387382200b1ef12d6a4ef9", size = 10284872 }, - { url = "https://files.pythonhosted.org/packages/ff/50/98aec292bc9537f640b8d031c55f3414bf15b6ed13b3e943fed75ac927b9/ruff-0.7.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:dc452ba6f2bb9cf8726a84aa877061a2462afe9ae0ea1d411c53d226661c601d", size = 10600334 }, - { url = "https://files.pythonhosted.org/packages/f2/85/12607ae3201423a179b8cfadc7cb1e57d02cd0135e45bd0445acb4cef327/ruff-0.7.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:4b406c2dce5be9bad59f2de26139a86017a517e6bcd2688da515481c05a2cb11", size = 11017333 }, - { url = "https://files.pythonhosted.org/packages/d4/7f/3b85a56879e705d5f46ec14daf8a439fca05c3081720fe3dc3209100922d/ruff-0.7.0-py3-none-win32.whl", hash = "sha256:f6c968509f767776f524a8430426539587d5ec5c662f6addb6aa25bc2e8195ec", size = 8570962 }, - { url = "https://files.pythonhosted.org/packages/39/9f/c5ee2b40d377354dabcc23cff47eb299de4b4d06d345068f8f8cc1eadac8/ruff-0.7.0-py3-none-win_amd64.whl", hash = "sha256:ff4aabfbaaba880e85d394603b9e75d32b0693152e16fa659a3064a85df7fce2", size = 9365544 }, - { url = "https://files.pythonhosted.org/packages/89/8b/ee1509f60148cecba644aa718f6633216784302458340311898aaf0b1bed/ruff-0.7.0-py3-none-win_arm64.whl", hash = "sha256:10842f69c245e78d6adec7e1db0a7d9ddc2fff0621d730e61657b64fa36f207e", size = 8695763 }, +version = "0.7.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4b/06/09d1276df977eece383d0ed66052fc24ec4550a61f8fbc0a11200e690496/ruff-0.7.3.tar.gz", hash = "sha256:e1d1ba2e40b6e71a61b063354d04be669ab0d39c352461f3d789cac68b54a313", size = 3243664 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c0/56/933d433c2489e4642487b835f53dd9ff015fb3d8fa459b09bb2ce42d7c4b/ruff-0.7.3-py3-none-linux_armv6l.whl", hash = "sha256:34f2339dc22687ec7e7002792d1f50712bf84a13d5152e75712ac08be565d344", size = 10372090 }, + { url = "https://files.pythonhosted.org/packages/20/ea/1f0a22a6bcdd3fc26c73f63a025d05bd565901b729d56bcb093c722a6c4c/ruff-0.7.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:fb397332a1879b9764a3455a0bb1087bda876c2db8aca3a3cbb67b3dbce8cda0", size = 10190037 }, + { url = "https://files.pythonhosted.org/packages/16/74/aca75666e0d481fe394e76a8647c44ea919087748024924baa1a17371e3e/ruff-0.7.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:37d0b619546103274e7f62643d14e1adcbccb242efda4e4bdb9544d7764782e9", size = 9811998 }, + { url = "https://files.pythonhosted.org/packages/20/a1/cf446a0d7f78ea1f0bd2b9171c11dfe746585c0c4a734b25966121eb4f5d/ruff-0.7.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d59f0c3ee4d1a6787614e7135b72e21024875266101142a09a61439cb6e38a5", size = 10620626 }, + { url = "https://files.pythonhosted.org/packages/cd/c1/82b27d09286ae855f5d03b1ad37cf243f21eb0081732d4d7b0d658d439cb/ruff-0.7.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:44eb93c2499a169d49fafd07bc62ac89b1bc800b197e50ff4633aed212569299", size = 10177598 }, + { url = "https://files.pythonhosted.org/packages/b9/42/c0acac22753bf74013d035a5ef6c5c4c40ad4d6686bfb3fda7c6f37d9b37/ruff-0.7.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6d0242ce53f3a576c35ee32d907475a8d569944c0407f91d207c8af5be5dae4e", size = 11171963 }, + { url = "https://files.pythonhosted.org/packages/43/18/bb0befb7fb9121dd9009e6a72eb98e24f1bacb07c6f3ecb55f032ba98aed/ruff-0.7.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6b6224af8b5e09772c2ecb8dc9f3f344c1aa48201c7f07e7315367f6dd90ac29", size = 11856157 }, + { url = "https://files.pythonhosted.org/packages/5e/91/04e98d7d6e32eca9d1372be595f9abc7b7f048795e32eb2edbd8794d50bd/ruff-0.7.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c50f95a82b94421c964fae4c27c0242890a20fe67d203d127e84fbb8013855f5", size = 11440331 }, + { url = "https://files.pythonhosted.org/packages/f5/dc/3fe99f2ce10b76d389041a1b9f99e7066332e479435d4bebcceea16caff5/ruff-0.7.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7f3eff9961b5d2644bcf1616c606e93baa2d6b349e8aa8b035f654df252c8c67", size = 12725354 }, + { url = "https://files.pythonhosted.org/packages/43/7b/1daa712de1c5bc6cbbf9fa60e9c41cc48cda962dc6d2c4f2a224d2c3007e/ruff-0.7.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8963cab06d130c4df2fd52c84e9f10d297826d2e8169ae0c798b6221be1d1d2", size = 11010091 }, + { url = "https://files.pythonhosted.org/packages/b6/db/1227a903587432eb569e57a95b15a4f191a71fe315cde4c0312df7bc85da/ruff-0.7.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:61b46049d6edc0e4317fb14b33bd693245281a3007288b68a3f5b74a22a0746d", size = 10610687 }, + { url = "https://files.pythonhosted.org/packages/db/e2/dc41ee90c3085aadad4da614d310d834f641aaafddf3dfbba08210c616ce/ruff-0.7.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:10ebce7696afe4644e8c1a23b3cf8c0f2193a310c18387c06e583ae9ef284de2", size = 10254843 }, + { url = "https://files.pythonhosted.org/packages/6f/09/5f6cac1c91542bc5bd33d40b4c13b637bf64d7bb29e091dadb01b62527fe/ruff-0.7.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3f36d56326b3aef8eeee150b700e519880d1aab92f471eefdef656fd57492aa2", size = 10730962 }, + { url = "https://files.pythonhosted.org/packages/d3/42/89a4b9a24ef7d00269e24086c417a006f9a3ffeac2c80f2629eb5ce140ee/ruff-0.7.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5d024301109a0007b78d57ab0ba190087b43dce852e552734ebf0b0b85e4fb16", size = 11101907 }, + { url = "https://files.pythonhosted.org/packages/b0/5c/efdb4777686683a8edce94ffd812783bddcd3d2454d38c5ac193fef7c500/ruff-0.7.3-py3-none-win32.whl", hash = "sha256:4ba81a5f0c5478aa61674c5a2194de8b02652f17addf8dfc40c8937e6e7d79fc", size = 8611095 }, + { url = "https://files.pythonhosted.org/packages/bb/b8/28fbc6a4efa50178f973972d1c84b2d0a33cdc731588522ab751ac3da2f5/ruff-0.7.3-py3-none-win_amd64.whl", hash = "sha256:588a9ff2fecf01025ed065fe28809cd5a53b43505f48b69a1ac7707b1b7e4088", size = 9418283 }, + { url = "https://files.pythonhosted.org/packages/3f/77/b587cba6febd5e2003374f37eb89633f79f161e71084f94057c8653b7fb3/ruff-0.7.3-py3-none-win_arm64.whl", hash = "sha256:1713e2c5545863cdbfe2cbce21f69ffaf37b813bfd1fb3b90dc9a6f1963f5a8c", size = 8725228 }, ] [[package]] @@ -418,14 +418,14 @@ wheels = [ [[package]] name = "starlette" -version = "0.41.0" +version = "0.41.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/78/53/c3a36690a923706e7ac841f649c64f5108889ab1ec44218dac45771f252a/starlette-0.41.0.tar.gz", hash = "sha256:39cbd8768b107d68bfe1ff1672b38a2c38b49777de46d2a592841d58e3bf7c2a", size = 2573755 } +sdist = { url = "https://files.pythonhosted.org/packages/3e/da/1fb4bdb72ae12b834becd7e1e7e47001d32f91ec0ce8d7bc1b618d9f0bd9/starlette-0.41.2.tar.gz", hash = "sha256:9834fd799d1a87fd346deb76158668cfa0b0d56f85caefe8268e2d97c3468b62", size = 2573867 } wheels = [ - { url = "https://files.pythonhosted.org/packages/35/c6/a4443bfabf5629129512ca0e07866c4c3c094079ba4e9b2551006927253c/starlette-0.41.0-py3-none-any.whl", hash = "sha256:a0193a3c413ebc9c78bff1c3546a45bb8c8bcb4a84cae8747d650a65bd37210a", size = 73216 }, + { url = "https://files.pythonhosted.org/packages/54/43/f185bfd0ca1d213beb4293bed51d92254df23d8ceaf6c0e17146d508a776/starlette-0.41.2-py3-none-any.whl", hash = "sha256:fbc189474b4731cf30fcef52f18a8d070e3f3b46c6a04c97579e85e6ffca942d", size = 73259 }, ] [[package]]