
A production-ready bridge to Couchbase clusters that exposes both KV operations and SQL++ queries through MCP. You get schema discovery across buckets, scopes, and collections, standard CRUD operations on documents, and full query capabilities including EXPLAIN plans and Index Advisor recommendations. The query performance tools are especially useful for optimization work, surfacing slow queries, primary index usage, and missing covering indexes. Ships with read-only mode enabled by default, so you can safely connect Claude to production clusters for analysis without risking data modifications. Works with both self-hosted Couchbase and Capella cloud instances, requiring Python 3.10+ and cluster credentials to get started.
Couchbase MCP Server is a self-hosted Model Context Protocol (MCP) server that connects AI agents and LLM-powered assistants — Claude, Cursor, Windsurf, VS Code Copilot, and other MCP clients — to data in Couchbase clusters, whether hosted on Capella or self-managed. MCP is an open standard for letting AI assistants call tools and query external data sources; this server implements that standard for Couchbase, so an AI agent can inspect your cluster, run SQL++ queries, read and write documents, and analyze query performance using natural language instead of hand-written code.
It provides tools across categories including Cluster Health, Data Schema, Key-Value, Query, and Performance — with safety controls via read-only mode (on by default) and fine-grained tool disabling, so you can let an AI agent explore and query your data without risking unintended writes. It supports both STDIO and Streamable HTTP transports.
Couchbase MCP server is distributed as a Python Package Index (PyPI) package and via Docker. 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.
For full documentation, visit mcp-server.couchbase.com.
For full documentation, visit docs.couchbase.com/mcp-server.
CB_MCP_READ_ONLY_MODE=false, and individual tools can be disabled or gated behind user confirmation.Once the server is connected, you can talk to your Couchbase cluster in natural language through your AI assistant. For example:
orders collection?"users collection where status = 'active'."products collection with these fields: ..." (requires CB_MCP_READ_ONLY_MODE=false)This distribution ships two servers: the operational server (default —
the tables immediately below) talks to a regular Couchbase cluster via the
couchbase SDK, and the Operational Insights
server (its own table further down) talks to Operational Insights clusters via
the couchbase-operational-insights SDK.
| Tool Name | Description |
|---|---|
get_server_configuration_status | Get 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_connection | Check the cluster credentials by connecting to the cluster |
get_cluster_health_and_services | Get cluster health status and list of all running services, optionally filtered to specific services via service_types |
get_cluster_diagnostics_report | Get the SDK's cached connection diagnostics — whether connections were already broken and for how long, without any active network probing |
get_cluster_metrics | Get one or more cluster statistics over a historic time window via the Management REST API's stats-range endpoint. Self-managed Couchbase Server 7.6+ only — not available on Capella. |
get_cluster_tasks | Get the cluster tasks running right now — rebalance, compaction, XDCR, index build — via the Management REST API's tasks endpoint. Returns the raw task array; fields vary by task type. Requires the Read-Only Admin (ro_admin) role. Self-managed Couchbase Server 7.6+ only — not available on Capella. |
get_cluster_health_snapshot | Get a per-node health snapshot — service topology, membership, orchestrator and a cluster health rollup — merged from the Management REST API's /pools/default, nodeServices and terseClusterInfo endpoints. Isolates a symptom to a specific node/service and flags which nodes are safe to act on. Requires the Read-Only Admin (ro_admin) role. Self-managed Couchbase Server 7.6+ only — not available on Capella. |
discover_tool_input_values | Look up the exact input values another tool needs, from reference data bundled with the server — currently every Couchbase Server metric name (type, unit, version added, description) for get_cluster_metrics. Browse by category or fuzzy-search by keyword. Works offline, without a cluster connection. |
| Tool Name | Description |
|---|---|
get_buckets_in_cluster | Get a list of all the buckets in the cluster |
get_scopes_in_bucket | Get a list of all the scopes in the specified bucket |
get_collections_in_scope | Get 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_bucket | Get a list of all the scopes and collections in the specified bucket |
get_schema_for_collection | Get the structure for a collection |
create_scope | Create a new scope in a bucket (Couchbase Server 7.6+ and Capella). Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
create_collection | Create a new collection in an existing scope (Couchbase Server 7.6+ and Capella). Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
delete_scope | Delete a scope and all its collections from a bucket — permanent. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
delete_collection | Delete a collection and all its documents from a scope — permanent. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
| Tool Name | Description |
|---|---|
get_document_by_id | Get a document by ID from a specified scope and collection |
lookup_subdocument | Look up parts of a document (specific fields, existence checks, or array/object counts) by path without fetching the whole document |
upsert_document_by_id | Upsert a document by ID to a specified scope and collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
insert_document_by_id | Insert a new document by ID (fails if document exists). Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
replace_document_by_id | Replace an existing document by ID (fails if document doesn't exist). Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
delete_document_by_id | Delete a document by ID from a specified scope and collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
mutate_subdocument | Modify 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. |
| Tool Name | Description |
|---|---|
list_indexes | List 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_recommendations | Get index recommendations from Couchbase Index Advisor for a given SQL++ query to optimize query performance |
create_index | Create 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_index | Trigger the build of all deferred indexes on a collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
drop_index | Drop a GSI index (scalar or vector) from a collection. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
run_sql_plus_plus_query | Run 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, scope/collection management, index management, and FTS index management) are disabled. When enabled (i.e. CB_MCP_READ_ONLY_MODE=true), write tools are not loaded and SQL++ queries that modify data are blocked. |
explain_sql_plus_plus_query | Generate and evaluate an EXPLAIN plan for a SQL++ query. Returns query metadata, extracted plan, and plan evaluation findings. |
Requires Couchbase Server 7.6+ and the Search service. Vector search is not supported by these tools (see the separate vector search tooling).
| Tool Name | Description |
|---|---|
list_fts_indexes | List Search (FTS) indexes. With no filters, lists cluster-level (legacy) indexes; with bucket_name, lists scope-level (scoped) indexes across every scope in that bucket; with bucket_name and scope_name, lists scope-level indexes in that one scope. |
get_fts_index_definition | Get the full definition of a single Search index (mappings, analyzers, plan params). Pass bucket_name and scope_name together for a scope-level index, or omit both for a cluster-level (legacy) index. |
run_fts_query | Run an FTS query against a Search index, or fetch its execution plan. query is the raw FTS query JSON body, supporting any non-vector query type (match, match_phrase, term, conjuncts, disjuncts, geo, date/numeric range, query_string, ...). Pass explain=true to fetch the execution plan instead of results — this still executes the query (limit defaulting to 1) since the Search service only exposes the plan per matched hit, not as a separate dry-run call. |
upsert_fts_index | Create or update a Search (FTS) index definition (mappings, analyzers, plan params). Works with both scope-level (scoped) and cluster-level (legacy) indexes. Pass bucket_name and scope_name together to target a scope-level index, or omit both for a cluster-level (legacy) index. Updating an existing index triggers a full rebuild — fetch the current definition with get_fts_index_definition first and pass its uuid back to avoid clobbering concurrent changes. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
drop_fts_index | Drop a Search (FTS) index. Works with both scope-level (scoped) and cluster-level (legacy) indexes. Pass bucket_name and scope_name together for a scope-level index, or omit both for a cluster-level (legacy) index. This permanently removes the index and cannot be undone — confirm the exact name and location with list_fts_indexes first. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
| Tool Name | Description |
|---|---|
get_longest_running_queries | Get longest running queries by average service time |
get_most_frequent_queries | Get most frequently executed queries |
get_queries_with_largest_response_sizes | Get queries with the largest response sizes |
get_queries_with_large_result_count | Get queries with the largest result counts |
get_queries_using_primary_index | Get queries that use a primary index (potential performance concern) |
get_queries_not_using_covering_index | Get queries that don't use a covering index |
get_queries_not_selective | Get queries that are not selective (index scans return many more documents than final result) |
Registered by the separate operational-insights server (see
Operational Insights Server below), not the
default operational one.
| Tool Name | Description |
|---|---|
get_server_configuration_status | Get this server's status and configuration without connecting to a cluster — read-only mode, disabled/confirmation-required tools, OAuth settings, and the resolved logging configuration. Shared with the operational server: the same tool, registered by both. |
get_databases_in_cluster | List all databases in the Operational Insights cluster. |
get_scopes_in_database | List all scopes in a database. |
get_collections_in_scope | List all collections (datasets) in a scope. Shares its name with the operational server's tool of the same name — see the note below. |
get_schema_for_collection | Infer the JSON schema of a collection by sampling documents. Shares its name with the operational server's tool of the same name — see the note below. |
list_indexes | List secondary indexes via the System.Metadata.Index catalog (the SDK has no index manager). Shares its name with the operational server's tool of the same name — see the note below. |
run_query_sync | Run a SQL++ statement (SELECT, DML, or DDL) and return all result rows. Enforces read-only mode server-side via QueryOptions(readonly=True) — there is no client-side SQL++ parser here. |
explain_query | Generate the query plan for a SQL++ statement via EXPLAIN, without executing it. |
create_index | Create a secondary index via CREATE INDEX (the SDK has no index manager). Disabled by default when CB_MCP_READ_ONLY_MODE=true. Shares its name with the operational server's tool of the same name — see the note below. |
run_query_async | Start a SQL++ statement without waiting for it to finish, returning a query_handle token. Same read-only enforcement as run_query_sync. |
get_async_query_results | Check whether an async query has finished and, if so, return its rows. Doubles as the status check — call again later if not yet ready. |
discard_async_query_results | Free a finished async query's result buffers on the server. Normal cleanup step after get_async_query_results. |
cancel_async_query | Stop an async query that is still running. Disabled by default when CB_MCP_READ_ONLY_MODE=true. A finished query cannot be cancelled — discard its results instead. |
The Server Async Request API tools form a start → poll → discard-or-cancel
flow for long-running queries: run_query_async returns a query_handle,
get_async_query_results is polled until it reports readiness (and returns
the rows), then either discard_async_query_results frees the results or,
for a query still running, cancel_async_query stops it.
Note:
get_collections_in_scope,get_schema_for_collection,create_indexandlist_indexesexist, with different behavior, on both servers. (get_server_configuration_statusalso appears on both, but it is deliberately one shared tool — same implementation, same result shape — so it needs no disambiguation.) Each server is a separate process, so this is only a concern if a single MCP client registers bothoperationalandoperational-insightssimultaneously — in that case, disambiguate at the client configuration layer (e.g. by giving the two server entries distinct names in the client's own config).
The MCP server can be run either from the prebuilt PyPI package or the source using uv.
We publish a pre built PyPI package for the MCP server.
{
"mcpServers": {
"couchbase": {
"command": "uvx",
"args": ["couchbase-mcp-server"],
"env": {
"CB_CONNECTION_STRING": "couchbases://connection-string",
"CB_USERNAME": "username",
"CB_PASSWORD": "password"
}
}
}
}
or
{
"mcpServers": {
"couchbase": {
"command": "uvx",
"args": ["couchbase-mcp-server"],
"env": {
"CB_CONNECTION_STRING": "couchbases://connection-string",
"CB_CLIENT_CERT_PATH": "/path/to/client-certificate.pem",
"CB_CLIENT_KEY_PATH": "/path/to/client.key"
}
}
}
}
Note: If you have other MCP servers in use in the client, you can add it to the existing
mcpServersobject.
The MCP server can be run from the source using this repository.
git clone https://github.com/couchbase/mcp-server-couchbase.git
This is the common configuration for the MCP clients such as Claude Desktop, Cursor, Windsurf Editor.
{
"mcpServers": {
"couchbase": {
"command": "uv",
"args": [
"--directory",
"path/to/cloned/repo/mcp-server-couchbase/",
"run",
"src/mcp_server.py"
],
"env": {
"CB_CONNECTION_STRING": "couchbases://connection-string",
"CB_USERNAME": "username",
"CB_PASSWORD": "password"
}
}
}
}
Note:
path/to/cloned/repo/mcp-server-couchbase/should be the path to the cloned repository on your local machine. Don't forget the trailing slash at the end!
Note: If you have other MCP servers in use in the client, you can add it to the existing
mcpServersobject.
The server can be configured using environment variables or command line arguments:
| Environment Variable | CLI Argument | Description | Default |
|---|---|---|---|
CB_CONNECTION_STRING | --connection-string | Connection string to the Couchbase cluster | Required |
CB_USERNAME | --username | Username with access to required buckets for basic authentication | Required (or Client Certificate and Key needed for mTLS) |
CB_PASSWORD | --password | Password for basic authentication | Required (or Client Certificate and Key needed for mTLS) |
CB_CLIENT_CERT_PATH | --client-cert-path | Path to the client certificate file for mTLS authentication | Required if using mTLS (or Username and Password required) |
CB_CLIENT_KEY_PATH | --client-key-path | Path to the client key file for mTLS authentication | Required if using mTLS (or Username and Password required) |
CB_CA_CERT_PATH | --ca-cert-path | Path to server root certificate for TLS if server is configured with a self-signed/untrusted certificate. This will not be required if you are connecting to Capella | |
CB_MCP_READ_ONLY_MODE | --read-only-mode | Prevent all data modifications (KV, Query, scope/collection management, index management, and FTS index management). When enabled, write tools are not loaded. | true |
CB_MCP_TRANSPORT | --transport | Transport mode: stdio, http, sse | stdio |
CB_MCP_HOST | --host | Host for HTTP/SSE transport modes | 127.0.0.1 |
CB_MCP_PORT | --port | Port for HTTP/SSE transport modes | 8000 |
CB_MCP_DISABLED_TOOLS | --disabled-tools | Tools to disable (see Disabling Tools) | None |
CB_MCP_CONFIRMATION_REQUIRED_TOOLS | --confirmation-required-tools | Tools that require explicit user confirmation before execution via MCP elicitation (see Elicitation/Confirmation Required Tools) | None |
CB_MCP_LOG_LEVEL | --log-level | Logging level for the MCP server: off, debug, info, warning, error (see Logging) | info |
CB_MCP_LOG_SINKS | --log-sinks | Comma-separated log destinations: stderr, file, or both (see Logging) | stderr |
CB_MCP_LOG_FILE | --log-file | Base path for per-level log files (only used when the file sink is enabled) | mcp_server.log |
CB_MCP_LOG_ROTATION_MAX_SIZE_MB | --log-rotation-max-size-mb | Global maximum size in MB per log file before it rotates, inherited by every level unless overridden. 0 is invalid and falls back to the default with a startup warning | 1 (1 MB) |
CB_MCP_LOG_MAX_BYTES | --log-max-bytes | Deprecated — 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 also set | Unset |
CB_MCP_LOG_ERROR_ROTATION_MAX_SIZE_MB | --log-error-rotation-max-size-mb | Rotation size in MB for the ERROR log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for ERROR | Inherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB |
CB_MCP_LOG_WARNING_ROTATION_MAX_SIZE_MB | --log-warning-rotation-max-size-mb | Rotation size in MB for the WARNING log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for WARNING | Inherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB |
CB_MCP_LOG_INFO_ROTATION_MAX_SIZE_MB | --log-info-rotation-max-size-mb | Rotation size in MB for the INFO log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for INFO | Inherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB |
CB_MCP_LOG_DEBUG_ROTATION_MAX_SIZE_MB | --log-debug-rotation-max-size-mb | Rotation size in MB for the DEBUG log file; overrides CB_MCP_LOG_ROTATION_MAX_SIZE_MB for DEBUG | Inherits CB_MCP_LOG_ROTATION_MAX_SIZE_MB |
CB_MCP_LOG_RETENTION_BACKUP_COUNT | --log-retention-backup-count | Rotated backup files kept per-level log file (excluding the live file), applied to every level unless overridden. 0 keeps only the live file (see Logging) | 1 |
CB_MCP_LOG_ERROR_RETENTION_BACKUP_COUNT | --log-error-retention-backup-count | Rotated backups kept for the ERROR log file; overrides the global count for ERROR | Inherits CB_MCP_LOG_RETENTION_BACKUP_COUNT |
CB_MCP_LOG_WARNING_RETENTION_BACKUP_COUNT | --log-warning-retention-backup-count | Rotated backups kept for the WARNING log file; overrides the global count for WARNING | Inherits CB_MCP_LOG_RETENTION_BACKUP_COUNT |
CB_MCP_LOG_INFO_RETENTION_BACKUP_COUNT | --log-info-retention-backup-count | Rotated backups kept for the INFO log file; overrides the global count for INFO | Inherits CB_MCP_LOG_RETENTION_BACKUP_COUNT |
CB_MCP_LOG_DEBUG_RETENTION_BACKUP_COUNT | --log-debug-retention-backup-count | Rotated backups kept for the DEBUG log file; overrides the global count for DEBUG | Inherits CB_MCP_LOG_RETENTION_BACKUP_COUNT |
CB_MCP_OAUTH_JWT_JWKS_URI | --oauth-jwks-uri | JWKS 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_ISSUER | --oauth-issuer | Expected JWT iss claim. Required to enable OAuth | None |
CB_MCP_OAUTH_JWT_AUDIENCE | --oauth-audience | Expected JWT aud claim. Required to enable OAuth | None |
CB_MCP_OAUTH_JWT_ALGORITHM | --oauth-algorithm | JWT signing algorithm: one of RS256/384/512, ES256/384/512, PS256/384/512 | RS256 |
CB_MCP_OAUTH_MCP_BASE_URL | --oauth-mcp-base-url | Public base URL of this server. When set, publishes RFC 9728 Protected Resource Metadata so PRM-aware clients can discover the IdP | None |
CB_MCP_OAUTH_SCOPE_READ_LABEL | --oauth-scope-read-label | Override the OAuth scope label treated as 'read' access (advertised in PRM and matched against the token's scope/scp claim). Use when your IdP can't emit the canonical form | couchbase-mcp:read |
CB_MCP_OAUTH_SCOPE_WRITE_LABEL | --oauth-scope-write-label | Override the OAuth scope label treated as 'write' access; same semantics as the read label | couchbase-mcp:write |
CB_MCP_READ_ONLY_MODE is the single switch controlling write operations:
true (default): All write operations (KV, Query, scope/collection management, index management, and FTS index management) are disabled. All write tools (KV: upsert, insert, replace, delete, sub-document mutate; scope/collection management: create_scope, create_collection, delete_scope, delete_collection; index management: create_index, build_index, drop_index; FTS index management: upsert_fts_index, drop_fts_index) are not loaded and will not be available to the LLM, and SQL++ queries that modify data or structure are blocked.false: All write tools are loaded and SQL++ data/structure modification queries are allowed.This is the recommended safe default to prevent inadvertent data modifications by LLMs.
Note: For authentication, you need either the Username and Password or the Client Certificate and key paths. Optionally, you can specify the CA root certificate path that will be used to validate the server certificates. If both the Client Certificate & key path and the username and password are specified, the client certificates will be used for authentication.
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.
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.
Using comma-separated list:
{
"mcpServers": {
"couchbase": {
"command": "uvx",
"args": ["couchbase-mcp-server"],
"env": {
"CB_CONNECTION_STRING": "couchbases://connection-string",
"CB_USERNAME": "username",
"CB_PASSWORD": "password",
"CB_MCP_DISABLED_TOOLS": "upsert_document_by_id,delete_document_by_id"
}
}
}
}
Using file path (recommended for many tools):
{
"mcpServers": {
"couchbase": {
"command": "uvx",
"args": ["couchbase-mcp-server"],
"env": {
"CB_CONNECTION_STRING": "couchbases://connection-string",
"CB_USERNAME": "username",
"CB_PASSWORD": "password",
"CB_MCP_DISABLED_TOOLS": "/path/to/disabled_tools.txt"
}
}
}
}
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_idanddelete_document_by_id, data modifications can still occur via therun_sql_plus_plus_querytool using SQL++ DML statements (INSERT, UPDATE, DELETE, MERGE) unless:
- The
CB_MCP_READ_ONLY_MODEis set totrue(default), 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 tool disabling as an additional layer to guide LLM behavior and reduce the attack surface, not as the sole security control.
You can require explicit user confirmation for specific tools before execution (when the MCP client supports elicitation).
CB_MCP_CONFIRMATION_REQUIRED_TOOLS / --confirmation-required-tools supports these formats:
# comments supported)Example:
# Environment variable
CB_MCP_CONFIRMATION_REQUIRED_TOOLS="delete_document_by_id,replace_document_by_id"
# Command line
uvx couchbase-mcp-server --confirmation-required-tools delete_document_by_id,replace_document_by_id
When a listed tool is invoked:
You can also check the version of the server using:
uvx couchbase-mcp-server --version
The MCP server logs to stderr by default. Logging is configured with the CB_MCP_LOG_* variables listed in Additional Configuration:
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.CB_MCP_LOG_ROTATION_MAX_SIZE_MB is the global size (in MB) at which each per-level file rotates. Override individual levels with CB_MCP_LOG_<LEVEL>_ROTATION_MAX_SIZE_MB (ERROR/WARNING/INFO/DEBUG), also in MB, which inherit the global when unset. A size of 0 (global or per-level) is invalid and falls back to the default (1 MB) with a startup warning. CB_MCP_LOG_MAX_BYTES (bytes) is deprecated but still honored for backward compatibility; it is ignored when CB_MCP_LOG_ROTATION_MAX_SIZE_MB is also set, and prints a deprecation warning at startup.CB_MCP_LOG_RETENTION_BACKUP_COUNT sets how many rotated backups are kept per level (excluding the live file); the default of 1 preserves the previous behaviour. Override individual levels with CB_MCP_LOG_<LEVEL>_RETENTION_BACKUP_COUNT (ERROR/WARNING/INFO/DEBUG), which inherit the global value when unset. Set a count to 0 to keep only the live file for that level — it is still capped by the rotation size (reset on rollover rather than backed up).file sink is active, a one-shot record (OS, Python, dependency versions, transport, resolved logging config, and redacted server config) is written as JSON to a dedicated mcp_server_config.log.json file (derived from the CB_MCP_LOG_FILE base). It is overwritten on each start, so support always has the current config and it never scrolls out of a rotating log.# Enable debug logging to both stderr and rotating per-level files
uvx couchbase-mcp-server --log-level=debug --log-sinks=stderr,file
# Keep 30 rotated ERROR backups but only the live DEBUG file
uvx couchbase-mcp-server --log-level=debug --log-sinks=file \
--log-error-retention-backup-count=30 --log-debug-retention-backup-count=0
For more details, see the documentation.
Follow the steps below to use Couchbase MCP server with Claude Desktop MCP client
The MCP server can now be added to Claude Desktop by editing the configuration file. More detailed instructions can be found on the MCP quickstart guide.
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonOpen the configuration file and add the configuration to the mcpServers section.
Restart Claude Desktop to apply the changes.
You can now use the server in Claude Desktop to run queries on the Couchbase cluster using natural language and perform CRUD operations on documents.
Logs
The logs for Claude Desktop can be found in the following locations:
The logs can be used to diagnose connection issues or other problems with your MCP server configuration. For more details, refer to the official documentation.
Follow steps below to use Couchbase MCP server with Cursor:
Install Cursor on your machine.
In Cursor, go to Cursor > Cursor Settings > Tools & Integrations > MCP Tools. Also, checkout the docs on setting up MCP server configuration from Cursor.
Specify the same configuration manually, or use the one-click Install in Cursor link. You may need to add the server configuration under a parent key of mcpServers.
Note: The install link uses placeholder values from the configuration examples above. Update the connection string and credentials after installation.
Save the configuration.
You will see couchbase as an added server in MCP servers list. Refresh to see if server is enabled.
You can now use the Couchbase MCP server in Cursor to query your Couchbase cluster using natural language and perform CRUD operations on documents.
For more details about MCP integration with Cursor, refer to the official Cursor MCP documentation.
Logs
In the bottom panel of Cursor, click on "Output" and select "Cursor MCP" from the dropdown menu to view server logs. This can help diagnose connection issues or other problems with your MCP server configuration.
Follow the steps below to use the Couchbase MCP server with Windsurf Editor.
Install Windsurf Editor on your machine.
In Windsurf Editor, navigate to Command Palette > Windsurf MCP Configuration Panel or Windsurf - Settings > Advanced > Cascade > Model Context Protocol (MCP) Servers. For more details on the configuration, please refer to the official documentation.
Click on Add Server and then Add custom server. On the configuration that opens in the editor, add the Couchbase MCP Server configuration from above.
Save the configuration.
You will see couchbase as an added server in MCP Servers list under Advanced Settings. Refresh to see if server is enabled.
You can now use the Couchbase MCP server in Windsurf Editor to query your Couchbase cluster using natural language and perform CRUD operations on documents.
For more details about MCP integration with Windsurf Editor, refer to the official Windsurf MCP documentation.
Follow the steps below to use the Couchbase MCP server with VS Code.
Install VS Code
Following are a couple of ways to configure the MCP server.
For a Workspace server configuration
For the Global server configuration:
Ctrl+Shift+P or Cmd+Shift+P)Note: VS Code uses servers as the top-level JSON property in mcp.json files to define MCP (Model Context Protocol) servers, while Cursor uses mcpServers for the equivalent configuration. Check the VS Code client configurations for any further changes or details. An example VS Code configuration is provided below.
{
"servers": {
"couchbase": {
"command": "uvx",
"args": ["couchbase-mcp-server"],
"env": {
"CB_CONNECTION_STRING": "couchbases://connection-string",
"CB_USERNAME": "username",
"CB_PASSWORD": "password"
}
}
}
}
Once you save the file, the server starts and a small action list appears with Running|Stop|n Tools|More...
Click on the options from the option list to Start/Stop/manage the server.
You can now use the Couchbase MCP server in VS Code to query your Couchbase cluster using natural language and perform CRUD operations on documents.
Logs:
In the Command Palette (Ctrl+Shift+P or Cmd+Shift+P),
Follow the steps below to use the Couchbase MCP server with JetBrains IDEs
Logs: The log file can be explored at Help > Show Log in Finder (Explorer) > mcp > couchbase
Alongside the default operational server (the one every section above
describes), this distribution ships a second server for
Operational Insights
clusters, using the separate
couchbase-operational-insights
SDK. It is a different product from a regular Couchbase cluster and runs as
an independent process on its own port.
Run it by passing operational-insights as the CLI subcommand (or appending
it as the container's command):
uvx couchbase-mcp-server operational-insights
# or, from source:
uv run src/mcp_server.py operational-insights
# or, via Docker:
docker run --rm -i \
-e CB_OI_CONNECTION_STRING=http://localhost:8095 \
-e CB_OI_USERNAME=Administrator \
-e CB_OI_PASSWORD=password \
couchbase/mcp-server:<version> operational-insights
--connection-string is an HTTP(S) URL, not a couchbase:// connection
string — e.g. http://localhost:8095 for a local Operational Insights
server, or https://<host>:18095 for Capella. This is the single most
common misconfiguration when pointing this server at a cluster.
| CLI Argument | Environment Variable | Description | Default |
|---|---|---|---|
--connection-string | CB_OI_CONNECTION_STRING | Operational Insights endpoint URL (HTTP/HTTPS, not couchbase://) | None |
--username | CB_OI_USERNAME | Operational Insights username | None |
--password | CB_OI_PASSWORD | Operational Insights password | None |
--ca-cert-path | CB_OI_CA_CERT_PATH | Path to server root certificate (PEM), for verifying a self-signed/untrusted server certificate | None |
--client-cert-path | CB_OI_CLIENT_CERT_PATH | Path to the client certificate for mTLS authentication — a PEM cert (paired with --client-key-path) or a PKCS#12 bundle (.p12/.pfx, --client-key-path left unset). Requires an https:// --connection-string; overrides --username/--password when set | None |
--client-key-path | CB_OI_CLIENT_KEY_PATH | Path to the client certificate's private key (PEM). Leave unset when --client-cert-path is a PKCS#12 bundle | None |
--client-cert-password | CB_OI_CLIENT_CERT_PASSWORD | Decryption password for an encrypted client key or PKCS#12 bundle | None |
Every other flag (--read-only-mode, --transport, --host, --port,
--disabled-tools, --confirmation-required-tools, --log-*,
--oauth-*) is identical to the operational server's — see
Additional Configuration for MCP Server —
except the defaults for port (8001, not 8000) and log file
(mcp_server_operational_insights.log, not mcp_server.log), since two
servers cannot share either. OAuth uses the same scope labels
(couchbase-mcp:read / couchbase-mcp:write) as the operational server, so
an existing IdP configuration works for both without changes.
Example MCP client configuration:
{
"mcpServers": {
"couchbase-operational-insights": {
"command": "uvx",
"args": ["couchbase-mcp-server", "operational-insights"],
"env": {
"CB_OI_CONNECTION_STRING": "http://localhost:8095",
"CB_OI_USERNAME": "Administrator",
"CB_OI_PASSWORD": "password"
}
}
}
}
See Operational Insights tools above for the tool list, and the note there about the three tool names shared with the operational server.
Both servers share a single MCP Registry
listing, io.github.couchbase/mcp-server-couchbase, published from
server.json. The listing has a separate package entry for each server (PyPI
and Docker). Each entry passes its subcommand (operational or
operational-insights) and declares only that server's arguments and
environment variables.
The MCP Server can be run in Streamable HTTP transport mode which allows multiple clients to connect to the same server instance via HTTP. Check if your MCP client supports streamable http transport before attempting to connect to MCP server in this mode.
Note: OAuth 2.1 authorization is supported on this transport. See OAuth 2.1 Authorization. Without OAuth configured, the HTTP endpoint is unauthenticated.
By default, the MCP server will run on port 8000 but this can be configured using the --port or CB_MCP_PORT environment variable.
uvx couchbase-mcp-server \
--connection-string='<couchbase_connection_string>' \
--username='<database_username>' \
--password='<database_password>' \
--read-only-mode=true \
--transport=http
The server will be available on http://localhost:8000/mcp. This can be used in MCP clients supporting streamable http transport mode such as Cursor.
{
"mcpServers": {
"couchbase-http": {
"url": "http://localhost:8000/mcp"
}
}
}
There is an option to run the MCP server in Server-Sent Events (SSE) transport mode.
Note: SSE mode has been deprecated by MCP. We have support for Streamable HTTP.
By default, the MCP server will run on port 8000 but this can be configured using the --port or CB_MCP_PORT environment variable.
uvx couchbase-mcp-server \
--connection-string='<couchbase_connection_string>' \
--username='<database_username>' \
--password='<database_password>' \
--read-only-mode=true \
--transport=sse
The server will be available on http://localhost:8000/sse. This can be used in MCP clients supporting SSE transport mode such as Cursor.
{
"mcpServers": {
"couchbase-sse": {
"url": "http://localhost:8000/sse"
}
}
}
When running with --transport=http, the MCP 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 listed in Additional Configuration:
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.CB_MCP_OAUTH_MCP_BASE_URL additionally publishes RFC 9728 Protected Resource Metadata so PRM-aware clients can discover the authorization server.scope/scp claim: couchbase-mcp:read (read tools, including SQL++) and couchbase-mcp:write (write tools: KV mutations, scope/collection management, index management, and FTS 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.uvx couchbase-mcp-server \
--connection-string='<couchbase_connection_string>' \
--username='<database_username>' \
--password='<database_password>' \
--transport=http \
--oauth-jwks-uri='https://auth.example.com/.well-known/jwks.json' \
--oauth-issuer='https://auth.example.com/' \
--oauth-audience='couchbase-mcp-server' \
--oauth-mcp-base-url='<public_base_url_of_this_server>'
For full details, see the documentation.
The MCP server can also be built and run as a Docker container. Prebuilt images can be found on DockerHub or pulled via docker pull docker.io/couchbase/mcp-server:latest.
Alternatively, we are part of the Docker MCP Catalog.
docker build -t mcp/couchbase-src .
docker build --build-arg GIT_COMMIT_HASH=$(git rev-parse HEAD) \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
-t mcp/couchbase-src .
Alternatively, use the provided build script:
# Build with default image name (mcp/couchbase-src)
./build.sh
# Build with custom image name
./build.sh my-custom/image-name
This script automatically:
mcp/couchbase-src)latest, <short-commit>)Verify image labels:
# View git commit hash in image
docker inspect --format='{{index .Config.Labels "org.opencontainers.image.revision"}}' mcp/couchbase-src:latest
# View all metadata labels
docker inspect --format='{{json .Config.Labels}}' mcp/couchbase-src:latest
The MCP server can be run with the environment variables being used to configure the Couchbase settings. The environment variables are the same as described in the Additional Configuration section.
docker run --rm -i \
-e CB_CONNECTION_STRING='<couchbase_connection_string>' \
-e CB_USERNAME='<database_user>' \
-e CB_PASSWORD='<database_password>' \
-e CB_MCP_TRANSPORT='<http|sse|stdio>' \
-e CB_MCP_READ_ONLY_MODE='<true|false>' \
-e CB_MCP_CONFIRMATION_REQUIRED_TOOLS='delete_document_by_id' \
-e CB_MCP_PORT=9001 \
-e CB_MCP_HOST=0.0.0.0 \
-p 9001:9001 \
mcp/couchbase-src
The CB_MCP_PORT and CB_MCP_HOST environment variables are only applicable in the case of HTTP transport modes like http and sse.
The Docker image can be used in stdio transport mode with the following configuration.
{
"mcpServers": {
"couchbase-mcp-docker": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"CB_CONNECTION_STRING=<couchbase_connection_string>",
"-e",
"CB_USERNAME=<database_user>",
"-e",
"CB_PASSWORD=<database_password>",
"mcp/couchbase-src"
]
}
}
}
Notes
couchbase_connection_string value depends on whether the Couchbase server is running on the same host machine, in another Docker container, or on a remote host. If your Couchbase server is running on your host machine, your connection string would likely be of the form couchbase://host.docker.internal. For details refer to the docker documentation.--network=<your_network> option. The network you choose depends on your environment; the default is bridge. For details, refer to network drivers in docker.This product automatically collects usage and performance data (such as product name and version) and browser information (such as IP address) (collectively, "Usage Data"). Couchbase uses Usage Data, along with other data you may provide to Couchbase (such as your user name or email address), to develop and improve our products as well as inform our sales and marketing programs. We do not access or collect any data you store in Couchbase products. We use Usage Data to understand aggregate usage patterns and make our products more useful to you. For more information on how Couchbase collects, protects, and processes information, please refer to the Couchbase Privacy Policy viewable at https://www.couchbase.com/privacy-policy.
uv package manager is properly installed and accessible. You may need to provide absolute path to uv/uvx in the command field in the configuration.uv sync to update the dependencies.We provide high-level MCP integration tests to verify that the server exposes the expected tools and that they can be invoked against a demo Couchbase cluster.
CB_CONNECTION_STRINGCB_USERNAMECB_PASSWORDCB_MCP_TEST_BUCKET (a bucket to probe during the tests)CB_OI_CONNECTION_STRING / CB_OI_USERNAME / CB_OI_PASSWORD.
Those tests skip automatically (not fail) when unset.uv run --extra dev pytest tests/integration -v
What is the Couchbase MCP Server? It's a self-hosted implementation of the Model Context Protocol that lets AI assistants and agents (Claude, Cursor, Windsurf, VS Code Copilot, JetBrains AI Assistant/Junie, and any other MCP client) query and, optionally, modify data in a Couchbase cluster using natural language.
CB_CONNECTION_STRINGCouchbase connection string. Required for connecting to the cluster.
CB_USERNAMECouchbase database username. Required for basic authentication.
CB_PASSWORDsecretCouchbase database password. Required for basic authentication.
CB_CA_CERT_PATHCouchbase CA certificate path. Required for TLS authentication in non Capella clusters.
CB_CLIENT_CERT_PATHCouchbase client certificate path. Required for mTLS authentication.
CB_CLIENT_KEY_PATHCouchbase client key path. Required for mTLS authentication.
CB_MCP_READ_ONLY_MODECouchbase read only mode. Set to true to allow disable write operations across both KV and query. KV write tools are not loaded and SQL++ queries that modify data are blocked. Set to false to allow data modification queries and tools.
CB_MCP_READ_ONLY_QUERY_MODE[Deprecated] Couchbase read only query mode. Set to true to allow only read-only queries. Set to false to allow data modification queries. Use CB_MCP_READ_ONLY_MODE instead.
CB_MCP_TRANSPORTTransport mode for the server (stdio, http or sse). Default is stdio
CB_MCP_HOSTHost to run the MCP server on (default: 127.0.0.1). Used only for HTTP and SSE transport modes.
CB_MCP_PORTPort to run the MCP server on (default: 8000). Used only for HTTP and SSE transport modes.
CB_MCP_DISABLED_TOOLSTools to disable. Accepts comma-separated tool names (e.g., 'tool_1,tool_2') or a file path containing one tool name per line.
CB_MCP_CONFIRMATION_REQUIRED_TOOLSComma-separated tool names that require user confirmation before execution. Also accepts a file path containing one tool name per line. Requires the MCP client to support elicitation.