Couchbase MCP Server
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.
[][cursor-install-basic]
For full documentation, visit docs.couchbase.com/mcp-server.
Table of Contents
Why Couchbase MCP Server
- Safe by default — write operations (document upserts/inserts/deletes and data-modifying SQL++ queries) are blocked unless you explicitly set
CB_MCP_READ_ONLY_MODE=false, and individual tools can be disabled or gated behind user confirmation.
- Works with Capella and self-managed clusters — the same configuration connects to Couchbase Capella (fully managed) or a self-hosted Couchbase Server cluster.
- RBAC-aware — tool disabling is a convenience layer for guiding LLM behavior; the underlying Couchbase user's role-based access control remains the authoritative security boundary.
- Production transports — run over STDIO for local desktop clients, or Streamable HTTP with optional OAuth 2.1 (JWT/JWKS, provider-agnostic — Auth0, Okta, Keycloak, Entra, Cognito, etc.) for shared/remote deployments.
- Any MCP client — tested with Claude Desktop, Cursor, Windsurf, VS Code, and JetBrains AI Assistant/Junie; works with any client implementing the MCP specification.
Example Prompts
Once the server is connected, you can talk to your Couchbase cluster in natural language through your AI assistant. For example:
- "What buckets, scopes, and collections do I have in this cluster, and what's the schema of the
orders collection?"
- "Run a SQL++ query to find the 10 most recent documents in the
users collection where status = 'active'."
- "What are the 5 slowest queries on this cluster in the last hour, and are any of them missing a covering index?"
- "Check whether this cluster is healthy and tell me which services are running."
- "Insert a new document into the
products collection with these fields: ..." (requires CB_MCP_READ_ONLY_MODE=false)
Features/Tools
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.
Cluster setup & health tools
| 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_client_connectivity_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. |
get_bucket_config | Get a bucket's configuration and live state — RAM quota, eviction policy, replica count, durability level, storage backend, conflict-resolution type, auto-compaction settings, and basic stats — via the Management REST API's bucket endpoint. Returns the raw bucket object unchanged; omit bucket_name to get every bucket at once. Requires the Read-Only Admin (ro_admin) role. Self-managed Couchbase Server 7.6+ only — not available on Capella. |
get_cluster_system_events | Get the cluster's system event log — configuration changes, failovers, rebalances and service restarts with timestamps — via the Management REST API's /events endpoint. Correlates a symptom with what changed and when. Returns events oldest-first with a summary of counts and time range; windowed with since_time and bounded (default 50 events) rather than returning the endpoint's 250. Requires the Full Admin or Cluster 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. |
Data model & schema discovery tools
| 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. |
Document KV operations tools
| 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. |
Query and indexing tools
| Tool Name | Description |
|---|
list_indexes | List all indexes in the cluster with their definitions, with optional filtering by bucket, scope, collection and index name. Each entry includes is_vector (and, when true, vector_type: hyperscale or composite). Set return_raw_index_stats=true to return the unprocessed index information. |
get_index_stats | Get per-index statistics (size, fragmentation, scan traffic, indexing lag) from the Index Service, per node. Names which index is responsible for disk or memory pressure, and identifies unused indexes. Self-managed Couchbase Server 7.6+ only — not available on Capella. |
get_index_advisor_recommendations | Get index recommendations from Couchbase Index Advisor for a given SQL++ query to optimize query performance |
create_index | Deprecated — use create_query_index instead. Create a scalar (non-vector) GSI secondary index on a collection. Deferred by default — call build_index afterward to build it. Kept for backward compatibility, removed in a future 2.0. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
create_query_index | Create a GSI index — scalar, Hyperscale vector, or Composite vector — via index_type, all through raw SQL++ (neither vector shape has an SDK management API). similarity and dimension are required for vector types, with no default. Deferred by default — call build_index afterward. 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. |
Full-text search (FTS) tools
Requires Couchbase Server 7.6+ and the Search service. Vector search querying is not supported by these tools (see Vector search tools below) — a vector field mapping in upsert_search_index is unaffected by this and already works.
| Tool Name | Description |
|---|
list_search_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_search_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_search | 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_search_index | Create or update a Search (FTS) index definition (mappings, analyzers, plan params) — including a vector field mapping (type: "vector", with dims/similarity; note FTS's similarity values differ from GSI's). 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_search_index_definition first and pass its uuid back to avoid clobbering concurrent changes. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
drop_search_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_search_indexes first. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
Vector search tools
Both tools embed query text using the model configured via Embedding Provider Configuration — the caller passes plain text, never a raw vector. run_vector_query targets Couchbase Server 8.0+'s GSI vector indexes (Composite Vector Index / Hyperscale Vector Index) via SQL++; run_vector_search targets the Search service's vector search on Couchbase Server 7.6+. Available on both self-managed Couchbase Server and Capella.
| Tool Name | Description |
|---|
run_vector_query | Embed a query and run a vector similarity search against a GSI vector index (Couchbase Server 8.0+), via SQL++'s APPROX_VECTOR_DISTANCE(). Unlike Search-service vector search, GSI selects the index automatically from the vector field referenced in the query — there is no index_name parameter. Returns full documents (or select_fields, if given); supports an optional raw SQL++ where prefilter and Hyperscale Vector Index tuning (num_probes/rerank/top_n_scan). |
run_vector_search | Run the Search service's vector search (Couchbase Server 7.6+) against a named Search index. Two independent, combinable options each take the same raw FTS query JSON body run_search accepts: scalar_query makes this a genuinely hybrid search (relevance-scored full-text matching and vector similarity both contribute to ranking), while prefilter narrows which documents the vector search is even allowed to consider as candidates before it runs — the Search-service equivalent of run_vector_query's where prefilter. Returns index-stored fields per hit, same as run_search (not full documents — follow up with get_document_by_id for those). |
Query performance analysis tools
| 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 (scans — secondary index, primary index, or sequential — return many more documents than final result) |
Query service health tools
These reach the Query service's own N1QL Admin REST API, distinct from the SQL++ system-catalog-based tools above — they report the query engine's health directly, per node, and include the only remediation action in this group. Self-managed Couchbase Server 7.6+ only — not available on Capella.
| Tool Name | Description |
|---|
get_cluster_query_vitals | Get query-engine health (request rate, active/queued request counts, memory, GC, uptime) from every query-service node, via the Query service's /admin/vitals endpoint. Distinguishes "the workload is heavy" from "the query engine itself is stressed." Requires at minimum the Read-Only Admin (ro_admin) role. |
get_active_queries | Get all queries executing right now, merged across every query-service node, via the /admin/active_requests endpoint — elapsed time, statement, client, state. Requires at minimum the Read-Only Admin (ro_admin) role. |
delete_active_query | Cancel an in-flight query by its request ID via DELETE /admin/active_requests/{request_id}, trying every query node in turn. Requires the Full Admin or Cluster Admin role. Disabled by default when CB_MCP_READ_ONLY_MODE=true. |
Operational Insights tools
Registered by the separate operational-insights server (see
Operational Insights Server below), not the
default operational one.
Every tool name below is prefixed with operational_insights_ (get_server_configuration_status
excepted) so none can collide with the operational server's tool names, even
if a single MCP client registers both servers at once.
| 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. |
operational_insights_get_databases_in_cluster | List all databases in the Operational Insights cluster. |
operational_insights_get_scopes_in_database | List all scopes in a database. |
operational_insights_get_collections_in_scope | List all collections (datasets) in a scope. |
operational_insights_get_schema_for_collection | Infer the JSON schema of a collection by sampling documents. |
operational_insights_list_indexes | List secondary indexes via the System.Metadata.Index catalog (the SDK has no index manager). |
operational_insights_run_query_sync | Run a SQL++ statement (SELECT, DML, or DDL) and return its result rows, up to CB_MCP_OPERATIONAL_INSIGHTS_QUERY_RESULT_MAX_SIZE when that is set (unset means no limit); a larger result is cut short and reported with truncated: true. Pass copy_to_link, copy_to_bucket and copy_to_path to export the rows to object storage instead of returning them (see Exporting large results). Enforces read-only mode server-side via QueryOptions(readonly=True) — there is no client-side SQL++ parser here. |
operational_insights_explain_query | Generate the query plan for a SQL++ statement via EXPLAIN, without executing it. |
operational_insights_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. |
operational_insights_run_query_async | Start a SQL++ statement without waiting for it to finish, returning a query_handle token. Accepts the same copy_to_* export arguments as operational_insights_run_query_sync, and is the better choice for a large export since it does not hold the request open for the upload. Same read-only enforcement as operational_insights_run_query_sync. |
operational_insights_get_async_query_results | Check whether an async query has finished and, if so, return its rows (subject to the same CB_MCP_OPERATIONAL_INSIGHTS_QUERY_RESULT_MAX_SIZE budget, reported via truncated). For an exporting query it reports completion and names the destination instead of returning rows. Doubles as the status check — call again later if not yet ready. |
operational_insights_discard_async_query_results | Free a finished async query's result buffers on the server. Normal cleanup step after operational_insights_get_async_query_results. |
operational_insights_cancel_async_query | Stop an async query that is still running. Available in read-only mode: cancelling releases resources the caller allocated and does not modify stored data. 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: operational_insights_run_query_async returns a query_handle,
operational_insights_get_async_query_results is polled until it reports readiness (and returns
the rows), then either operational_insights_discard_async_query_results frees the results or,
for a query still running, operational_insights_cancel_async_query stops it.
Prerequisites
- Python 3.10 or higher.
- A running Couchbase cluster. The easiest way to get started is to use Capella free tier, which is fully managed version of Couchbase server. You can follow instructions to import one of the sample datasets or import your own.
- uv installed to run the server.
- An MCP client such as Claude Desktop installed to connect the server to Claude. The instructions are provided for Claude Desktop and Cursor. Other MCP clients could be used as well.
Operational Insights Server
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_OPERATIONAL_INSIGHTS_CONNECTION_STRING=http://localhost:8095 \
-e CB_OPERATIONAL_INSIGHTS_USERNAME=Administrator \
-e CB_OPERATIONAL_INSIGHTS_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_OPERATIONAL_INSIGHTS_CONNECTION_STRING | Operational Insights endpoint URL (HTTP/HTTPS, not couchbase://) | None |
--username | CB_OPERATIONAL_INSIGHTS_USERNAME | Operational Insights username | None |
--password | CB_OPERATIONAL_INSIGHTS_PASSWORD | Operational Insights password | None |
--ca-cert-path | CB_OPERATIONAL_INSIGHTS_CA_CERT_PATH | Path to server root certificate (PEM), for verifying a self-signed/untrusted server certificate | None |
--client-cert-path | CB_OPERATIONAL_INSIGHTS_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_OPERATIONAL_INSIGHTS_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_OPERATIONAL_INSIGHTS_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_OPERATIONAL_INSIGHTS_CONNECTION_STRING": "http://localhost:8095",
"CB_OPERATIONAL_INSIGHTS_USERNAME": "Administrator",
"CB_OPERATIONAL_INSIGHTS_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.
Exporting large results (Operational Insights)
A query whose result exceeds CB_MCP_OPERATIONAL_INSIGHTS_QUERY_RESULT_MAX_SIZE (when that limit is set) comes back
truncated, which is the right default for a tool whose output is read by an
LLM — but sometimes the full data is what you need. operational_insights_run_query_sync and
operational_insights_run_query_async can write the rows to external object storage instead of
returning them, so the size of the result stops mattering.
Pass all three destination arguments:
| Argument | Description |
|---|
copy_to_link | Name of an existing external link, created with CREATE LINK ... TYPE S3. Required. |
copy_to_bucket | Destination bucket in the external store. Required. |
copy_to_path | Path prefix within that bucket, e.g. exports/run1. Required. |
copy_to_format | json (default) or parquet. |
The statement is wrapped in COPY ... TO and the tool returns a confirmation
with no rows:
{
"success": true,
"exported": true,
"destination": {
"link": "s3Link",
"bucket": "my-exports",
"path": "exports/run1",
"format": "json"
},
"message": "Results were written to my-exports/exports/run1 as json. ..."
}
Notes:
- All three of link, bucket and path are required. A partial destination is
rejected rather than quietly running the query and returning rows, which
would write nothing and look like success.
operational_insights_run_query_sync waits for the whole upload before returning, so the
call takes as long as the copy does. For a large export prefer
operational_insights_run_query_async, which returns a query_handle as soon as the query is
submitted; operational_insights_get_async_query_results then reports completion and names the
destination rather than returning rows.
- Exports are blocked in read-only mode.
COPY ... TO writes data to
external storage, so it requires CB_MCP_READ_ONLY_MODE=false (or a token
carrying couchbase-mcp:write), even though the Operational Insights server
itself classifies the statement as read-only.
csv is not offered: the server requires a TYPE(...) clause naming the
output schema for CSV, which cannot be inferred from an arbitrary SELECT.
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.
Streamable HTTP Transport Mode
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.
Usage
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.
Multiple Workers
One server process uses at most about one CPU core. To use more cores, run several worker processes behind the same host and port:
uvx couchbase-mcp-server \
--connection-string='<couchbase_connection_string>' \
--username='<database_username>' \
--password='<database_password>' \
--transport=http \
--workers=4
A good starting point is the number of CPU cores available to the server. With more than one worker:
- The
http transport is required.
- The server runs in stateless HTTP mode, because a client's requests can reach different workers. You can also set
--stateless-http=true on a single worker, for example when several replicas sit behind a load balancer without sticky sessions.
--confirmation-required-tools cannot be used, since confirmation needs a session (see Elicitation/Confirmation for Tool Calls).
- Every process writes its own log files, named with the host and process id, for example
mcp_server.<host>.<pid>.info.log: one set for the supervisor that starts the workers, and one per worker. A restarted worker starts a new set of files.
- The Operational Insights server supports only one worker, because its async query handles are held in process memory.
Health Check
In HTTP mode the server also answers GET /health (for example http://localhost:8000/health) with {"status": "ok", "server": "operational"}. Use it for container liveness probes and load-balancer health checks:
- It reports that the server process is up and serving HTTP. It does not connect to the cluster, so a cluster outage does not make healthy containers restart.
- It needs no authentication, even when OAuth is enabled; it returns nothing beyond the server name.
- It is served by every worker when running with
--workers.
MCP Client Configuration
{
"mcpServers": {
"couchbase-http": {
"url": "http://localhost:8000/mcp"
}
}
}
SSE Transport Mode
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.
SSE: Usage
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.
SSE: MCP Client Configuration
{
"mcpServers": {
"couchbase-sse": {
"url": "http://localhost:8000/sse"
}
}
}
OAuth 2.1 Authorization
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:
- 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, 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.
Docker Image
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.
Building Image
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:
- Accepts an optional image name parameter (defaults to
mcp/couchbase-src)
- Generates git commit hash and build timestamp
- Creates multiple useful tags (
latest, <short-commit>)
- Shows build information and results
- Uses the same arguments as CI/CD builds
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
Running
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.
Independent Docker Container
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.
Docker: MCP Client Configuration
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
- The
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.
- You can specify the container's networking using the
--network=<your_network> option. The network you choose depends on your environment; the default is bridge. For details, refer to network drivers in docker.
Risks Associated with LLMs
- The use of large language models and similar technology involves risks, including the potential for inaccurate or harmful outputs.
- Couchbase does not review or evaluate the quality or accuracy of such outputs, and such outputs may not reflect Couchbase's views.
- You are solely responsible for determining whether to use large language models and related technology, and for complying with any license terms, terms of use, and your organization's policies governing your use of the same.
Usage Data Collection
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.
Troubleshooting Tips
- Ensure the path to your MCP server repository is correct in the configuration if running from source.
- Verify that your Couchbase connection string, database username, password or the path to the certificates are correct.
- If using Couchbase Capella, ensure that the cluster is accessible from the machine where the MCP server is running.
- Check that the database user has proper permissions to access at least one bucket.
- Confirm that the
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.
- Check the logs for any errors or warnings that may indicate issues with the MCP server. The location of the logs depend on your MCP client.
- If you are observing issues running your MCP server from source after updating your local MCP server repository, try running
uv sync to update the dependencies.
Integration testing
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.
- Export demo cluster credentials:
CB_CONNECTION_STRING
CB_USERNAME
CB_PASSWORD
- Optional:
CB_MCP_TEST_BUCKET (a bucket to probe during the tests)
- Optional, for the Operational Insights server's
own tests:
CB_OPERATIONAL_INSIGHTS_CONNECTION_STRING / CB_OPERATIONAL_INSIGHTS_USERNAME / CB_OPERATIONAL_INSIGHTS_PASSWORD.
Those tests skip automatically (not fail) when unset.
- Run the tests:
uv run --extra dev pytest tests/integration -v
FAQ
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.
How do I connect Claude Desktop to Couchbase? Install the server with uvx couchbase-mcp-server (or run it from source or Docker), then add its configuration to Claude Desktop's claude_desktop_config.json as shown in Configuration. Restart Claude Desktop and it will pick up the new tools.
Can I use this with Couchbase Capella? Yes. The same CB_CONNECTION_STRING/CB_USERNAME/CB_PASSWORD (or mTLS certificate) configuration works for both Couchbase Capella and self-managed Couchbase Server clusters.
Is it safe to let an AI agent write to my database? By default, CB_MCP_READ_ONLY_MODE is true, so all write operations — document upserts/inserts/replaces/deletes and data-modifying SQL++ statements — are disabled and the write tools aren't even loaded. You can also disable individual tools (see Disabling Tools) or require explicit user confirmation before specific tools run (see Elicitation/Confirmation). Tool-level controls guide LLM behavior; your Couchbase user's RBAC permissions remain the real security boundary.
Can I run natural-language queries against my data without writing SQL++ myself? Yes — ask your AI assistant a question in plain English (e.g. "show me the 10 most recent orders over $100") and it can translate that into a SQL++ query using the run_sql_plus_plus_query tool. You can also ask the assistant to explain_sql_plus_plus_query a query or ask the index advisor for recommendations.
What's the difference between STDIO, Streamable HTTP, and SSE transport? STDIO is for a single local MCP client (e.g. Claude Desktop) launching the server as a subprocess. Streamable HTTP lets multiple clients share one running server instance over HTTP, and supports OAuth 2.1. SSE is the older HTTP transport, now deprecated by the MCP spec in favor of Streamable HTTP — see Streamable HTTP Transport Mode.
Is this officially supported by Couchbase? This project is Couchbase community-maintained — see Support Policy. Enterprise support is available separately through Couchbase AI Data Plane.
Contributing
We welcome contributions from the community! Whether you want to fix bugs, add features, or improve documentation, your help is appreciated.
If you need help, have found a bug, or want to contribute improvements, the best place to do that is right here — by opening a GitHub issue.
For Developers
If you're interested in contributing code or setting up a development environment:
📖 See CONTRIBUTING.md for comprehensive developer setup instructions, including:
- Development environment setup with
uv
- Code linting and formatting with Ruff
- Pre-commit hooks installation
- Project structure overview
- Development workflow and practices
📢 Support Policy
We truly appreciate your interest in this project!
This project is Couchbase community-maintained, which means it's not officially supported by our support team. However, our engineers are actively monitoring and maintaining this repo and will try to resolve issues on a best-effort basis.
Our support portal is unable to assist with requests related to this project, so we kindly ask that all inquiries stay within GitHub.
Your collaboration helps us all move forward together — thank you!