From f50e64985bcf69230653008d6667bc5d93e1c432 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Thu, 13 Nov 2025 15:40:25 +0100 Subject: [PATCH 1/2] Update README and query.py to clarify SQL++ query usage and scoping --- README.md | 1 + src/tools/query.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c1b6bb..c74ced1 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ An [MCP](https://modelcontextprotocol.io/) server implementation of Couchbase th - Upsert a document by ID to a specified scope and collection - Delete a document by ID from a specified scope and collection - Run a [SQL++ query](https://www.couchbase.com/sqlplusplus/) on a specified scope + - Queries are automatically scoped to the specified bucket and scope, so use collection names directly (e.g., `SELECT * FROM users` not `SELECT * FROM bucket.scope.users`) - There is an option in the MCP server, `CB_MCP_READ_ONLY_QUERY_MODE` that is set to true by default to disable running SQL++ queries that change the data or the underlying collection structure. Note that the documents can still be updated by ID. - Get the status of the MCP server - Check the cluster credentials by connecting to the cluster diff --git a/src/tools/query.py b/src/tools/query.py index d6a44d7..fa6781d 100644 --- a/src/tools/query.py +++ b/src/tools/query.py @@ -39,7 +39,15 @@ def get_schema_for_collection( def run_sql_plus_plus_query( ctx: Context, bucket_name: str, scope_name: str, query: str ) -> list[dict[str, Any]]: - """Run a SQL++ query on a scope and return the results as a list of JSON objects.""" + """Run a SQL++ query on a scope and return the results as a list of JSON objects. + + The query will be run on the specified scope in the specified bucket. + The query should use collection names directly without bucket/scope prefixes, as the scope context is automatically set. + + Example: + query = "SELECT * FROM users WHERE age > 18" + # Not: "SELECT * FROM bucket.scope.users WHERE age > 18" + """ cluster = get_cluster_connection(ctx) bucket = connect_to_bucket(cluster, bucket_name) From a9e5e359c146d457a23a00915fcd2c0de857baab Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Thu, 13 Nov 2025 15:48:11 +0100 Subject: [PATCH 2/2] Clarify SQL++ query usage in README and query.py documentation --- README.md | 2 +- src/tools/query.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c74ced1..117c434 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ An [MCP](https://modelcontextprotocol.io/) server implementation of Couchbase th - Upsert a document by ID to a specified scope and collection - Delete a document by ID from a specified scope and collection - Run a [SQL++ query](https://www.couchbase.com/sqlplusplus/) on a specified scope - - Queries are automatically scoped to the specified bucket and scope, so use collection names directly (e.g., `SELECT * FROM users` not `SELECT * FROM bucket.scope.users`) + - Queries are automatically scoped to the specified bucket and scope, so use collection names directly (e.g., use `SELECT * FROM users` instead of `SELECT * FROM bucket.scope.users`) - There is an option in the MCP server, `CB_MCP_READ_ONLY_QUERY_MODE` that is set to true by default to disable running SQL++ queries that change the data or the underlying collection structure. Note that the documents can still be updated by ID. - Get the status of the MCP server - Check the cluster credentials by connecting to the cluster diff --git a/src/tools/query.py b/src/tools/query.py index fa6781d..32bb89e 100644 --- a/src/tools/query.py +++ b/src/tools/query.py @@ -46,7 +46,7 @@ def run_sql_plus_plus_query( Example: query = "SELECT * FROM users WHERE age > 18" - # Not: "SELECT * FROM bucket.scope.users WHERE age > 18" + # Incorrect: "SELECT * FROM bucket.scope.users WHERE age > 18" """ cluster = get_cluster_connection(ctx)