Repository navigation
Require a caller on the agent and Google Drive MCP servers; add GET /mcp - #231
Merged
Merged
Conversation
The agent MCP servers (/agents/<name>/mcp) and the Google Drive MCP server (/gdrive/mcp) answered every route without credentials: anyone who reached port 8000 could run exposed agents on the server's provider keys, or list and read Drive files through the server's service account. Every route but health and CORS preflight now takes the same callers as the OpenAI-compatible API (get_pat_user: personal access token, Basic auth, login token or session, with a role in ALLOWED_API_ROLES). An agent's routes also check the agent's allowed_for_roles, since the tool call reaches the agent over A2A without the caller's identity. GET /mcp lists the exposed agents the caller may use, with their MCP URLs. The agent servers' initialize response now carries the agent's description in serverInfo, which MCP registries such as the LobeHub market read.
This was referenced Oct 14, 2026
Closed
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.
Problem
Two MCP servers answered every route without credentials:
/agents/<name>/mcp: anyone who reached port 8000 could run any agent inMCP_EXPOSED_AGENTS, spending the server's LLM keys. Per-user budgets didn't apply, and neither did the agent'sallowed_for_roles, because the tool call reaches the agent over A2A without the caller's identity./gdrive/mcp: anyone could list, search and read Google Drive files, and see their sharing permissions, through the server's service account./images/mcpalready required a signed-in caller.docs/dev/mcp-servers.mdclaimed every MCP endpoint did.Change
shared/utils/mcp/mcp_auth.py:require_mcp_userreusesget_pat_user, the gate the OpenAI-compatible API uses. It accepts a personal access token, Basic auth, the login token or a dashboard session, from an admin or a role inALLOWED_API_ROLES.agent_allowedreads the agent'sallowed_for_rolesand asksRBACMiddleware.check_agent_access. An agent with no roles is admin-only.healthandOPTIONS, require a caller (401) who may use that agent (403).healthandOPTIONS, require a caller.GET /mcplists the exposed agents the caller may use, with name, description and MCP URL.initializeresponse now includesserverInfo.titleandserverInfo.description, plusinstructions. Without themlhm plugin init(LobeHub market) fails with "Could not infer a plugin description".Breaking
Clients that call these servers without credentials will now get 401. They need to send
Authorization: Bearer mate_pat_...(or Basic auth). This includes other MATE instances that consume these agents throughmcp_servers_config.${VAR}interpolation inheaderskeeps the token out of the config row. There is deliberately no switch to restore the old behaviour.Not changed
/images/mcpkeeps its dashboard-user check and still doesn't accept personal access tokens. The docs now say so.healthstill shows the agent's name and description publicly.Tests
shared/test/test_mcp_auth.py:healthand preflight stay public/mcplists only allowed agentsagent_allowedrole parsingDocs
docs/dev/mcp-servers.md: new "Who may call" section,/mcp, auth line corrected, personal access tokens for clients.docs/dev/openai-api-and-mcp.md: same, briefly.docs/reference/api.mdregenerated.gen_docs.py --checkanddrift --base origin/mainare clean.