{"record":{"id":"40f28dbae8ac347d","repo":"BerriAI/litellm","slug":"missing-user-env-vars-40f28d","errorCode":"missing_user_env_vars","errorMessage":"Cannot connect to MCP server \"{label}\".\\n\\nYour administrator configured this server to require per-user variables, but you haven't set the following yet:\\n{bullet_list}\\n\\nSet your credentials here:\\n{setup_url}","messagePattern":"Cannot connect to MCP server \"(.+?)\"\\.\\\\n\\\\nYour administrator configured this server to require per-user variables, but you haven't set the following yet:\\\\n(.+?)\\\\n\\\\nSet your credentials here:\\\\n(.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":412,"severity":"error","filePath":"litellm/proxy/_experimental/mcp_server/rest_endpoints.py","lineNumber":1043,"sourceCode":"                raw_headers=data.get(\"raw_headers\"),\n                litellm_logging_obj=data.get(\"litellm_logging_obj\"),\n                requested_server_id=canonical_server_id,\n            )\n            return await _safe_fire_mcp_tool_call_logging(\n                logging_obj,\n                result,\n                _tool_start_time,\n                datetime.now(),\n                user_api_key_auth=user_api_key_dict,\n                request_data=data,\n            )\n        except MCPMissingUserEnvVarsError as e:\n            verbose_logger.info(\n                \"MCP tool call missing per-user env vars: server_id=%s missing=%s\",\n                e.server_id,\n                e.missing,\n            )\n            raise HTTPException(\n                status_code=412,\n                detail={\n                    \"error\": \"missing_user_env_vars\",\n                    \"message\": str(e),\n                    \"server_id\": e.server_id,\n                    \"server_name\": e.server_name,\n                    \"missing\": e.missing,\n                    \"setup_url\": e.setup_url,\n                },\n            )\n        except BlockedPiiEntityError as e:\n            verbose_logger.error(\"BlockedPiiEntityError in MCP tool call: %s\", e)\n            raise HTTPException(\n                status_code=400,\n                detail={\n                    \"error\": \"blocked_pii_entity\",\n                    \"message\": str(e),\n                    \"entity_type\": getattr(e, \"entity_type\", None),","sourceCodeStart":1025,"sourceCodeEnd":1061,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/_experimental/mcp_server/rest_endpoints.py#L1025-L1061","documentation":"An administrator can register an MCP server with per-user variables (an env-var template each user must fill with their own credentials). When the calling user has no values stored, the tool call raises MCPMissingUserEnvVarsError, which this handler converts to HTTP 412 with error code missing_user_env_vars. The response includes server_id, server_name, the list of missing variables, and a setup_url pointing at the page where the user sets them.","triggerScenarios":"Any MCP tool call (POST /mcp-rest/tools/call or the /mcp session endpoint) against a server whose configuration declares per-user env vars, made by a user who never filled them in.","commonSituations":"New team members calling a shared MCP server for the first time; an admin adds per-user variables to a previously open server and existing callers start failing; fresh environments where the user-env store is empty.","solutions":["Open the setup_url from the error response and set the listed variables for your user.","Submit values for every entry in detail.missing (typically the API key/token the upstream server needs), then retry the call.","If per-user credentials are not wanted, have the admin replace the per-user env-var template with a static server credential."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = await client.post(f\"{base}/mcp-rest/tools/call\", json=payload)\n    resp.raise_for_status()\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 412:\n        d = e.response.json().get(\"detail\", {})\n        if d.get(\"error\") == \"missing_user_env_vars\":\n            # route the user to the setup page, then allow a retry\n            send_user_notice(setup_url=d.get(\"setup_url\"), missing=d.get(\"missing\", []))\n            return\n    raise","preventionTips":["On each user's first call to a per-user-variable server, catch 412 and route them to setup_url before retrying.","Admins: document which per-user variables a server needs before granting users access."],"tags":["mcp","configuration","user-variables","http-412"],"backgroundTag":"per-user-env-var-missing","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}