Replies: 1 comment
|
Too early to design MCP attribution / stratification / hooking. Leaving the discussion open to gather suggestions on MCP server management and attribution (to users, but also to agents) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What I'd like to achieve
I want MCP server configuration to work at two levels:
MCPServerManager.)admin,developer,guest, etc.) get additional MCP servers or can override/deny servers from the server-level config. For example: admins get access to internal MCP servers, guests only see the public ones.The goal is to make this configurable through the existing
/settingsCRUD, with no code changes per deployment.How I'd approach it
A dedicated plugin (
mcp_manager) that owns all MCP configuration policy. Core stays a dumb consumer.The key idea: core's
MCPClientsshould not know where server configs come from — DB, roles, env vars, a registry. It shouI'd do this via a hook:The plugin implements the hook and owns the resolution logic:
Two services, both
SingletonServicesubclasses with a nestedSettingsmodel:ServerMcpSettings(slug="server") — installation-wide defaults. Admin configures via/settings. Env-var seedCCAT_MCP_SERVERS) on first boot. Essentially the currentMCPServerManagerlogic, relocated.RoleMcpSettings(slug="role") — maps each role to additional servers and a deny-list. Merge precedence: deny > role override > server default.Since both subclass
SingletonServicewith aSettingsmodel, the existing/settingsCRUD auto-discovers them — no new route code for the config UI.Side benefit: the public MCP registry route (currently orphaned at
cat/routes/mcp/registry.py, not mounted anywhere) moves into the plugin as an@endpoint.Why a hook instead of core calling the service directly
[]and MCP is cleanly disabled.Core changes (minimal)
MCPClients.need_new_client()to call the hook instead of hardcodingawait agent.ccat.get("mcp_servers", "system").MCPServerManagerout of core into the plugin.@endpoint.MCPServer(pydantic model) stays incat/protocols/model_context/server.pyas a shared type.Open questions
Hook async support — can
mcp_servers_for_userbeasync def? The settings services do async DB reads. If async hooks are supported, the plugin code is much cleaner. If not, I can work around it.Hook return type —
list[MCPServer](I build the fastmcp config dict in core) or the raw{"mcpServers": {...}}dict (whatMCPClient.__init__expects today)? I'd preferlist[MCPServer]so the model is the single source of truth.Role access in hooks — is
cat.user.rolethe right way to get the current user's role inside a hook? Any example or best practice that I should follow?Scope — I'd ship Tier 1 (server-level) + Tier 2 (role-level) first and leave user-level enable/disable (the existing
TODOV2inneed_new_client) for later. Agree, or do you want all three at once?Conclusion
Is the described plan sound? Should I consider a different approach? Do you know if there's already someone working on this? Any thoughts?
If there are no blockers, I'd start scaffolding the
mcp_managerplugin.All reactions