Skip to content

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

Open
@grahama1970

Description

@grahama1970

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions