Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for clarification: Direct Execution (stdio transport) implementation #227

Open
grahama1970 opened this issue Feb 21, 2025 · 0 comments

Comments

@grahama1970
Copy link

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

  1. Web UI Implementation (Working):
mcp dev quickstart.py

This works perfectly - tools register and execute as expected.

  1. 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

  1. Is there additional setup needed for direct execution?
  2. Are there working examples of stdio transport implementation?
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant