π The fast, Pythonic way to build MCP servers and clients.
Ensure contrib is importable
Jeremiah Lowin2cc577168b86
diff --git a/src/contrib/README.md b/src/fastmcp/contrib/README.mdsimilarity index 58%rename from src/contrib/README.mdrename to src/fastmcp/contrib/README.mdindex 3df31bf9c..7b1dbb550 100644--- a/src/contrib/README.md+++ b/src/fastmcp/contrib/README.md@@ -6,4 +6,14 @@ This directory holds community-contributed modules for FastMCP. These modules ex* Modules in `contrib` may have different testing requirements or stability guarantees compared to the core library.* Changes to the core FastMCP library might break modules in `contrib` without explicit warnings in the main changelog.-Use these modules at your own discretion. Contributions are welcome, but please include tests and documentation.\ No newline at end of file+Use these modules at your own discretion. Contributions are welcome, but please include tests and documentation.++## Usage++To use a contrib module, import it from the `fastmcp.contrib` package.++```python+from fastmcp.contrib import my_module+```++Note that the contrib modules may have different dependencies than the core library, which can be noted in their respective README's or even separate requirements / dependency files.\ No newline at end of filediff --git a/src/contrib/bulk_tool_caller/README.md b/src/fastmcp/contrib/bulk_tool_caller/README.mdsimilarity index 100%rename from src/contrib/bulk_tool_caller/README.mdrename to src/fastmcp/contrib/bulk_tool_caller/README.mddiff --git a/src/contrib/bulk_tool_caller/__init__.py b/src/fastmcp/contrib/bulk_tool_caller/__init__.pysimilarity index 100%rename from src/contrib/bulk_tool_caller/__init__.pyrename to src/fastmcp/contrib/bulk_tool_caller/__init__.pydiff --git a/src/contrib/bulk_tool_caller/bulk_tool_caller.py b/src/fastmcp/contrib/bulk_tool_caller/bulk_tool_caller.pysimilarity index 97%rename from src/contrib/bulk_tool_caller/bulk_tool_caller.pyrename to src/fastmcp/contrib/bulk_tool_caller/bulk_tool_caller.pyindex aa02c5e61..365dd95b7 100644--- a/src/contrib/bulk_tool_caller/bulk_tool_caller.py+++ b/src/fastmcp/contrib/bulk_tool_caller/bulk_tool_caller.py@@ -3,10 +3,14 @@ from typing import Anyfrom mcp.types import CallToolResultfrom pydantic import BaseModel, Field-from contrib.mcp_mixin.mcp_mixin import _DEFAULT_SEPARATOR_TOOL, MCPMixin, mcp_toolfrom fastmcp import FastMCPfrom fastmcp.client import Clientfrom fastmcp.client.transports import FastMCPTransport+from fastmcp.contrib.mcp_mixin.mcp_mixin import (+ _DEFAULT_SEPARATOR_TOOL,+ MCPMixin,+ mcp_tool,+)class CallToolRequest(BaseModel):diff --git a/src/contrib/bulk_tool_caller/example.py b/src/fastmcp/contrib/bulk_tool_caller/example.pysimilarity index 81%rename from src/contrib/bulk_tool_caller/example.pyrename to src/fastmcp/contrib/bulk_tool_caller/example.pyindex 76170c197..85139feda 100644--- a/src/contrib/bulk_tool_caller/example.py+++ b/src/fastmcp/contrib/bulk_tool_caller/example.py@@ -1,7 +1,7 @@"""Sample code for FastMCP using MCPMixin."""-from contrib.bulk_tool_caller import BulkToolCallerfrom fastmcp import FastMCP+from fastmcp.contrib.bulk_tool_caller import BulkToolCallermcp = FastMCP()diff --git a/src/contrib/mcp_mixin/README.md b/src/fastmcp/contrib/mcp_mixin/README.mdsimilarity index 92%rename from src/contrib/mcp_mixin/README.mdrename to src/fastmcp/contrib/mcp_mixin/README.mdindex 3acb66190..6dce9c9e3 100644--- a/src/contrib/mcp_mixin/README.md+++ b/src/fastmcp/contrib/mcp_mixin/README.md@@ -10,7 +10,7 @@ Inherit from `MCPMixin` and use the decorators on the methods you want to regist```pythonfrom fastmcp import FastMCP-from contrib.mcp_mixin import MCPMixin, mcp_tool, mcp_resource+from fastmcp.contrib.mcp_mixin import MCPMixin, mcp_tool, mcp_resourceclass MyComponent(MCPMixin):@mcp_tool(name="my_tool", description="Does something cool.")diff --git a/src/contrib/mcp_mixin/__init__.py b/src/fastmcp/contrib/mcp_mixin/__init__.pysimilarity index 100%rename from src/contrib/mcp_mixin/__init__.pyrename to src/fastmcp/contrib/mcp_mixin/__init__.pydiff --git a/src/contrib/mcp_mixin/example.py b/src/fastmcp/contrib/mcp_mixin/example.pysimilarity index 96%rename from src/contrib/mcp_mixin/example.pyrename to src/fastmcp/contrib/mcp_mixin/example.pyindex 5e996632e..dcdc4c272 100644--- a/src/contrib/mcp_mixin/example.py+++ b/src/fastmcp/contrib/mcp_mixin/example.py@@ -2,13 +2,13 @@import asyncio-from contrib.mcp_mixin import (+from fastmcp import FastMCP+from fastmcp.contrib.mcp_mixin import (MCPMixin,mcp_prompt,mcp_resource,mcp_tool,)-from fastmcp import FastMCPmcp = FastMCP()diff --git a/src/contrib/mcp_mixin/mcp_mixin.py b/src/fastmcp/contrib/mcp_mixin/mcp_mixin.pysimilarity index 100%rename from src/contrib/mcp_mixin/mcp_mixin.pyrename to src/fastmcp/contrib/mcp_mixin/mcp_mixin.pydiff --git a/tests/contrib/test_bulk_tool_caller.py b/tests/contrib/test_bulk_tool_caller.pyindex 5e5519852..348eb0ef7 100644--- a/tests/contrib/test_bulk_tool_caller.py+++ b/tests/contrib/test_bulk_tool_caller.py@@ -3,12 +3,12 @@ from typing import Anyimport pytestfrom mcp.types import EmbeddedResource, ImageContent, TextContent-from contrib.bulk_tool_caller.bulk_tool_caller import (+from fastmcp import FastMCP+from fastmcp.contrib.bulk_tool_caller.bulk_tool_caller import (BulkToolCaller,CallToolRequest,CallToolRequestResult,)-from fastmcp import FastMCPContentType = TextContent | ImageContent | EmbeddedResourcediff --git a/tests/contrib/test_mcp_mixin.py b/tests/contrib/test_mcp_mixin.pyindex b31919cff..a39b293e3 100644--- a/tests/contrib/test_mcp_mixin.py+++ b/tests/contrib/test_mcp_mixin.py@@ -2,18 +2,18 @@import pytest-from contrib.mcp_mixin import (+from fastmcp import FastMCP+from fastmcp.contrib.mcp_mixin import (MCPMixin,mcp_prompt,mcp_resource,mcp_tool,)-from contrib.mcp_mixin.mcp_mixin import (+from fastmcp.contrib.mcp_mixin.mcp_mixin import (_DEFAULT_SEPARATOR_PROMPT,_DEFAULT_SEPARATOR_RESOURCE,_DEFAULT_SEPARATOR_TOOL,)-from fastmcp import FastMCPclass TestMCPMixin: