Skip to content

Commit ca72d69

Browse files
authored
Improve tool description for running SQL++ queries (#82)
1 parent 9e5e0c3 commit ca72d69

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ An [MCP](https://modelcontextprotocol.io/) server implementation of Couchbase th
2121
- Upsert a document by ID to a specified scope and collection
2222
- Delete a document by ID from a specified scope and collection
2323
- Run a [SQL++ query](https://www.couchbase.com/sqlplusplus/) on a specified scope
24+
- 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`)
2425
- 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.
2526
- Get the status of the MCP server
2627
- Check the cluster credentials by connecting to the cluster

src/tools/query.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ def get_schema_for_collection(
3939
def run_sql_plus_plus_query(
4040
ctx: Context, bucket_name: str, scope_name: str, query: str
4141
) -> list[dict[str, Any]]:
42-
"""Run a SQL++ query on a scope and return the results as a list of JSON objects."""
42+
"""Run a SQL++ query on a scope and return the results as a list of JSON objects.
43+
44+
The query will be run on the specified scope in the specified bucket.
45+
The query should use collection names directly without bucket/scope prefixes, as the scope context is automatically set.
46+
47+
Example:
48+
query = "SELECT * FROM users WHERE age > 18"
49+
# Incorrect: "SELECT * FROM bucket.scope.users WHERE age > 18"
50+
"""
4351
cluster = get_cluster_connection(ctx)
4452

4553
bucket = connect_to_bucket(cluster, bucket_name)

0 commit comments

Comments
 (0)