Couchbase MCP Server - Enable AI agents to connect to and interact with Couchbase clusters.
Couchbase MCP Server is a self-hosted Model Context Protocol (MCP) server that connects AI agents and LLM-powered assistants to data in Couchbase clusters. It supports Couchbase data access whether hosted on Capella or self-managed, enabling MCP clients to interact via MCP tools.
๐ ๏ธ Key Features
Self-hosted MCP server for Couchbase clusters
Enables MCP clients to connect AI agents/assistants to Couchbase data
Works with Couchbase hosted on Capella or self-managed
Topics include couchbase, mcp, model-context-protocol, and nosql
๐ Use Cases
Query and interact with Couchbase data from MCP clients
Integrate with AI assistants such as Claude, Cursor, Windsurf, and VS Code Copilot
โก Developer Benefits
Uses MCP, an open standard for AI assistants to call tools and query external data sources
Suitable for LLM-powered assistants that support MCP clients
โ ๏ธ Limitations
The provided information does not include tool names, counts, authentication, or setup details
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.
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
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_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.
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. 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.
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, and 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 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.
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 (index scans return many more documents than final result)
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.
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.
Configuration
The MCP server can be run either from the prebuilt PyPI package or the source using uv.
Running from PyPI
We publish a pre built PyPI package for the MCP server.
Server Configuration using Pre built Package for MCP Clients
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 mcpServers object.
Additional Configuration for MCP Server
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, and index management). When enabled, write tools are not loaded.
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
Read-Only Mode Configuration
CB_MCP_READ_ONLY_MODE is the single switch controlling write operations:
When true (default): All write operations (KV, Query, scope/collection management, and 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) are not loaded and will not be available to the LLM, and SQL++ queries that modify data or structure are blocked.
When 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.
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.
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), 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.
Elicitation/Confirmation for Tool Calls
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:
Comma-separated list
File path (one tool name per line, # comments supported)
Example:
bash
# 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:
If the client supports elicitation, the user is prompted to confirm.
If the client does not support elicitation, the tool executes without confirmation for backward compatibility.
You can also check the version of the server using:
bash
uvx couchbase-mcp-server --version
Logging
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.
Rotation size โ 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.
Retention โ 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).
Server-config snapshot โ when the 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.
bash
# 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
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.
On Mac, the configuration file is located at ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows, the configuration file is located at %APPDATA%\Claude\claude_desktop_config.json
Open 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:
MacOS: ~/Library/Logs/Claude
Windows: %APPDATA%\Claude\Logs
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.
Cursor
Follow steps below to use Couchbase MCP server with Cursor:
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.
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.
Windsurf Editor
Follow the steps below to use the Couchbase MCP server with Windsurf Editor.
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.
VS Code
Follow the steps below to use the Couchbase MCP server with VS Code.
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.
Navigate to Settings > Tools > AI Assistant or Junie > MCP Server
Click "+" to add the Couchbase MCP configuration and click Save.
You will see the Couchbase MCP server added to the list of servers. Once you click Apply, the Couchbase MCP server starts and on-hover of status, it shows all the tools available.
You can now use the Couchbase MCP server in JetBrains IDEs to query your Couchbase cluster using natural language and perform CRUD operations on documents.
Logs:
The log file can be explored at Help > Show Log in Finder (Explorer) > mcp > couchbase
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.
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 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, 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.
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.
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.
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)
Run the tests:
bash
uv run pytest tests/ -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
Quick Start for Contributors
bash
# Clone and setup
git clone https://github.com/couchbase/mcp-server-couchbase.git
cd mcp-server-couchbase
# Install with development dependencies
uv sync --extra dev
# Install pre-commit hooks
uv run pre-commit install
# Run linting
./scripts/lint.sh
๐ข 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!
Install
Configuration
Environment variables
CB_CONNECTION_STRING
Couchbase connection string. Required for connecting to the cluster.
CB_USERNAME
Couchbase database username. Required for basic authentication.
CB_PASSWORDsecret
Couchbase database password. Required for basic authentication.
CB_CA_CERT_PATH
Couchbase CA certificate path. Required for TLS authentication in non Capella clusters.
CB_CLIENT_CERT_PATH
Couchbase client certificate path. Required for mTLS authentication.
CB_CLIENT_KEY_PATH
Couchbase client key path. Required for mTLS authentication.
CB_MCP_READ_ONLY_MODE
Couchbase 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_TRANSPORT
Transport mode for the server (stdio, http or sse). Default is stdio
CB_MCP_HOST
Host to run the MCP server on (default: 127.0.0.1). Used only for HTTP and SSE transport modes.
CB_MCP_PORT
Port to run the MCP server on (default: 8000). Used only for HTTP and SSE transport modes.
CB_MCP_DISABLED_TOOLS
Tools 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_TOOLS
Comma-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.
CB_MCP_LOG_LEVEL
Logging level for the MCP server. One of off, debug, info, warning, error. Use 'off' to disable logging entirely. Invalid values fall back to info. Default is info.
CB_MCP_LOG_SINKS
Comma-separated list of log destinations. Allowed values: stderr, file. Include 'file' to write per-level log files; include 'stderr' to write to the console. Default is stderr.
CB_MCP_LOG_FILE
Base path for the per-level log files. One rotating file is written per level (e.g. mcp_server.info.log, mcp_server.error.log). Only used when 'file' is in CB_MCP_LOG_SINKS. Default is mcp_server.log.
CB_MCP_LOG_ROTATION_MAX_SIZE_MB
Global maximum size in MB per-level log file before it rotates, inherited by every level unless overridden by a per-level CB_MCP_LOG_<LEVEL>_ROTATION_MAX_SIZE_MB. A value of 0 is invalid and falls back to the default (1 MB) with a startup warning. Default is 1 (1 MB).
CB_MCP_LOG_MAX_BYTES
[DEPRECATED] Global rotation size in bytes; use CB_MCP_LOG_ROTATION_MAX_SIZE_MB (MB) instead. Still honored for backward compatibility but ignored when CB_MCP_LOG_ROTATION_MAX_SIZE_MB is also set. A value of 0 is invalid and falls back to the default with a startup warning.
CB_MCP_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 it when unset. 0 is invalid and falls back to the inherited global with a startup warning.
CB_MCP_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 it when unset. 0 is invalid and falls back to the inherited global with a startup warning.
CB_MCP_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 it when unset. 0 is invalid and falls back to the inherited global with a startup warning.
CB_MCP_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 it when unset. 0 is invalid and falls back to the inherited global with a startup warning.
CB_MCP_LOG_RETENTION_BACKUP_COUNT
Number of rotated backup files kept per-level log file, excluding the live file. Applies to every level unless overridden per level. Set to 0 to keep only the live file (still capped by the rotation size). Default is 1.
CB_MCP_LOG_ERROR_RETENTION_BACKUP_COUNT
Rotated backups kept for the ERROR log file. Overrides CB_MCP_LOG_RETENTION_BACKUP_COUNT for ERROR; inherits it when unset.
CB_MCP_LOG_WARNING_RETENTION_BACKUP_COUNT
Rotated backups kept for the WARNING log file. Overrides CB_MCP_LOG_RETENTION_BACKUP_COUNT for WARNING; inherits it when unset.
CB_MCP_LOG_INFO_RETENTION_BACKUP_COUNT
Rotated backups kept for the INFO log file. Overrides CB_MCP_LOG_RETENTION_BACKUP_COUNT for INFO; inherits it when unset.
CB_MCP_LOG_DEBUG_RETENTION_BACKUP_COUNT
Rotated backups kept for the DEBUG log file. Overrides CB_MCP_LOG_RETENTION_BACKUP_COUNT for DEBUG; inherits it when unset.
CB_MCP_OAUTH_JWT_JWKS_URI
JWKS endpoint of the identity provider used to verify bearer JWT signatures. Required to enable OAuth, along with CB_MCP_OAUTH_JWT_ISSUER and CB_MCP_OAUTH_JWT_AUDIENCE. Only honored when CB_MCP_TRANSPORT=http.
CB_MCP_OAUTH_JWT_ISSUER
Expected JWT 'iss' claim value. Also advertised as the authorization server in Protected Resource Metadata when CB_MCP_OAUTH_MCP_BASE_URL is set. Required to enable OAuth.
CB_MCP_OAUTH_JWT_AUDIENCE
Expected JWT 'aud' claim value. Required to enable OAuth.
CB_MCP_OAUTH_JWT_ALGORITHM
JWT signing algorithm. One of RS256/384/512, ES256/384/512, PS256/384/512. Default is RS256.
CB_MCP_OAUTH_MCP_BASE_URL
Public base URL of this MCP server. When set, the server publishes RFC 9728 Protected Resource Metadata at <base_url>/.well-known/oauth-protected-resource/mcp so PRM-aware clients can discover the authorization server. Optional.
CB_MCP_OAUTH_SCOPE_READ_LABEL
Override the OAuth scope label the server treats as 'read' access; advertised in PRM and matched against the token's scope/scp claim. Use when your IdP cannot emit the canonical form. Default is couchbase-mcp:read.
CB_MCP_OAUTH_SCOPE_WRITE_LABEL
Override the OAuth scope label the server treats as 'write' access; same semantics as CB_MCP_OAUTH_SCOPE_READ_LABEL. Default is couchbase-mcp:write.