1 Resources tool_server
Forgejo Actions edited this page 2026-11-26 06:34:52 +00:00

openwebui_tool_server (Resource)

Registers one external tool server, OpenAPI or MCP, with Open WebUI.

Open WebUI keeps every tool server in a single configuration list, TOOL_SERVER_CONNECTIONS, and the only write route replaces that list as a whole. This resource reads the list, edits its own entry, and writes the list back, under a lock that serialises the resources of one Terraform run. It leaves every field of every other entry, and every field of its own entry that it does not model, exactly as it found them.

~> Note: openwebui_tool_server and openwebui_tool_servers_config manage the same list. Use one or the other, never both. openwebui_tool_server is the recommended one.

~> Note: The lock covers one process. Two terraform apply runs against the same instance at the same time can lose a tool server.

OAuth

An MCP server with auth_type = "oauth_2.1" authenticates with a registration blob that Open WebUI mints through dynamic client registration and stores encrypted in info.oauth_client_info. Registering is a separate call, so the two resources compose:

resource "openwebui_oauth_client" "paperless" {
  url       = "https://paperless.mcp.example"
  client_id = "paperless"
  type      = "mcp"
}

resource "openwebui_tool_server" "paperless" {
  server_id = "paperless"
  type      = "mcp"
  url       = "https://paperless.mcp.example"
  auth_type = "oauth_2.1"
  enabled   = true

  oauth_client_info = openwebui_oauth_client.paperless.oauth_client_info
}

The client_id of the OAuth client must equal the server_id of the tool server, because Open WebUI looks the client up as <type>:<server_id>.

The blob is a Fernet ciphertext under OAUTH_CLIENT_INFO_ENCRYPTION_KEY, which defaults to WEBUI_SECRET_KEY. Terraform carries it and cannot read or re-create it. Rotating either key invalidates every stored blob, and recovering means registering each OAuth client again.

Example Usage

# An OpenAPI tool server that needs no authentication.
resource "openwebui_tool_server" "weather" {
  server_id = "weather"
  url       = "https://tools.example.com/weather"
  path      = "openapi.json"
  auth_type = "none"
  enabled   = true
}

# An OpenAPI tool server behind a bearer token, shared with one group.
resource "openwebui_tool_server" "billing" {
  server_id = "billing"
  url       = "https://tools.example.com/billing"
  path      = "openapi.json"
  auth_type = "bearer"
  key       = var.billing_tool_token

  read_groups = ["finance"]
}

# An MCP server that authenticates with OAuth 2.1. Registering the OAuth client
# is a separate call, so the two resources compose. The client_id of the OAuth
# client must equal the server_id of the tool server.
resource "openwebui_oauth_client" "paperless" {
  url       = "https://paperless.mcp.example.com"
  client_id = "paperless"
  type      = "mcp"
}

resource "openwebui_tool_server" "paperless" {
  server_id   = "paperless"
  type        = "mcp"
  url         = "https://paperless.mcp.example.com"
  auth_type   = "oauth_2.1"
  enabled     = true
  name        = "Paperless"
  description = "Document search"

  oauth_client_info = openwebui_oauth_client.paperless.oauth_client_info
}

# An MCP server whose identity provider issued the credentials up front. The
# OAuth client registers with the secret, and the tool server overlays the same
# client id and secret onto the registration.
resource "openwebui_oauth_client" "invoices" {
  url           = "https://invoices.mcp.example.com"
  client_id     = "invoices"
  client_secret = var.invoices_oauth_client_secret
  type          = "mcp"
}

resource "openwebui_tool_server" "invoices" {
  server_id = "invoices"
  type      = "mcp"
  url       = "https://invoices.mcp.example.com"
  auth_type = "oauth_2.1_static"
  enabled   = true
  name      = "Invoices"

  oauth_client_id     = "invoices"
  oauth_client_secret = var.invoices_oauth_client_secret
  oauth_client_info   = openwebui_oauth_client.invoices.oauth_client_info
}

variable "billing_tool_token" {
  type      = string
  sensitive = true
}

variable "invoices_oauth_client_secret" {
  type      = string
  sensitive = true
}

Schema

Required

  • server_id (String) Identifier of the tool server, stored as info.id. Models reference the server as server:mcp:<server_id> or server:<server_id> in their tool_ids, so changing it breaks every model that points at this server. Forces replacement.
  • url (String) Base URL of the tool server, e.g. https://tools.example.

Optional

  • auth_type (String) How Open WebUI authenticates to the server: none, bearer, oauth_2.1, or oauth_2.1_static. bearer reads key. Both OAuth types read the registration in oauth_client_info and apply only to MCP servers.
  • description (String) Description of an MCP server, stored as info.description.
  • enabled (Boolean) Whether Open WebUI loads the server. Stored as config.enable; a disabled server stays registered and offers no tools. Defaults to true.
  • function_name_filter_list (List of String) Filters the tools the server exposes, matched by name suffix. A plain entry allows every tool whose name ends with it. An entry with a ! prefix blocks those tools instead. Unset, every tool is exposed. Stored as a list of strings under config.function_name_filter_list. The provider also reads the comma-separated string a save from the web UI writes.
  • headers_json (String) JSON object of extra HTTP headers, e.g. jsonencode({ X-Api-Version = "2" }).
  • key (String, Sensitive) Bearer token sent to the tool server when auth_type is bearer. Sensitive.
  • name (String) Display name of an MCP server, stored as info.name. An OpenAPI server takes its name from the fetched spec instead.
  • oauth_client_id (String) OAuth client identifier for auth_type = "oauth_2.1_static", which overlays it onto the registration blob.
  • oauth_client_info (String, Sensitive) Encrypted OAuth registration for the server, normally taken from the oauth_client_info attribute of an openwebui_oauth_client resource. Left unset, the blob already stored on the server is preserved untouched. Sensitive.
  • oauth_client_secret (String, Sensitive) OAuth client secret for auth_type = "oauth_2.1_static". Stored in plain text by Open WebUI. Sensitive.
  • oauth_resource_parameter (String) How Open WebUI sends the OAuth resource indicator: auto, always, or never. An unrecognised value reads as auto.
  • oauth_scope (String) Space-separated OAuth scopes to request for this server.
  • path (String) Path to the OpenAPI spec, e.g. openapi.json, appended to url unless it is itself a full URL. MCP servers ignore it. Defaults to empty.
  • public_read (Boolean) Whether every signed-in user can use the server's tools.
  • public_write (Boolean) Whether every signed-in user can manage the server's tools.
  • read_groups (List of String) List of group names or IDs granted read access to the server's tools.
  • read_users (List of String) List of user email addresses or IDs granted read access to the server's tools.
  • spec (String) Inline OpenAPI spec as JSON text, read when spec_type is json.
  • spec_type (String) Where an OpenAPI server's spec comes from: url fetches it from path, json reads it from spec.
  • type (String) Tool server type, openapi or mcp. Defaults to openapi.
  • write_groups (List of String) List of group names or IDs granted write access to the server's tools.
  • write_users (List of String) List of user email addresses or IDs granted write access to the server's tools. Name the same address in read_users as well.

Read-Only

  • id (String) Terraform identifier. Always equal to server_id.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# A tool server is imported by its server_id, which Open WebUI stores as info.id.
terraform import openwebui_tool_server.paperless paperless

# A connection registered by hand in the web UI may carry no info.id. Import it
# by its position in the list, and the next apply pins the identity.
terraform import openwebui_tool_server.weather weather@2