Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Rename dirs

Jeremiah Lowin43977765faab
diff --git a/src/fastmcp/__init__.py b/src/fastmcp/__init__.py
index 03ed6204b..ddcb3c456 100644
--- a/src/fastmcp/__init__.py
+++ b/src/fastmcp/__init__.py
@@ -2,9 +2,11 @@
from importlib.metadata import version
from fastmcp.server import FastMCP, Context
+from . import clients
__version__ = version("fastmcp")
__all__ = [
"FastMCP",
"Context",
+ "clients",
]
diff --git a/src/fastmcp/client/__init__.py b/src/fastmcp/clients/__init__.py
similarity index 75%
rename from src/fastmcp/client/__init__.py
rename to src/fastmcp/clients/__init__.py
index 2a07f0fdb..c9d74c25f 100644
--- a/src/fastmcp/client/__init__.py
+++ b/src/fastmcp/clients/__init__.py
@@ -1,12 +1,12 @@
from .websocket import WebSocketClient
from .sse import SSEClient
from .stdio import StdioClient, UvxClient
-from .memory import InMemoryClient
+from .fastmcp_client import FastMCPClient
__all__ = [
"StdioClient",
"SSEClient",
"WebSocketClient",
"UvxClient",
- "InMemoryClient",
+ "FastMCPClient",
]
diff --git a/src/fastmcp/client/base.py b/src/fastmcp/clients/base.py
similarity index 100%
rename from src/fastmcp/client/base.py
rename to src/fastmcp/clients/base.py
diff --git a/src/fastmcp/client/memory.py b/src/fastmcp/clients/fastmcp_client.py
similarity index 90%
rename from src/fastmcp/client/memory.py
rename to src/fastmcp/clients/fastmcp_client.py
index 1a497f81e..64f211ea3 100644
--- a/src/fastmcp/client/memory.py
+++ b/src/fastmcp/clients/fastmcp_client.py
@@ -4,14 +4,14 @@ from typing import TypeVar
from mcp.shared.memory import create_connected_server_and_client_session
from typing_extensions import Unpack
-from fastmcp.client.base import BaseClient, ClientKwargs
+from fastmcp.clients.base import BaseClient, ClientKwargs
from fastmcp.server.server import FastMCP
T = TypeVar("T")
-class InMemoryClient(BaseClient):
- """Client that connects to an in-memory MCP server.
+class FastMCPClient(BaseClient):
+ """Client that connects directly to an in-memory FastMCP server.
This client creates and manages an in-memory connection to a server,
without using any external processes or network connections.
diff --git a/src/fastmcp/client/sse.py b/src/fastmcp/clients/sse.py
similarity index 94%
rename from src/fastmcp/client/sse.py
rename to src/fastmcp/clients/sse.py
index 578a32106..2cf0570a9 100644
--- a/src/fastmcp/client/sse.py
+++ b/src/fastmcp/clients/sse.py
@@ -4,7 +4,7 @@ from mcp import ClientSession
from mcp.client.sse import sse_client
from typing_extensions import Unpack
-from fastmcp.client.base import BaseClient, ClientKwargs
+from fastmcp.clients.base import BaseClient, ClientKwargs
class SSEClient(BaseClient):
diff --git a/src/fastmcp/client/stdio.py b/src/fastmcp/clients/stdio.py
similarity index 98%
rename from src/fastmcp/client/stdio.py
rename to src/fastmcp/clients/stdio.py
index ad358d66a..208550535 100644
--- a/src/fastmcp/client/stdio.py
+++ b/src/fastmcp/clients/stdio.py
@@ -6,7 +6,7 @@ from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from typing_extensions import Unpack
-from fastmcp.client.base import BaseClient, ClientKwargs
+from fastmcp.clients.base import BaseClient, ClientKwargs
class StdioClient(BaseClient):
diff --git a/src/fastmcp/client/websocket.py b/src/fastmcp/clients/websocket.py
similarity index 93%
rename from src/fastmcp/client/websocket.py
rename to src/fastmcp/clients/websocket.py
index d3a77a47b..8f1edc02c 100644
--- a/src/fastmcp/client/websocket.py
+++ b/src/fastmcp/clients/websocket.py
@@ -4,7 +4,7 @@ from mcp import ClientSession
from mcp.client.websocket import websocket_client
from typing_extensions import Unpack
-from fastmcp.client.base import BaseClient, ClientKwargs
+from fastmcp.clients.base import BaseClient, ClientKwargs
class WebSocketClient(BaseClient):
diff --git a/tests/client/__init__.py b/tests/clients/__init__.py
similarity index 100%
rename from tests/client/__init__.py
rename to tests/clients/__init__.py
diff --git a/tests/client/test_memory_client.py b/tests/clients/test_fastmcp_client.py
similarity index 90%
rename from tests/client/test_memory_client.py
rename to tests/clients/test_fastmcp_client.py
index f103588e4..0d4b88167 100644
--- a/tests/client/test_memory_client.py
+++ b/tests/clients/test_fastmcp_client.py
@@ -3,7 +3,7 @@ from typing import cast
import pytest
from pydantic import AnyUrl
-from fastmcp.client.memory import InMemoryClient
+from fastmcp.clients import FastMCPClient
from fastmcp.server.server import FastMCP
@@ -50,7 +50,7 @@ def fastmcp_server():
async def test_list_tools(fastmcp_server):
"""Test listing tools with InMemoryClient."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
async with client:
result = await client.list_tools()
@@ -64,7 +64,7 @@ async def test_list_tools(fastmcp_server):
async def test_call_tool(fastmcp_server):
"""Test calling a tool with InMemoryClient."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
async with client:
result = await client.call_tool("greet", {"name": "World"})
@@ -76,7 +76,7 @@ async def test_call_tool(fastmcp_server):
async def test_list_resources(fastmcp_server):
"""Test listing resources with InMemoryClient."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
async with client:
result = await client.list_resources()
@@ -88,7 +88,7 @@ async def test_list_resources(fastmcp_server):
async def test_list_prompts(fastmcp_server):
"""Test listing prompts with InMemoryClient."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
async with client:
result = await client.list_prompts()
@@ -100,7 +100,7 @@ async def test_list_prompts(fastmcp_server):
async def test_get_prompt(fastmcp_server):
"""Test getting a prompt with InMemoryClient."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
async with client:
result = await client.get_prompt("welcome", {"name": "Developer"})
@@ -112,7 +112,7 @@ async def test_get_prompt(fastmcp_server):
async def test_read_resource(fastmcp_server):
"""Test reading a resource with InMemoryClient."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
async with client:
# Use the URI from the resource we know exists in our server
@@ -130,7 +130,7 @@ async def test_read_resource(fastmcp_server):
async def test_client_connection(fastmcp_server):
"""Test that the client connects and disconnects properly."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
# Before connection
assert not client.is_connected()
@@ -145,7 +145,7 @@ async def test_client_connection(fastmcp_server):
async def test_resource_template(fastmcp_server):
"""Test using a resource template with InMemoryClient."""
- client = InMemoryClient(server=fastmcp_server)
+ client = FastMCPClient(server=fastmcp_server)
async with client:
# First, list templates