prefecthq--fastmcp
60e0ffc959
Upgrade checks / Notify on failure (push) Has been cancelled
Upgrade checks / Close issue on success (push) Has been cancelled
Schema Crash Test / Real-world schema crash test (232K schemas) (push) Has been cancelled
Run static analysis / static_analysis (push) Has been cancelled
Tests / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Tests / Tests with lowest-direct dependencies (push) Has been cancelled
Tests / MCP conformance tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled
Tests / Package install smoke (push) Has been cancelled
Upgrade checks / Static analysis (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Upgrade checks / Integration tests (push) Has been cancelled
Update MCPServerConfig Schema / update-config-schema (push) Has been cancelled
Update SDK Documentation / update-sdk-docs (push) Has been cancelled
40 行
863 B
Python
40 行
863 B
Python
"""Example FastMCP server for demonstrating fastmcp.json configuration."""
|
|
|
|
from fastmcp import FastMCP
|
|
|
|
# Create the FastMCP server instance
|
|
mcp = FastMCP("Config Example Server")
|
|
|
|
|
|
@mcp.tool
|
|
def echo(text: str) -> str:
|
|
"""Echo the provided text back to the user."""
|
|
return f"You said: {text}"
|
|
|
|
|
|
@mcp.tool
|
|
def add(a: int, b: int) -> int:
|
|
"""Add two numbers together."""
|
|
return a + b
|
|
|
|
|
|
@mcp.resource("config://example")
|
|
def get_example_config() -> str:
|
|
"""Return an example configuration."""
|
|
return """
|
|
This server is configured using fastmcp.json.
|
|
|
|
The configuration file specifies:
|
|
- Python version
|
|
- Dependencies
|
|
- Transport settings
|
|
- Other runtime options
|
|
"""
|
|
|
|
|
|
# This allows the server to run with: fastmcp run server.py
|
|
if __name__ == "__main__":
|
|
import asyncio
|
|
|
|
asyncio.run(mcp.run_async())
|