litellm/litellm-proxy-extras
mateo-berri fc8ad45ba3 feat(mcp): per-user env-vars for MCP servers (backend + UI wiring)
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>
2026-05-23 19:11:41 -07:00
..
dist adding build 2026-03-21 22:55:04 -07:00
litellm_proxy_extras feat(mcp): per-user env-vars for MCP servers (backend + UI wiring) 2026-05-23 19:11:41 -07:00
tests [Fix] v2 resolver: swallow non-connection DB errors; wrap resolve failures 2026-04-21 15:53:07 -07:00
build_and_publish.md build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
LICENSE install prisma migration files - connects litellm proxy to litellm's prisma migration files (#9637) 2025-03-29 15:27:09 -07:00
migration_runbook.md [Infra] Add freshness and destructive guards to migration workflow 2026-04-21 12:00:23 -07:00
pyproject.toml chore(ci): bump versions (#28287) 2026-05-19 15:10:37 -07:00
README.md build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00

Additional files for the proxy. Reduces the size of the main litellm package.

Currently, only stores the migration.sql files for litellm-proxy.

To install, run:

uv add litellm-proxy-extras

OR

uv tool install 'litellm[proxy]' # installs litellm-proxy-extras and other proxy dependencies

To use the migrations, run:

litellm --use_prisma_migrate