Open
Description
Overview
While exploring the MCP Python SDK, I noticed some differences between the documented direct execution approach and actual behavior. Looking for guidance or clarification.
Current Understanding
The documentation describes direct execution without npm:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("My App")
if __name__ == "__main__":
mcp.run()
Testing Results
- Web UI Implementation (Working):
mcp dev quickstart.py
This works perfectly - tools register and execute as expected.
- Direct Execution Attempts:
# demo_server.py
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Demo")
@mcp.tool()
def add(a: int, b: int) -> int:
return a + b
if __name__ == "__main__":
mcp.run(transport="stdio")
Tried running with:
python demo_server.py
# and
(sleep 3; echo '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "add", "args": {"a": 2, "b": 3}}, "id": 1}'; cat) | python demo_server.py
Questions
- Is there additional setup needed for direct execution?
- Are there working examples of stdio transport implementation?
- Should the documentation be updated to clarify requirements?
Environment
- Python 3.11.6
- Latest MCP SDK
- macOS
Happy to provide more details or test cases if needed.
Metadata
Metadata
Assignees
Labels
No labels