Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
ecb6207
1
Parent(s): d5fbe48
Ensure contrib is importable
Browse files- src/{contrib → fastmcp/contrib}/README.md +11 -1
- src/{contrib → fastmcp/contrib}/bulk_tool_caller/README.md +0 -0
- src/{contrib → fastmcp/contrib}/bulk_tool_caller/__init__.py +0 -0
- src/{contrib → fastmcp/contrib}/bulk_tool_caller/bulk_tool_caller.py +5 -1
- src/{contrib → fastmcp/contrib}/bulk_tool_caller/example.py +1 -1
- src/{contrib → fastmcp/contrib}/mcp_mixin/README.md +1 -1
- src/{contrib → fastmcp/contrib}/mcp_mixin/__init__.py +0 -0
- src/{contrib → fastmcp/contrib}/mcp_mixin/example.py +2 -2
- src/{contrib → fastmcp/contrib}/mcp_mixin/mcp_mixin.py +0 -0
- tests/contrib/test_bulk_tool_caller.py +2 -2
- tests/contrib/test_mcp_mixin.py +3 -3
src/{contrib → fastmcp/contrib}/README.md
RENAMED
|
@@ -6,4 +6,14 @@ This directory holds community-contributed modules for FastMCP. These modules ex
|
|
| 6 |
* Modules in `contrib` may have different testing requirements or stability guarantees compared to the core library.
|
| 7 |
* Changes to the core FastMCP library might break modules in `contrib` without explicit warnings in the main changelog.
|
| 8 |
|
| 9 |
-
Use these modules at your own discretion. Contributions are welcome, but please include tests and documentation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
* Modules in `contrib` may have different testing requirements or stability guarantees compared to the core library.
|
| 7 |
* Changes to the core FastMCP library might break modules in `contrib` without explicit warnings in the main changelog.
|
| 8 |
|
| 9 |
+
Use these modules at your own discretion. Contributions are welcome, but please include tests and documentation.
|
| 10 |
+
|
| 11 |
+
## Usage
|
| 12 |
+
|
| 13 |
+
To use a contrib module, import it from the `fastmcp.contrib` package.
|
| 14 |
+
|
| 15 |
+
```python
|
| 16 |
+
from fastmcp.contrib import my_module
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
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.
|
src/{contrib → fastmcp/contrib}/bulk_tool_caller/README.md
RENAMED
|
File without changes
|
src/{contrib → fastmcp/contrib}/bulk_tool_caller/__init__.py
RENAMED
|
File without changes
|
src/{contrib → fastmcp/contrib}/bulk_tool_caller/bulk_tool_caller.py
RENAMED
|
@@ -3,10 +3,14 @@ from typing import Any
|
|
| 3 |
from mcp.types import CallToolResult
|
| 4 |
from pydantic import BaseModel, Field
|
| 5 |
|
| 6 |
-
from contrib.mcp_mixin.mcp_mixin import _DEFAULT_SEPARATOR_TOOL, MCPMixin, mcp_tool
|
| 7 |
from fastmcp import FastMCP
|
| 8 |
from fastmcp.client import Client
|
| 9 |
from fastmcp.client.transports import FastMCPTransport
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
class CallToolRequest(BaseModel):
|
|
|
|
| 3 |
from mcp.types import CallToolResult
|
| 4 |
from pydantic import BaseModel, Field
|
| 5 |
|
|
|
|
| 6 |
from fastmcp import FastMCP
|
| 7 |
from fastmcp.client import Client
|
| 8 |
from fastmcp.client.transports import FastMCPTransport
|
| 9 |
+
from fastmcp.contrib.mcp_mixin.mcp_mixin import (
|
| 10 |
+
_DEFAULT_SEPARATOR_TOOL,
|
| 11 |
+
MCPMixin,
|
| 12 |
+
mcp_tool,
|
| 13 |
+
)
|
| 14 |
|
| 15 |
|
| 16 |
class CallToolRequest(BaseModel):
|
src/{contrib → fastmcp/contrib}/bulk_tool_caller/example.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""Sample code for FastMCP using MCPMixin."""
|
| 2 |
|
| 3 |
-
from contrib.bulk_tool_caller import BulkToolCaller
|
| 4 |
from fastmcp import FastMCP
|
|
|
|
| 5 |
|
| 6 |
mcp = FastMCP()
|
| 7 |
|
|
|
|
| 1 |
"""Sample code for FastMCP using MCPMixin."""
|
| 2 |
|
|
|
|
| 3 |
from fastmcp import FastMCP
|
| 4 |
+
from fastmcp.contrib.bulk_tool_caller import BulkToolCaller
|
| 5 |
|
| 6 |
mcp = FastMCP()
|
| 7 |
|
src/{contrib → fastmcp/contrib}/mcp_mixin/README.md
RENAMED
|
@@ -10,7 +10,7 @@ Inherit from `MCPMixin` and use the decorators on the methods you want to regist
|
|
| 10 |
|
| 11 |
```python
|
| 12 |
from fastmcp import FastMCP
|
| 13 |
-
from contrib.mcp_mixin import MCPMixin, mcp_tool, mcp_resource
|
| 14 |
|
| 15 |
class MyComponent(MCPMixin):
|
| 16 |
@mcp_tool(name="my_tool", description="Does something cool.")
|
|
|
|
| 10 |
|
| 11 |
```python
|
| 12 |
from fastmcp import FastMCP
|
| 13 |
+
from fastmcp.contrib.mcp_mixin import MCPMixin, mcp_tool, mcp_resource
|
| 14 |
|
| 15 |
class MyComponent(MCPMixin):
|
| 16 |
@mcp_tool(name="my_tool", description="Does something cool.")
|
src/{contrib → fastmcp/contrib}/mcp_mixin/__init__.py
RENAMED
|
File without changes
|
src/{contrib → fastmcp/contrib}/mcp_mixin/example.py
RENAMED
|
@@ -2,13 +2,13 @@
|
|
| 2 |
|
| 3 |
import asyncio
|
| 4 |
|
| 5 |
-
from
|
|
|
|
| 6 |
MCPMixin,
|
| 7 |
mcp_prompt,
|
| 8 |
mcp_resource,
|
| 9 |
mcp_tool,
|
| 10 |
)
|
| 11 |
-
from fastmcp import FastMCP
|
| 12 |
|
| 13 |
mcp = FastMCP()
|
| 14 |
|
|
|
|
| 2 |
|
| 3 |
import asyncio
|
| 4 |
|
| 5 |
+
from fastmcp import FastMCP
|
| 6 |
+
from fastmcp.contrib.mcp_mixin import (
|
| 7 |
MCPMixin,
|
| 8 |
mcp_prompt,
|
| 9 |
mcp_resource,
|
| 10 |
mcp_tool,
|
| 11 |
)
|
|
|
|
| 12 |
|
| 13 |
mcp = FastMCP()
|
| 14 |
|
src/{contrib → fastmcp/contrib}/mcp_mixin/mcp_mixin.py
RENAMED
|
File without changes
|
tests/contrib/test_bulk_tool_caller.py
CHANGED
|
@@ -3,12 +3,12 @@ from typing import Any
|
|
| 3 |
import pytest
|
| 4 |
from mcp.types import EmbeddedResource, ImageContent, TextContent
|
| 5 |
|
| 6 |
-
from
|
|
|
|
| 7 |
BulkToolCaller,
|
| 8 |
CallToolRequest,
|
| 9 |
CallToolRequestResult,
|
| 10 |
)
|
| 11 |
-
from fastmcp import FastMCP
|
| 12 |
|
| 13 |
ContentType = TextContent | ImageContent | EmbeddedResource
|
| 14 |
|
|
|
|
| 3 |
import pytest
|
| 4 |
from mcp.types import EmbeddedResource, ImageContent, TextContent
|
| 5 |
|
| 6 |
+
from fastmcp import FastMCP
|
| 7 |
+
from fastmcp.contrib.bulk_tool_caller.bulk_tool_caller import (
|
| 8 |
BulkToolCaller,
|
| 9 |
CallToolRequest,
|
| 10 |
CallToolRequestResult,
|
| 11 |
)
|
|
|
|
| 12 |
|
| 13 |
ContentType = TextContent | ImageContent | EmbeddedResource
|
| 14 |
|
tests/contrib/test_mcp_mixin.py
CHANGED
|
@@ -2,18 +2,18 @@
|
|
| 2 |
|
| 3 |
import pytest
|
| 4 |
|
| 5 |
-
from
|
|
|
|
| 6 |
MCPMixin,
|
| 7 |
mcp_prompt,
|
| 8 |
mcp_resource,
|
| 9 |
mcp_tool,
|
| 10 |
)
|
| 11 |
-
from contrib.mcp_mixin.mcp_mixin import (
|
| 12 |
_DEFAULT_SEPARATOR_PROMPT,
|
| 13 |
_DEFAULT_SEPARATOR_RESOURCE,
|
| 14 |
_DEFAULT_SEPARATOR_TOOL,
|
| 15 |
)
|
| 16 |
-
from fastmcp import FastMCP
|
| 17 |
|
| 18 |
|
| 19 |
class TestMCPMixin:
|
|
|
|
| 2 |
|
| 3 |
import pytest
|
| 4 |
|
| 5 |
+
from fastmcp import FastMCP
|
| 6 |
+
from fastmcp.contrib.mcp_mixin import (
|
| 7 |
MCPMixin,
|
| 8 |
mcp_prompt,
|
| 9 |
mcp_resource,
|
| 10 |
mcp_tool,
|
| 11 |
)
|
| 12 |
+
from fastmcp.contrib.mcp_mixin.mcp_mixin import (
|
| 13 |
_DEFAULT_SEPARATOR_PROMPT,
|
| 14 |
_DEFAULT_SEPARATOR_RESOURCE,
|
| 15 |
_DEFAULT_SEPARATOR_TOOL,
|
| 16 |
)
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
class TestMCPMixin:
|