Spaces:
Running
Running
Commit ·
39a5900
1
Parent(s): 1e5ddc5
Refactor tests (remove duplicate). Add test coverage for simple_echo, complex_inputs, desktop, echo.
Browse files- README.md +4 -0
- examples/desktop.py +7 -0
- examples/readme-quickstart.py +0 -18
- pyproject.toml +3 -1
- tests/server/test_openapi.py +2 -0
- uv.lock +0 -0
README.md
CHANGED
|
@@ -762,6 +762,10 @@ Run the test suite:
|
|
| 762 |
```bash
|
| 763 |
uv run pytest -vv
|
| 764 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 765 |
|
| 766 |
#### Formatting & Linting
|
| 767 |
|
|
|
|
| 762 |
```bash
|
| 763 |
uv run pytest -vv
|
| 764 |
```
|
| 765 |
+
or if you want an overview of the code coverage
|
| 766 |
+
```bash
|
| 767 |
+
uv run pytest --cov=src --cov=examples --cov-report=html
|
| 768 |
+
```
|
| 769 |
|
| 770 |
#### Formatting & Linting
|
| 771 |
|
examples/desktop.py
CHANGED
|
@@ -19,6 +19,13 @@ def desktop() -> list[str]:
|
|
| 19 |
return [str(f) for f in desktop.iterdir()]
|
| 20 |
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@mcp.tool()
|
| 23 |
def add(a: int, b: int) -> int:
|
| 24 |
"""Add two numbers"""
|
|
|
|
| 19 |
return [str(f) for f in desktop.iterdir()]
|
| 20 |
|
| 21 |
|
| 22 |
+
# Add a dynamic greeting resource
|
| 23 |
+
@mcp.resource("greeting://{name}")
|
| 24 |
+
def get_greeting(name: str) -> str:
|
| 25 |
+
"""Get a personalized greeting"""
|
| 26 |
+
return f"Hello, {name}!"
|
| 27 |
+
|
| 28 |
+
|
| 29 |
@mcp.tool()
|
| 30 |
def add(a: int, b: int) -> int:
|
| 31 |
"""Add two numbers"""
|
examples/readme-quickstart.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
from fastmcp import FastMCP
|
| 2 |
-
|
| 3 |
-
# Create an MCP server
|
| 4 |
-
mcp = FastMCP("Demo")
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
# Add an addition tool
|
| 8 |
-
@mcp.tool()
|
| 9 |
-
def add(a: int, b: int) -> int:
|
| 10 |
-
"""Add two numbers"""
|
| 11 |
-
return a + b
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# Add a dynamic greeting resource
|
| 15 |
-
@mcp.resource("greeting://{name}")
|
| 16 |
-
def get_greeting(name: str) -> str:
|
| 17 |
-
"""Get a personalized greeting"""
|
| 18 |
-
return f"Hello, {name}!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyproject.toml
CHANGED
|
@@ -7,7 +7,7 @@ dependencies = [
|
|
| 7 |
"python-dotenv>=1.1.0",
|
| 8 |
"exceptiongroup>=1.2.2",
|
| 9 |
"httpx>=0.28.1",
|
| 10 |
-
"mcp>=1.
|
| 11 |
"openapi-pydantic>=0.5.1",
|
| 12 |
"rich>=13.9.4",
|
| 13 |
"typer>=0.15.2",
|
|
@@ -47,7 +47,9 @@ dev = [
|
|
| 47 |
"pyright>=1.1.389",
|
| 48 |
"pytest>=8.3.3",
|
| 49 |
"pytest-asyncio>=0.23.5",
|
|
|
|
| 50 |
"pytest-flakefinder",
|
|
|
|
| 51 |
"pytest-xdist>=3.6.1",
|
| 52 |
"ruff",
|
| 53 |
]
|
|
|
|
| 7 |
"python-dotenv>=1.1.0",
|
| 8 |
"exceptiongroup>=1.2.2",
|
| 9 |
"httpx>=0.28.1",
|
| 10 |
+
"mcp>=1.7.1,<2.0.0",
|
| 11 |
"openapi-pydantic>=0.5.1",
|
| 12 |
"rich>=13.9.4",
|
| 13 |
"typer>=0.15.2",
|
|
|
|
| 47 |
"pyright>=1.1.389",
|
| 48 |
"pytest>=8.3.3",
|
| 49 |
"pytest-asyncio>=0.23.5",
|
| 50 |
+
"pytest-cov>=6.1.1",
|
| 51 |
"pytest-flakefinder",
|
| 52 |
+
"pytest-report>=0.2.1",
|
| 53 |
"pytest-xdist>=3.6.1",
|
| 54 |
"ruff",
|
| 55 |
]
|
tests/server/test_openapi.py
CHANGED
|
@@ -194,6 +194,7 @@ class TestTools:
|
|
| 194 |
assert len(tools) == 2
|
| 195 |
|
| 196 |
assert tools[0].model_dump() == dict(
|
|
|
|
| 197 |
name="create_user_users_post",
|
| 198 |
description=IsStr(regex=r"^Create a new user\..*$", regex_flags=re.DOTALL),
|
| 199 |
inputSchema={
|
|
@@ -206,6 +207,7 @@ class TestTools:
|
|
| 206 |
},
|
| 207 |
)
|
| 208 |
assert tools[1].model_dump() == dict(
|
|
|
|
| 209 |
name="update_user_name_users__user_id__name_patch",
|
| 210 |
description=IsStr(
|
| 211 |
regex=r"^Update a user's name\..*$", regex_flags=re.DOTALL
|
|
|
|
| 194 |
assert len(tools) == 2
|
| 195 |
|
| 196 |
assert tools[0].model_dump() == dict(
|
| 197 |
+
annotations=None,
|
| 198 |
name="create_user_users_post",
|
| 199 |
description=IsStr(regex=r"^Create a new user\..*$", regex_flags=re.DOTALL),
|
| 200 |
inputSchema={
|
|
|
|
| 207 |
},
|
| 208 |
)
|
| 209 |
assert tools[1].model_dump() == dict(
|
| 210 |
+
annotations=None,
|
| 211 |
name="update_user_name_users__user_id__name_patch",
|
| 212 |
description=IsStr(
|
| 213 |
regex=r"^Update a user's name\..*$", regex_flags=re.DOTALL
|
uv.lock
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|