Adds end-to-end support for per-server env-var definitions and per-user
values that interpolate `${VAR}` placeholders in `static_headers` at
tool-call time.
Schema:
- New `env_vars` JSONB column on `LiteLLM_MCPServerTable` (list of
`{name, scope: "instance"|"per_user", value}`); per-user values reuse
`LiteLLM_MCPUserCredentials` with payload `type="vars"`.
Backend:
- `litellm/proxy/_experimental/mcp_server/env_vars.py` — parse / resolve
/ interpolate helpers + `MissingEnvVarsError`.
- `MCPServerManager._resolve_env_vars_for_server` substitutes
placeholders before merging extra headers. Missing required per-user
vars surface as `CallToolResult(isError=True)` with a dashboard
deep-link, so MCP clients (Claude Code, etc.) print the message to
the user.
- `GET`/`POST /v1/mcp/server/{server_id}/my-env-vars` for the fill
modal and status pill. Only `per_user` definitions are returned;
instance values stay admin-only. Stale names (after a rename or scope
flip) are trimmed on both read and write paths.
UI:
- Fill modal + status pill now hit the real endpoints (mocks remain as
fallback for demo mode).
- `MCPServer` type gains `env_vars`; networking helpers
`getMyMcpEnvVars` / `storeMyMcpEnvVars` added.
Tests:
- New `tests/test_litellm/proxy/_experimental/mcp_server/test_env_vars.py`
covers parse / collect / resolve / interpolate / missing_required and
user-var storage round-trip.
- Manager tests extended to exercise placeholder interpolation and the
missing-vars deep-link error path.
Co-authored-by: Cursor <cursoragent@cursor.com>