litellm/terraform/provider/docs/resources/mcp_server.md
Yassin Kortam ce2582e9d0
feat(terraform): vendor terraform-provider-litellm as source of truth with endpoint drift CI (#32241)
* feat(terraform): vendor terraform-provider-litellm as source of truth with endpoint drift CI

* fix(terraform): address review feedback on vendored provider

Replace deprecated io/ioutil with io. Remove the unused org/team CRUD
client methods so the endpoint audit only tracks live call sites
(54 -> 46). Redact request/response logs by parsing the JSON and
recursively masking sensitive fields, which fixes the nested-object
leak in the old credential_values regex, with a regex fallback for
non-JSON payloads; covered by new unit tests. Docs: stop showing
api_key inside vector store litellm_params and document that Sensitive
attributes still persist in plaintext state, recommending
litellm_credential_name and an encrypted state backend.

* fix(terraform): stop persisting server-returned litellm_params into vector store state

The vector store Read wrote litellm_params straight back from the API
response into state. The proxy redacts secrets in those responses, so
the readback overwrote user config with redaction sentinels and caused
perpetual diffs, and against a server that returns raw values it would
persist secrets into a non-Sensitive attribute. Read now preserves the
config value like the credential and model resources do, litellm_params
is marked Sensitive, and a regression test pins that a server-returned
api_key never lands in state

* fix(terraform): send role on team member update and stop persisting server env into MCP state

The team member update payload omitted role, and the proxy leaves role
unchanged when the field is absent, so a role downgrade reported as
applied by Terraform never took effect on the proxy. The update now
always sends the configured role (the attribute is Required).

The MCP server resource wrote env straight back from API responses
into a non-Sensitive attribute, pulling admin-visible secrets into
state and, for sanitized responses, blanking user config. Read now
preserves the config value, env is marked Sensitive, and the docs warn
against passing secrets via args. Regression tests cover both fixes
and fail against the previous behavior.
2026-07-07 09:16:59 -07:00

6.7 KiB

page_title subcategory description
litellm_mcp_server Resource - terraform-provider-litellm Manages an MCP (Model Context Protocol) server in LiteLLM.

litellm_mcp_server (Resource)

Manages an MCP (Model Context Protocol) server in LiteLLM. MCP servers provide tools and resources that can be used by LLMs through the LiteLLM proxy.

Example Usage

Basic HTTP MCP Server

resource "litellm_mcp_server" "github_server" {
  server_name = "github-mcp-server"
  alias       = "github"
  description = "GitHub MCP server for repository operations"
  url         = "https://api.github.com/mcp"
  transport   = "http"
  auth_type   = "bearer"
  
  mcp_access_groups = ["dev_team", "devops_team"]
}

SSE MCP Server with Comprehensive Cost Tracking

resource "litellm_mcp_server" "zapier_server" {
  server_name  = "zapier-automation"
  alias        = "zapier"
  description  = "Zapier MCP server for workflow automation"
  url          = "https://actions.zapier.com/mcp/sk-xxxxx/sse"
  transport    = "sse"
  auth_type    = "bearer"
  spec_version = "2024-11-05"
  
  mcp_access_groups = ["automation_team", "marketing_team"]
  
  mcp_info {
    server_name = "Zapier Integration Server"
    description = "Provides automation tools through Zapier's MCP interface"
    logo_url    = "https://zapier.com/assets/images/zapier-logo.png"
    
    mcp_server_cost_info {
      default_cost_per_query = 0.01
      
      tool_name_to_cost_per_query = {
        "send_email"           = 0.05
        "create_document"      = 0.03
        "update_spreadsheet"   = 0.02
        "post_to_slack"        = 0.01
        "create_calendar_event" = 0.04
      }
    }
  }
}

Stdio MCP Server for Local Development

resource "litellm_mcp_server" "local_dev_server" {
  server_name = "local-development-tools"
  alias       = "local-dev"
  description = "Local MCP server for development tools"
  url         = "stdio://local-dev"
  transport   = "stdio"
  auth_type   = "none"
  
  command = "python3"
  args    = ["/opt/mcp-servers/dev-tools/server.py", "--verbose"]
  
  env = {
    "PYTHONPATH"    = "/opt/mcp-servers/dev-tools"
    "DEBUG"         = "true"
    "LOG_LEVEL"     = "info"
    "WORKSPACE_DIR" = "/workspace"
  }
  
  mcp_access_groups = ["local_developers"]
  
  mcp_info {
    server_name = "Development Tools"
    description = "Local development utilities and tools"
    
    mcp_server_cost_info {
      default_cost_per_query = 0.0  # Free for local development
    }
  }
}

Enterprise MCP Server with Full Configuration

resource "litellm_mcp_server" "enterprise_api_server" {
  server_name  = "enterprise-api-gateway"
  alias        = "enterprise"
  description  = "Enterprise API gateway MCP server"
  url          = "https://api.enterprise.com/mcp/v1"
  transport    = "http"
  auth_type    = "bearer"
  spec_version = "2024-11-05"
  
  mcp_access_groups = [
    "enterprise_users",
    "api_consumers",
    "integration_team"
  ]
  
  mcp_info {
    server_name = "Enterprise API Gateway"
    description = "Provides access to enterprise APIs and services"
    logo_url    = "https://enterprise.com/logo.png"
    
    mcp_server_cost_info {
      default_cost_per_query = 0.10
      
      tool_name_to_cost_per_query = {
        "query_database"       = 0.25
        "generate_report"      = 0.50
        "send_notification"    = 0.05
        "create_user"          = 0.15
        "update_permissions"   = 0.20
        "audit_log_query"      = 0.30
      }
    }
  }
}

Argument Reference

The following arguments are supported:

Required Arguments

  • server_name - (Required) Name of the MCP server.
  • url - (Required) URL of the MCP server. For stdio transport, use stdio:// prefix.
  • transport - (Required) Transport type for the MCP server. Valid values: http, sse, stdio.

Optional Arguments

  • alias - (Optional) Alias for the MCP server. Used for easier reference.
  • description - (Optional) Description of the MCP server.
  • spec_version - (Optional) MCP specification version. Defaults to 2024-11-05.
  • auth_type - (Optional) Authentication type. Valid values: none, bearer, basic. Defaults to none.
  • mcp_access_groups - (Optional) List of access groups that can use this MCP server.
  • command - (Optional) Command to run for stdio transport.
  • args - (Optional) List of arguments for the command (stdio transport only). Do not pass secrets as arguments; args are shown in plans, stored unencrypted in state, and visible in the server's process list.
  • env - (Optional, Sensitive) Map of environment variables for the command (stdio transport only). Hidden from plan output but still stored unencrypted in state; secure your state backend when configuring tokens here.

MCP Info Block

The mcp_info block supports:

  • server_name - (Optional) Server name in MCP info.
  • description - (Optional) Description in MCP info.
  • logo_url - (Optional) Logo URL for the MCP server.

MCP Server Cost Info Block

The mcp_server_cost_info block within mcp_info supports:

  • default_cost_per_query - (Optional) Default cost per query for all tools.
  • tool_name_to_cost_per_query - (Optional) Map of specific tool names to their cost per query.

Attribute Reference

In addition to all arguments above, the following attributes are exported:

  • server_id - Unique identifier for the MCP server.
  • created_at - Timestamp when the server was created.
  • created_by - User who created the server.
  • updated_at - Timestamp when the server was last updated.
  • updated_by - User who last updated the server.
  • status - Current status of the MCP server.
  • last_health_check - Timestamp of the last health check.
  • health_check_error - Error message from the last health check, if any.

Import

MCP servers can be imported using their server ID:

terraform import litellm_mcp_server.example server-id-here

Transport Types

HTTP Transport

  • Standard HTTP/HTTPS communication
  • Suitable for REST API-based MCP servers
  • Supports authentication via auth_type

SSE (Server-Sent Events) Transport

  • Real-time streaming communication
  • Ideal for servers that need to push updates
  • Commonly used with services like Zapier

Stdio Transport

  • Standard input/output communication
  • Used for local MCP servers or command-line tools
  • Requires command and optionally args and env

Access Control

Use mcp_access_groups to control which teams or users can access the MCP server tools. This integrates with LiteLLM's permission management system.

Cost Tracking

Configure cost tracking through the mcp_info.mcp_server_cost_info block to monitor and control spending on MCP tool usage.