Skip to content

Add stdio entrypoint so server can be launched directly#4

Open
danilobrando wants to merge 1 commit intoadelaidasofia:mainfrom
danilobrando:fix/stdio-entrypoint
Open

Add stdio entrypoint so server can be launched directly#4
danilobrando wants to merge 1 commit intoadelaidasofia:mainfrom
danilobrando:fix/stdio-entrypoint

Conversation

@danilobrando
Copy link
Copy Markdown

Summary

server.py defines the FastMCP instance and 29 tools, but has no __main__ block — running python3 server.py loads the module without starting the server. Claude Code (and any MCP client following the README) reports Failed to connect.

Repro

git clone https://github.com/adelaidasofia/substack-mcp
cd substack-mcp
pip3 install -r requirements.txt
# Register in .mcp.json:
#   "substack": { "command": "python3", "args": ["/path/to/server.py"] }
claude mcp list
# substack: ... - ✗ Failed to connect

Sending an MCP initialize JSON-RPC over stdio also returns no response — the process exits as soon as stdin closes because nothing is reading from it.

Fix

Add the standard FastMCP stdio entrypoint at the end of server.py:

if __name__ == "__main__":
    mcp.run(transport="stdio", show_banner=False)

show_banner=False keeps stdout clean for the MCP protocol (FastMCP prints to stderr by default, but the banner can leak into stdout in some setups).

Verified

After the patch:

$ claude mcp list
substack: ... - ✓ Connected

And test_connection returns the expected profile payload over the live MCP transport.

Without this, `python3 server.py` loads the module but never starts the
MCP server, and Claude Code reports `Failed to connect`.

Verified locally: after the patch, the server responds to MCP `initialize`
on stdio and shows up as connected in `claude mcp list`.
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

Successfully merging this pull request may close these issues.

1 participant