Skip to content

fix(mcp): support standalone stdio MCP mode in container entrypoint - #148

Merged
hapheus merged 3 commits into
mainfrom
fix/mcp-standalone-container
Nov 13, 2026
Merged

hapheus merged 3 commits into
mainfrom
fix/mcp-standalone-container

Conversation

@hapheus

@hapheus hapheus commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Detect mcp or torproxy mcp arguments in docker/start.sh to run in standalone stdio MCP mode.
  • Redirect all setup, Tor, and Privoxy stdout to stderr (exec 3>&1 1>&2) while keeping FD 3 clean for JSON-RPC on torproxy mcp stdout.
  • Remove --entrypoint torproxy from .mcp.json, smithery.yaml, and docs/mcp.md so Tor and Privoxy start automatically alongside the stdio MCP server.
  • Update contract tests in tests/unit/test_contracts.py.

Closes #147

Verification

  • uv run pytest tests/unit/ -v --cov=torproxy --cov-fail-under=85: 400 passed (87.24% coverage)
  • bash -n docker/*.sh tests/integration/*.sh && shellcheck docker/*.sh tests/integration/*.sh: passed
  • uv run ruff check . && uv run ruff format --check . && uv run mypy: passed
  • Local Docker build (docker build -f docker/Dockerfile -t torproxy:mcp-test .) + end-to-end stdio smoke test (initialize, tools/list, torproxy_status): exited 0 with pure JSON-RPC on stdout and Tor connecting.

@MustermenschAlex MustermenschAlex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, minimal fix! Preserving the JSON-RPC stdout stream on FD 3 while routing setup and daemon logs to stderr in docker/start.sh is very neat, and keeping both .mcp.json, smithery.yaml, docs/mcp.md, and tests/unit/test_contracts.py in sync keeps our contract tests solid. ❤️

@kuenstlichedummheit-sys kuenstlichedummheit-sys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on the FD 3 trick and closing 3>&- before exec torproxy mcp so no extra descriptor leaks into the child process. Also good that su torproxy isn't exec'd directly in start.sh, so the EXIT trap still fires and cleans up Tor/Privoxy on stdin EOF. LGTM!

majorungustl
majorungustl previously approved these changes Nov 13, 2026

@majorungustl majorungustl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, dropping the --entrypoint hack makes way more sense. Having docker run -i --rm hapheus/torproxy:latest mcp actually spin up Tor and Privoxy under the hood without barfing logs onto stdout is how it should've worked out of the box. Super minimal diff too, ship it!

@MustermenschAlex MustermenschAlex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version bump to 2.7.7 is properly synchronized across pyproject.toml, uv.lock, docker/Dockerfile, server.json, docs/releases.md, and CHANGELOG.md (including the comparison link). All contracts still hold cleanly. ❤️

@kuenstlichedummheit-sys kuenstlichedummheit-sys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelog comparison link and server.json OCI tag 2.7.7 look solid. No regressions on the FD 3 / start.sh path—re-approved!

@majorungustl majorungustl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelog link is in, all 11 CI checks are green, and the 2.7.7 bump is ready to go. Ship it!

@hapheus
hapheus merged commit d1eb514 into main Nov 13, 2026
12 checks passed
@hapheus
hapheus deleted the fix/mcp-standalone-container branch November 13, 2026 07:57
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.

fix(mcp): support standalone stdio MCP mode in container entrypoint

4 participants