Skip to content

fix(mcp): authenticate tool calls per HTTP request - #2134

Merged
hidb4ai merged 3 commits into
oceanbase:masterfrom
tmt-123:fix/mcp-request-identity-2082
Oct 21, 2026
Merged

hidb4ai merged 3 commits into
oceanbase:masterfrom
tmt-123:fix/mcp-request-identity-2082

Conversation

@tmt-123

@tmt-123 tmt-123 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Closes #2082.

Rationale for this change

Stateful MCP execution retains the initializing HTTP request's authentication context. Another authenticated caller can reuse the session and execute tools under the creator's identity. Actor and group membership also remain stale across requests.

What changes are included in this PR?

  • Use stateless Streamable HTTP so each tool execution inherits the current request's authenticated identity.
  • Add ASGI and real TCP regression tests for cross-user access, concurrent callers, identity updates, and invalid, missing, or revoked credentials.
  • Test denied writes, subsequent valid requests, client reconnects, and persistent Memory after a server restart.
  • Document transport behavior in English and Chinese.

Are there any user-facing changes?

MCP no longer issues transport session IDs. Clients should reconnect after upgrading. Scope, Memory, and Handoff data remain persisted. Cross-request SSE stream resumption is unavailable.

How was this change tested?

  • Linux, Python 3.12.13, FastMCP 3.4.4, MCP SDK 1.28.1.
  • All three regression cases fail against the original implementation.
  • 108 related tests passed, covering MCP, HTTP access control, authorization, tracing, metrics, and integration behavior.
  • Lock-file validation, Ruff, ty check, and pre-commit hooks passed.
  • Native Codex CLI 0.163.0-alpha.10.2 discovered 56 tools and completed scope creation and a Memory write/read round trip against the Linux server.
  • Claude Code 2.1.117 passed its native MCP connection health check. Model-driven tool use was not exercised.

AI usage statement

OpenAI Codex assisted with implementation, regression tests, and validation.

@CLAassistant

CLAassistant commented Oct 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One reproducible test-isolation issue remains in the TCP server lifecycle; details inline.

Comment thread tests/e2e/test_mcp_request_authentication.py Outdated
@tmt-123

tmt-123 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in 80928b9. Updated the test server to leave process signal handling to pytest and removed the manual AppStatus reset. Added regression coverage for delayed restarts and overlapping listeners.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@hidb4ai
hidb4ai merged commit 339e1d0 into oceanbase:master Oct 21, 2026
43 checks passed
@hidb4ai hidb4ai added the 1.4.1 v1.4.1 release tracking label Oct 21, 2026
@tmt-123
tmt-123 deleted the fix/mcp-request-identity-2082 branch October 22, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.4.1 v1.4.1 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[security] MCP 工具调用以会话创建者身份执行,越权使用他人会话(已复现)

3 participants