BerriAI/litellm · error · HTTPException

User does not have permission to access mcp server with id {

Error message

User does not have permission to access mcp server with id {server_id}. You can only manage mcp servers that you have access to.

What it means

Authorization guard in the per-user MCP state resolver: the server exists but is outside the caller's allowed-server set. Non-admins deliberately get 403 (not 404) so valid server ids cannot be enumerated; the same allowed-server resolution the gateway enforces on tool calls is applied here.

Source

Thrown at litellm/proxy/management_endpoints/mcp_management_endpoints.py:2303

        server = await get_mcp_server(prisma_client, server_id)
        if server is None:
            registry_server: Final = global_mcp_server_manager.get_mcp_server_by_id(server_id)
            if registry_server is not None:
                server = global_mcp_server_manager._build_mcp_server_table(registry_server)

        if _user_has_admin_view(user_api_key_dict):
            if server is None:
                raise HTTPException(
                    status_code=status.HTTP_404_NOT_FOUND,
                    detail={"error": f"MCP Server {server_id} not found"},
                )
            return server

        allowed_server_ids: Final[set[str]] = set()
        for auth_context in await build_effective_auth_contexts(user_api_key_dict):
            allowed_server_ids.update(await global_mcp_server_manager.get_allowed_mcp_servers(auth_context))
        if server is None or server.server_id not in allowed_server_ids:
            raise HTTPException(
                status_code=status.HTTP_403_FORBIDDEN,
                detail={
                    "error": (
                        f"User does not have permission to access mcp server with id {server_id}. "
                        "You can only manage mcp servers that you have access to."
                    )
                },
            )
        return server

    def _compute_user_env_var_status(
        *,
        server: LiteLLM_MCPServerTable,
        stored_values: dict[str, str],
    ) -> MCPUserEnvVarsStatus:
        """Build a status object for one server given the user's stored values.

        Stored credentials are write-only: the response reports only whether

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use an API key whose role is PROXY_ADMIN or that has been granted access to this MCP server.
  2. Ask an admin to add your key/team to the server's allowed access list.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/mcp_management_endpoints.py:2303 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/059f65a7c7289d64. Report an issue: GitHub.