Repository navigation
Conversation
…, PR1) Exposes a single agent as a per-agent MCP connector: an end user adds it to their AI client (Claude Code, Cursor, Claude Desktop) in one line, turning the agent's user_invocable playbooks into MCP tools. The agent holds credentials server-side; only a scoped, revocable key reaches the client. New client-sharing channel alongside Slack/Telegram/WhatsApp/VoIP/public link. OSS core (the #847 entitlement seam can wrap it later with a one-line diff). The per-user SSO/RFC-8693 tier is a separate enterprise epic, out of scope. Backend: - agent_connectors table (config: enabled + exposed-playbook allow-list) with dual-track migration (SQLite + Alembic 0006) + db/tables.py; cascade/rename via AGENT_REFS. - mcp_api_keys gains scope='connector': a separate, owner-bound, SHA-256-hashed, independently-revocable key with regenerate (revoke-old-mint-new) so a leaked snippet is cut off. Distinct from the auto-minted scope='agent' key. - routers/connectors.py: owner CRUD (status / config / mint-regenerate key / revoke) + a connector-key-readable /playbooks; services/connector_service.py (pure) builds per-client copy-paste snippets with the key embedded and resolves exposed = allow-list ∩ user_invocable (user_invocable:false never exposed). - Auth boundary: connector keys are consumption-only — _enforce_connector_scope fences them to their bound agent and refuses owner ops; _reject_connector_ principal blocks every role-gated endpoint. MCP server: - scope 'connector' added; connector.ts tools (list_playbooks/run_playbook/ask) gated by FastMCP canAccess so connector keys see ONLY these and operator keys never do; the agent comes from the bound key, never a tool arg; run_playbook re-checks exposure server-side before dispatch. Tests: test_connectors.py (config CRUD, key lifecycle incl. regenerate- invalidates-old, playbook resolution, snippet builder, auth boundary) — 21; connector.test.ts — 5; schema/alembic/cleanup parity green. Deferred (fast-follow): automation:gated approval routing, ChatGPT polish, Sharing-tab UI (PR2). Related to Abilityai/trinity-enterprise#46 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Author
|
Closing per re-scoping: this should be an enterprise feature, not OSS core. My earlier 'OSS core' framing was wrong — the issue is in the enterprise tracker and ent#45 requires paid-module schema/implementation to live in the private Re-splitting into two PRs:
Will link both here. |
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.
Summary
PR1 (backend + MCP) of the per-agent MCP connector (trinity-enterprise#46): expose a single agent as an MCP connector an end user adds to their AI client (Claude Code, Cursor, Claude Desktop) in one line, turning the agent's
user_invocableplaybooks (.claude/skills/) into MCP tools. The agent holds credentials server-side; only a scoped, revocable key reaches the client. A new client-sharing channel alongside Slack/Telegram/WhatsApp/VoIP/public links.Decisions (confirmed up front): OSS core (the #847 entitlement seam can wrap it behind
requires_entitlement('mcp_connector')later with a ~1-line diff); first PR is backend + key + MCP tools (Sharing-tab UI is PR2). The per-user SSO/RFC-8693 tier is a separate enterprise epic, out of scope.What's in this PR
Backend
agent_connectorstable (config:enabled+ exposed-playbook allow-list) — dual-track migration (SQLiteagent_connectors_table+ Alembic0006_agent_connectors) +db/tables.py; cascade/rename registered inAGENT_REFS.mcp_api_keys.scope='connector': a separate, owner-bound, SHA-256-hashed, independently-revocable key with regenerate (revoke-old → mint-new) so a leaked copy-paste snippet is cut off. Distinct from the auto-mintedscope='agent'key.routers/connectors.py: owner CRUD (GETstatus /PUTconfig /POSTkey /DELETEkey) + connector-key-readableGET /connector/playbooks.services/connector_service.py(pure) builds per-client copy-paste snippets with the key pre-embedded (Claude Codeclaude mcp add+.mcp.json, CursormcpServers, Claude Desktop) and resolves exposed = allow-list ∩user_invocable(auser_invocable:falseplaybook is never exposed). Raw key returned once._enforce_connector_scopefences it to its bound agent on read/chat and refuses owner ops (OwnedAgent*→ 403);_reject_connector_principalblocks every role-gated endpoint (require_role/require_admin). A leaked snippet can chat its one agent and nothing else.MCP server
scope='connector'added;connector.tstoolslist_playbooks/run_playbook/askgated by FastMCPcanAccessso connector keys see ONLY these and operator keys never do. The agent comes from the bound key, never a tool arg;run_playbookre-checks exposure server-side before dispatching via chat.Three-surface sync (Invariant #13): backend router + DB, MCP server tools; no agent-server change (reuses the existing
/api/skillsplaybook list + chat).Testing
tests/unit/test_connectors.py— 21 (config CRUD, key lifecycle incl. regenerate-invalidates-old, playbook resolution +user_invocableexclusion, snippet builder, auth boundary).src/mcp-server/src/connector.test.ts— 5 (tool shape, bound-agent enforcement, run_playbook exposure refusal); full MCP suite 36 pass,tscbuild clean.Deferred (fast-follow)
automation: gatedapproval routing — only the 5s file-based operator queue exists (no synchronous approval primitive); a gated playbook would need create-item-then-poll.Docs
architecture.md(subsystem block + MCP tool row + endpoints +agent_connectorsDDL +scope='connector') andrequirements.md§44.Related to Abilityai/trinity-enterprise#46
🤖 Generated with Claude Code