Skip to content

Force single worker when MCP is mounted - #1076

Closed
wayyoungboy wants to merge 1 commit into
oceanbase:mainfrom
wayyoungboy:codex/issue-1056-mcp-single-worker-guard
Closed

Force single worker when MCP is mounted#1076
wayyoungboy wants to merge 1 commit into
oceanbase:mainfrom
wayyoungboy:codex/issue-1056-mcp-single-worker-guard

Conversation

@wayyoungboy

@wayyoungboy wayyoungboy commented Jun 22, 2026

Copy link
Copy Markdown
Member

Refs #1056

Note: this PR implements the short-term single-worker guard from #1056. The longer-term stateless MCP session handling needed for true multi-worker support remains tracked there.

Summary:

  • Detect when the server CLI can mount the streamable HTTP MCP app.
  • Reuse the existing single-worker guard so MCP sessions are not split across multiple worker processes.
  • Keep multi-worker startup unchanged when no process-local runtime mode is active, and avoid running the guard checks in reload mode.

Validation:

  • Using the project virtual environment, ran python -m pytest tests/unit/server/test_server_cli.py tests/unit/server/test_main_mcp_optional.py -q (31 passed, 1 warning from an existing dependency deprecation).
  • Using the project virtual environment, ran python -m py_compile src/server/cli/server.py tests/unit/server/test_server_cli.py.
  • Ran git diff --check.
  • E2E: with MCP dependencies installed and non-embedded storage configuration, started powermem-server --host <loopback host> --port <local test port> --workers 2 --no-open-browser; startup printed the MCP single-worker guard and forced workers=1 before server initialization. The process was stopped after the guard was observed.

@wayyoungboy
wayyoungboy marked this pull request as ready for review June 26, 2026 03:55
@lightzt99

lightzt99 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Prefer longer-term stateless MCP mentioned in #1056 after discuss.

@lightzt99 lightzt99 closed this Jun 26, 2026
@wayyoungboy

Copy link
Copy Markdown
Member Author

Self-review status for the current head: I reviewed the single-worker guard for MCP-mounted server runs. The change matches the current mount condition: when fastmcp is available, the server can mount the MCP ASGI app, so forcing workers=1 avoids running that mounted MCP app in multiple worker processes. Reload mode remains untouched, and the current checks are green.

I did not find a blocking issue in this static review. I am not marking this LGTM because this PR is authored from the wayyoungboy branch and still needs independent maintainer review/acceptance.

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.

2 participants