Sign inSign up

couchbase/mcp-server

By couchbase

Updated 2 days ago

An MCP server implementation of Couchbase that allows LLMs to directly interact with Couchbase data.

Image
Databases & storage
0

4.5K

couchbase/mcp-server repository overview

Couchbase MCP Server

Pre-built images for the Couchbase MCP Server.

Couchbase MCP Server is a self-hosted MCP Server that allows AI agents to connect to and interact with data in Couchbase clusters, whether hosted on Capella or self-managed. It provides tools across categories including Cluster Health, Data Schema, Key-Value, Query, and Performance — with safety controls via read-only mode and fine-grained tool disabling. It supports both STDIO and Streamable HTTP transports.

Enterprise support for Couchbase MCP Server is available by licensing Couchbase AI Data Plane, which also entitles use and enterprise support of Couchbase Agent Memory and Couchbase Agent Catalog.

GitHub Repo: https://github.com/couchbase/mcp-server-couchbase

Dockerfile: https://github.com/couchbase/mcp-server-couchbase/blob/main/Dockerfile

Documentation: https://docs.couchbase.com/mcp-server/get-started/overview.html

Features/Tools

Cluster setup & health tools
Tool NameDescription
get_server_configuration_statusGet the server status and configuration without connecting to the cluster — reports read-only mode, disabled/confirmation-required tools, OAuth settings, and the resolved logging configuration
test_cluster_connectionCheck the cluster credentials by connecting to the cluster
get_cluster_health_and_servicesGet cluster health status and list of all running services
Data model & schema discovery tools
Tool NameDescription
get_buckets_in_clusterGet a list of all the buckets in the cluster
get_scopes_in_bucketGet a list of all the scopes in the specified bucket
get_collections_in_scopeGet a list of all the collections in a specified scope and bucket. Note that this tool requires the cluster to have Query service.
get_scopes_and_collections_in_bucketGet a list of all the scopes and collections in the specified bucket
get_schema_for_collectionGet the structure for a collection
Document KV operations tools
Tool NameDescription
get_document_by_idGet a document by ID from a specified scope and collection
lookup_subdocumentLook up parts of a document (specific fields, existence checks, or array/object counts) by path without fetching the whole document
upsert_document_by_idUpsert a document by ID to a specified scope and collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true.
insert_document_by_idInsert a new document by ID (fails if document exists). Disabled by default when CB_MCP_READ_ONLY_MODE=true.
replace_document_by_idReplace an existing document by ID (fails if document doesn't exist). Disabled by default when CB_MCP_READ_ONLY_MODE=true.
delete_document_by_idDelete a document by ID from a specified scope and collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true.
mutate_subdocumentModify parts of an existing document (upsert, insert, replace, remove, array ops, counters) by path without rewriting the whole document. Disabled by default when CB_MCP_READ_ONLY_MODE=true.
Query and indexing tools
Tool NameDescription
list_indexesList all indexes in the cluster with their definitions, with optional filtering by bucket, scope, collection and index name. Set return_raw_index_stats=true to return the unprocessed index information.
get_index_advisor_recommendationsGet index recommendations from Couchbase Index Advisor for a given SQL++ query to optimize query performance
create_indexCreate a scalar (non-vector) GSI secondary index on a collection. Deferred by default — call build_index afterward to build it. Disabled by default when CB_MCP_READ_ONLY_MODE=true.
build_indexTrigger the build of all deferred indexes on a collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true.
drop_indexDrop a GSI index (scalar or vector) from a collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true.
run_sql_plus_plus_queryRun a SQL++ query on a specified scope.

Queries are automatically scoped to the specified bucket and scope, so use collection names directly (e.g., SELECT * FROM users instead of SELECT * FROM bucket.scope.users).

CB_MCP_READ_ONLY_MODE is true by default, which means that all write operations (KV, Query, and index management) are disabled. When enabled, KV and index write tools are not loaded and SQL++ queries that modify data are blocked.
explain_sql_plus_plus_queryGenerate and evaluate an EXPLAIN plan for a SQL++ query. Returns query metadata, extracted plan, and plan evaluation findings.
Query performance analysis tools
Tool NameDescription
get_longest_running_queriesGet longest running queries by average service time
get_most_frequent_queriesGet most frequently executed queries
get_queries_with_largest_response_sizesGet queries with the largest response sizes
get_queries_with_large_result_countGet queries with the largest result counts
get_queries_using_primary_indexGet queries that use a primary index (potential performance concern)
get_queries_not_using_covering_indexGet queries that don't use a covering index
get_queries_not_selectiveGet queries that are not selective (index scans return many more documents than final result)

Usage

The Docker images can be used in the supported MCP clients such as Claude Desktop, Cursor, Windsurf, etc in combination with Docker.

Configuration

Add the configuration specified below to the MCP configuration in your MCP client.

{
  "mcpServers": {
    "couchbase": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "CB_CONNECTION_STRING=<couchbase_connection_string>",
        "-e",
        "CB_USERNAME=<database_username>",
        "-e",
        "CB_PASSWORD=<database_password>",
        "docker.io/couchbase/mcp-server:latest"
      ]
    }
  }
}
Environment Variables

The detailed explanation for the environment variables can be found on the GitHub Repo.

VariableDescriptionDefault
CB_CONNECTION_STRINGCouchbase Connection stringRequired
CB_USERNAMEDatabase usernameRequired (or Client Certificate and Key needed for mTLS)
CB_PASSWORDDatabase passwordRequired (or Client Certificate and Key needed for mTLS)
CB_CLIENT_CERT_PATHPath to the client certificate file for mTLS authenticationRequired if using mTLS (or Username and Password required)
CB_CLIENT_KEY_PATHPath to the client key file for mTLS authenticationRequired if using mTLS (or Username and Password required)
CB_CA_CERT_PATHPath to server root certificate for TLS if server is configured with a self-signed/untrusted certificate.
CB_MCP_READ_ONLY_MODEPrevent all data modifications (KV, Query, and index management). When true, KV and index write tools are not loaded.true
CB_MCP_TRANSPORTTransport mode (stdio/http/sse)stdio
CB_MCP_HOSTServer host (HTTP/SSE modes)127.0.0.1
CB_MCP_PORTServer port (HTTP/SSE modes)8000
CB_MCP_DISABLED_TOOLSTools to disable (see Disabling Tools)None
CB_MCP_CONFIRMATION_REQUIRED_TOOLSTools that require explicit user confirmation before execution (see Elicitation/Confirmation for Tool Calls)None
CB_MCP_LOG_LEVELLogging level for the server: off, debug, info, warning, error (see Logging)info
CB_MCP_LOG_SINKSComma-separated log destinations: stderr, file, or both (see Logging)stderr
CB_MCP_LOG_FILEBase path for per-level log files (only used when the file sink is enabled)mcp_server.log
CB_MCP_LOG_ROTATION_MAX_SIZE_MBGlobal max size in MB per log file before it rotates, inherited by every level. 0 is invalid and falls back to the default with a startup warning1 (1 MB)
CB_MCP_LOG_MAX_BYTESDeprecated — use CB_MCP_LOG_ROTATION_MAX_SIZE_MB (MB). Global rotation size in bytes, still honored for backward compatibility; ignored when CB_MCP_LOG_ROTATION_MAX_SIZE_MB is setUnset
CB_MCP_LOG_ERROR_ROTATION_MAX_SIZE_MBRotation size in MB for the ERROR log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for ERRORInherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB
CB_MCP_LOG_WARNING_ROTATION_MAX_SIZE_MBRotation size in MB for the WARNING log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for WARNINGInherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB
CB_MCP_LOG_INFO_ROTATION_MAX_SIZE_MBRotation size in MB for the INFO log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for INFOInherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB
CB_MCP_LOG_DEBUG_ROTATION_MAX_SIZE_MBRotation size in MB for the DEBUG log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for DEBUGInherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB
CB_MCP_LOG_RETENTION_BACKUP_COUNTRotated backups kept per-level log file (excluding the live file), applied to every level unless overridden. 0 keeps only the live file1
CB_MCP_LOG_ERROR_RETENTION_BACKUP_COUNTRotated backups kept for the ERROR log file; overrides the global count for ERRORInherits CB_MCP_LOG_RETENTION_BACKUP_COUNT
CB_MCP_LOG_WARNING_RETENTION_BACKUP_COUNTRotated backups kept for the WARNING log file; overrides the global count for WARNINGInherits CB_MCP_LOG_RETENTION_BACKUP_COUNT
CB_MCP_LOG_INFO_RETENTION_BACKUP_COUNTRotated backups kept for the INFO log file; overrides the global count for INFOInherits CB_MCP_LOG_RETENTION_BACKUP_COUNT
CB_MCP_LOG_DEBUG_RETENTION_BACKUP_COUNTRotated backups kept for the DEBUG log file; overrides the global count for DEBUGInherits CB_MCP_LOG_RETENTION_BACKUP_COUNT
CB_MCP_OAUTH_JWT_JWKS_URIJWKS endpoint of the identity provider used to verify bearer JWTs. Enables OAuth when set with the issuer and audience (see OAuth 2.1 Authorization)None
CB_MCP_OAUTH_JWT_ISSUERExpected JWT iss claim. Required to enable OAuthNone
CB_MCP_OAUTH_JWT_AUDIENCEExpected JWT aud claim. Required to enable OAuthNone
CB_MCP_OAUTH_JWT_ALGORITHMJWT signing algorithm: one of RS256/384/512, ES256/384/512, PS256/384/512RS256
CB_MCP_OAUTH_MCP_BASE_URLPublic base URL of this server. When set, publishes RFC 9728 Protected Resource Metadata for PRM-aware clientsNone
CB_MCP_OAUTH_SCOPE_READ_LABELOverride the OAuth scope label treated as 'read' access (advertised in PRM and matched against the token scope/scp claim). Use when your IdP can't emit the canonical formcouchbase-mcp:read
CB_MCP_OAUTH_SCOPE_WRITE_LABELOverride the OAuth scope label treated as 'write' access; same semantics as the read labelcouchbase-mcp:write
Disabling Tools

You can disable specific tools to prevent them from being loaded and exposed to the MCP client. Disabled tools will not appear in the tool discovery and cannot be invoked by the LLM.

Supported Formats

Comma-separated list:

# Environment variable
CB_MCP_DISABLED_TOOLS="upsert_document_by_id, delete_document_by_id"

# Command line
uvx couchbase-mcp-server --disabled-tools upsert_document_by_id, delete_document_by_id

File path (one tool name per line):

# Environment variable
CB_MCP_DISABLED_TOOLS=disabled_tools.txt

# Command line
uvx couchbase-mcp-server --disabled-tools disabled_tools.txt

File format (e.g., disabled_tools.txt):

# Write operations
upsert_document_by_id
delete_document_by_id

# Index advisor
get_index_advisor_recommendations

Lines starting with # are treated as comments and ignored.

MCP Client Configuration Examples

Using comma-separated list:

{
  "mcpServers": {
    "couchbase": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "CB_CONNECTION_STRING=couchbases://connection-string",
        "-e",
        "CB_USERNAME=username",
        "-e",
        "CB_PASSWORD=password",
        "-e",
        "CB_MCP_DISABLED_TOOLS=upsert_document_by_id,delete_document_by_id",
        "docker.io/couchbase/mcp-server:latest"
      ]
    }
  }
}

Using file path (recommended for many tools):

{
  "mcpServers": {
    "couchbase": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-v",
        "/path/to/disabled_tools.txt:/app/disabled_tools.txt",
        "-e",
        "CB_CONNECTION_STRING=couchbases://connection-string",
        "-e",
        "CB_USERNAME=username",
        "-e",
        "CB_PASSWORD=password",
        "-e",
        "CB_MCP_DISABLED_TOOLS=/app/disabled_tools.txt",
        "docker.io/couchbase/mcp-server:latest"
      ]
    }
  }
}
Important Security Note

Warning: Disabling tools alone does not guarantee that certain operations cannot be performed. The underlying database user's RBAC (Role-Based Access Control) permissions are the authoritative security control.

For example, even if you disable upsert_document_by_id and delete_document_by_id, data modifications can still occur via the run_sql_plus_plus_query tool using SQL++ DML statements (INSERT, UPDATE, DELETE, MERGE) unless:

  • The CB_MCP_READ_ONLY_MODE is set to true (default), which disables all write operations (KV, Query, and index management), OR
  • The database user lacks the necessary RBAC permissions for data modification

Best Practice: Always configure appropriate RBAC permissions on your Couchbase user credentials as the primary security measure. Use CB_MCP_READ_ONLY_MODE=true (the default) for comprehensive write protection, and tool disabling as an additional layer to guide LLM behavior.

Elicitation/Confirmation for Tool Calls

You can require explicit user confirmation for specific tools before execution (when the MCP client supports elicitation).

Configuration Formats

Comma-separated list:

CB_MCP_CONFIRMATION_REQUIRED_TOOLS="delete_document_by_id,replace_document_by_id"

File path (one tool name per line):

CB_MCP_CONFIRMATION_REQUIRED_TOOLS=confirmation_tools.txt

File format (e.g., confirmation_tools.txt):

# Destructive operations
delete_document_by_id
replace_document_by_id

Lines starting with # are treated as comments and ignored.

Behavior

When a listed tool is invoked:

  • If the client supports elicitation, the user is prompted to confirm before execution.
  • If the client does not support elicitation, the tool executes without confirmation for backward compatibility.
MCP Client Configuration Example
{
  "mcpServers": {
    "couchbase": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "CB_CONNECTION_STRING=couchbases://connection-string",
        "-e",
        "CB_USERNAME=username",
        "-e",
        "CB_PASSWORD=password",
        "-e",
        "CB_MCP_CONFIRMATION_REQUIRED_TOOLS=delete_document_by_id,replace_document_by_id",
        "docker.io/couchbase/mcp-server:latest"
      ]
    }
  }
}
Logging

The server logs to stderr by default. Logging is configured with the CB_MCP_LOG_* variables in the Environment Variables table:

  • CB_MCP_LOG_LEVEL — how much is logged: info (the default) logs lifecycle events and tool invocations, debug adds verbose internal detail, and off disables all logging.
  • CB_MCP_LOG_SINKS — where logs go: stderr (the default), per-level rotating files (file), or both. With file, one file is written per level (for example mcp_server.info.log and mcp_server.error.log) at the path set by CB_MCP_LOG_FILE. Mount a volume at that path to keep the logs after the container stops.
  • Rotation & retention — rotation size is configured in MB via CB_MCP_LOG_ROTATION_MAX_SIZE_MB (global) and per-level CB_MCP_LOG_<LEVEL>_ROTATION_MAX_SIZE_MB (inheriting the global); retention via CB_MCP_LOG_RETENTION_BACKUP_COUNT (global) and per-level CB_MCP_LOG_<LEVEL>_RETENTION_BACKUP_COUNT. A rotation size of 0 is invalid and falls back to the default with a startup warning. CB_MCP_LOG_MAX_BYTES (bytes) is deprecated but still honored for backward compatibility.
  • Server-config snapshot — with the file sink active, a one-shot record is written as JSON to a dedicated mcp_server_config.log.json file (derived from CB_MCP_LOG_FILE), overwritten each start, so support always has the current config even after other logs rotate.

For more details, see the documentation.

OAuth 2.1 Authorization

When running with CB_MCP_TRANSPORT=http, the server can act as an OAuth 2.1 resource server: it validates incoming bearer JWTs against your identity provider's JWKS. It is provider-agnostic (any OAuth 2.1 / OIDC provider that publishes a JWKS — Auth0, Okta, Keycloak, AWS Cognito, Microsoft Entra, etc.) and does not issue tokens or manage users. OAuth settings are ignored on stdio.

OAuth is configured with the CB_MCP_OAUTH_* variables in the Environment Variables table:

  • OAuth activates only when all three of CB_MCP_OAUTH_JWT_JWKS_URI, CB_MCP_OAUTH_JWT_ISSUER, and CB_MCP_OAUTH_JWT_AUDIENCE are set; setting only some of them fails at startup.
  • Setting CB_MCP_OAUTH_MCP_BASE_URL additionally publishes RFC 9728 Protected Resource Metadata so PRM-aware clients can discover the authorization server.
  • Access is gated by two scopes read from the token's scope/scp claim: couchbase-mcp:read (read tools, including SQL++) and couchbase-mcp:write (write tools: KV mutations and index management). Full access requires both. If your IdP can't emit those canonical labels, override them with CB_MCP_OAUTH_SCOPE_READ_LABEL / CB_MCP_OAUTH_SCOPE_WRITE_LABEL.

For full details, see the documentation.

Tag summary

Content type

Image

Digest

sha256:d13270383

Size

105.9 MB

Last updated

about 1 month ago

docker pull couchbase/mcp-server