feat(agent-connect): mount MCP-over-HTTP at /mcp on the dashboard#16
Merged
Conversation
MCP-native agents (Claude Code, Cursor, ...) point one URL at the cloud instance (https://team.engraphis.com/mcp) with a per-user bearer token and reuse the same v2 store the dashboard reads — no local install. Team-gated (402) + member-authed (401), exactly like /api/remember. - mcp_server: set_service(svc) injects the dashboard's MemoryService so the MCP tools share ONE writer (no second SQLite connection -> no WAL lock contention). - dashboard_app: build the streamable-http ASGI app up front and give the app a lifespan that initializes the MCP session manager (a mounted sub-app's own lifespan does not run in Starlette -> 'Task group is not initialized'); mount at /mcp with the endpoint at '/' inside the sub-app so the prefix lines up. The mcp import + session-manager build are fully inside a try so the dashboard still starts if the mcp extra is absent (MCP mount is genuinely optional). Reset _session_manager per create_app() so multiple apps in one process (tests) each get a fresh, runnable instance (run() is once-per-instance). - _auth_gate: protect /mcp (Team license 402 + member token/cookie 401) before the existing /api/* logic; disable MCP's DNS-rebinding host allowlist on the mounted instance (default localhost-only would 421 a real domain like team.engraphis.com; the dashboard gate is the real auth boundary; standalone mcp_server_http is unaffected as its own process). - v2_team.connect-info: mcp_over_http + mcp_url now reflect whether /mcp is mounted. - docs/AGENT_CONNECT.md updated (/mcp now live + config snippet); CHANGELOG. - tests/test_agent_connect_mcp.py: 5 tests (401, 402, handshake+tools/list, write-shares-dashboard-store, connect-info reports /mcp). Suite green (one pre-existing flaky inspector test fails under load but passes in isolation, on main too).
Coding-Dev-Tools
left a comment
Owner
Author
There was a problem hiding this comment.
Pre-PR Code Review — BLOCK (failing CI)
Verdict: BLOCK — do not merge until CI is green.
The MCP-over-HTTP feature design is sound and security-conscious (Team-gated 402, per-user bearer auth, session→owner binding, role re-evaluation per request, DNS-rebinding guard preserved, shared single-writer MemoryService). Tests cover auth/role/host/session paths well.
However, CI is RED on this PR (Python 3.10/3.11/3.12 test + lint (full offline stack)), while main is fully green (7/7). Exactly one test fails, and it is introduced by this PR:
FAILED tests/test_agent_connect_mcp.py::test_mcp_requires_team_license_402
AssertionError: {detail:{error:Team
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.