BerriAI/litellm · error · HTTPException
User does not have permission to create temporary mcp server
Error message
User does not have permission to create temporary mcp servers. You can only create temporary mcp servers if you are a PROXY_ADMIN.
What it means
Returned (403) by the temporary/session MCP server endpoint (used for the short-lived, Redis-cached servers of the admin OAuth setup flow). Like the persistent create endpoint it validates the payload first, then requires user_role to be exactly LitellmUserRoles.PROXY_ADMIN; non-admin keys cannot register temporary servers.
Source
Thrown at litellm/proxy/management_endpoints/mcp_management_endpoints.py:1635
litellm_changed_by: str | None = Header(
None,
description="The litellm-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability",
),
):
"""
Cache MCP server info in memory for a short duration (~5 minutes).
This endpoint does not write to the database. If the same server_id is provided
again while the cache entry is active, it will refresh the cached data + TTL.
"""
# Validate and normalize payload fields (alias/server name rules)
validate_and_normalize_mcp_server_payload(payload)
stamp_omitted_oauth2_flow(payload)
# Restrict to proxy admins similar to the persistent create endpoint
if LitellmUserRoles.PROXY_ADMIN != user_api_key_dict.user_role:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail={
"error": "User does not have permission to create temporary mcp servers. You can only create temporary mcp servers if you are a PROXY_ADMIN."
},
)
created_by: Final = user_api_key_dict.user_id or LITELLM_PROXY_ADMIN_NAME
payload_with_credentials: Final = _inherit_credentials_from_existing_server(payload)
temp_record: Final = _build_temporary_mcp_server_record(
payload_with_credentials,
created_by,
await _resolve_session_server_id(payload_with_credentials),
)
try:
temporary_server: Final = await global_mcp_server_manager.build_mcp_server_from_table(
temp_record,
credentials_are_encrypted=False,View on GitHub (pinned to 77b7c6c40c)
Solutions
- Run the temporary-server/session flow with the proxy master key or a PROXY_ADMIN user's key.
- Verify the key's user_role via /key/info before starting the flow.
- For user-facing OAuth flows, use the user-side endpoints with a real server_id instead of creating temp servers.
Example fix
# before
requests.post(f"{PROXY}/v1/mcp/server/oauth/session", headers={"Authorization": f"Bearer {USER_KEY}"}, json=payload)
# after
requests.post(f"{PROXY}/v1/mcp/server/oauth/session", headers={"Authorization": f"Bearer {os.environ['LITELLM_MASTER_KEY']}"}, json=payload) Defensive patterns
Strategy: validation
Validate before calling
info = requests.get(f"{PROXY}/key/info", headers=AUTH, params={"key": KEY}).json()
if info.get("key_info", info).get("user_role") != "proxy_admin":
raise PermissionError("temporary MCP servers require a PROXY_ADMIN key") Type guard
def can_create_temp_server(user_role: str | None) -> bool:
return user_role == "proxy_admin" Try / catch
try:
create_temp_server(payload)
except HTTPError as e:
if e.response.status_code == 403:
raise PermissionError("re-run the OAuth session flow with the master/admin key")
raise Prevention
- Reserve the OAuth session/temp-server flow for admin keys.
- Document which automation may use admin keys for MCP setup.
When it happens
Trigger: Calling the temporary MCP server / OAuth session endpoint with an internal-user, team, or org-admin key; automating the admin OAuth connect flow with a non-admin virtual key.
Common situations: Trying to script the MCP OAuth setup with the wrong key; team members attempting to register their own OAuth-connected MCP servers during a session.
Related errors
- Access denied to MCP server {server_id}
- User does not have permission to view mcp server with id {se
- User does not have permission to create mcp servers. You can
- Call not allowed to delete MCP server. User is not a proxy a
- Error caching temporary mcp server: {e}
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/3bc7e67d55188201.
Report an issue: GitHub.