terraform/provider/docs/resources/mcp_server.md
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.
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"]
}
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
}
}
}
}
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
}
}
}
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
}
}
}
}
The following arguments are supported:
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.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.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.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.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.MCP servers can be imported using their server ID:
terraform import litellm_mcp_server.example server-id-here
auth_typecommand and optionally args and envUse mcp_access_groups to control which teams or users can access the MCP server tools. This integrates with LiteLLM's permission management system.
Configure cost tracking through the mcp_info.mcp_server_cost_info block to monitor and control spending on MCP tool usage.