server.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Run the example
Save the code above as
server.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Start an example MCP server that uses the SSE transport.
"""Start an example MCP server that uses the SSE transport."""
from mcp.server.fastmcp import FastMCP
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
mcp = FastMCP("calendar_assistant")
@mcp.tool()
def get_events(day: str) -> str:
return f"There are no events scheduled for {day}."
@mcp.tool()
def get_birthdays_this_week() -> str:
return "It is your mom's birthday tomorrow"
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
mcp.run(transport="sse")
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U mcp
Run the example
server.py, then run:python server.py
Was this page helpful?