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
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
"""
|
|
FastMCP Testing Demo Server
|
|
|
|
A simple MCP server demonstrating tools, resources, and prompts
|
|
with comprehensive test coverage.
|
|
"""
|
|
|
|
from fastmcp import FastMCP
|
|
|
|
# Create server
|
|
mcp = FastMCP("Testing Demo")
|
|
|
|
|
|
# Tools
|
|
@mcp.tool
|
|
def add(a: int, b: int) -> int:
|
|
"""Add two numbers together"""
|
|
return a + b
|
|
|
|
|
|
@mcp.tool
|
|
def greet(name: str, greeting: str = "Hello") -> str:
|
|
"""Greet someone with a customizable greeting"""
|
|
return f"{greeting}, {name}!"
|
|
|
|
|
|
@mcp.tool
|
|
async def async_multiply(x: float, y: float) -> float:
|
|
"""Multiply two numbers (async example)"""
|
|
return x * y
|
|
|
|
|
|
# Resources
|
|
@mcp.resource("demo://info")
|
|
def server_info() -> str:
|
|
"""Get server information"""
|
|
return "This is the FastMCP Testing Demo server"
|
|
|
|
|
|
@mcp.resource("demo://greeting/{name}")
|
|
def greeting_resource(name: str) -> str:
|
|
"""Get a personalized greeting resource"""
|
|
return f"Welcome to FastMCP, {name}!"
|
|
|
|
|
|
# Prompts
|
|
@mcp.prompt("hello")
|
|
def hello_prompt(name: str = "World") -> str:
|
|
"""Generate a hello world prompt"""
|
|
return f"Say hello to {name} in a friendly way."
|
|
|
|
|
|
@mcp.prompt("explain")
|
|
def explain_prompt(topic: str, detail_level: str = "medium") -> str:
|
|
"""Generate a prompt to explain a topic"""
|
|
if detail_level == "simple":
|
|
return f"Explain {topic} in simple terms for beginners."
|
|
elif detail_level == "detailed":
|
|
return f"Provide a detailed, technical explanation of {topic}."
|
|
else:
|
|
return f"Explain {topic} with moderate technical detail."
|