Skip to main content
Glama

get_schema_for_collection

Retrieve the schema structure of a Couchbase collection by analyzing its data with an INFER query, returning field names and data types.

Instructions

Get the schema for a collection in the specified scope. Returns a dictionary with the collection name and the schema returned by running INFER query on the Couchbase collection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes
scope_nameYes
collection_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function implementing the get_schema_for_collection tool. It runs an 'INFER' SQL++ query on the specified bucket.scope.collection to retrieve and return the schema information.
    def get_schema_for_collection(
        ctx: Context, bucket_name: str, scope_name: str, collection_name: str
    ) -> dict[str, Any]:
        """Get the schema for a collection in the specified scope.
        Returns a dictionary with the collection name and the schema returned by running INFER query on the Couchbase collection.
        """
        schema = {"collection_name": collection_name, "schema": []}
        try:
            query = f"INFER `{collection_name}`"
            result = run_sql_plus_plus_query(ctx, bucket_name, scope_name, query)
            # Result is a list of list of schemas. We convert it to a list of schemas.
            if result:
                schema["schema"] = result[0]
        except Exception as e:
            logger.error(f"Error getting schema: {e}")
            raise
        return schema
  • Registers the get_schema_for_collection tool (along with others from ALL_TOOLS) with the FastMCP server instance.
    for tool in ALL_TOOLS:
        mcp.add_tool(tool)
  • Includes get_schema_for_collection in the ALL_TOOLS list used for server registration.
    get_schema_for_collection,
  • Imports the get_schema_for_collection handler from query.py for exposure via __init__.
    from .query import (
        get_longest_running_queries,
        get_most_frequent_queries,
        get_queries_not_selective,
        get_queries_not_using_covering_index,
        get_queries_using_primary_index,
        get_queries_with_large_result_count,
        get_queries_with_largest_response_sizes,
        get_schema_for_collection,
        run_sql_plus_plus_query,
    )
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool 'Returns a dictionary with the collection name and the schema returned by running INFER query on the Couchbase collection,' which adds useful behavioral context about the return format and underlying method (INFER query). However, it lacks details on error handling, permissions, rate limits, or whether it's read-only (implied but not stated). The description doesn't contradict annotations (none exist).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences. The first sentence states the purpose, and the second adds behavioral context about the return value. There's no fluff, and it's front-loaded with the core function. It could be slightly more structured (e.g., bullet points), but it's efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 required parameters, no annotations, but has an output schema), the description is reasonably complete. It explains what the tool does and the return format, and the output schema will handle return values. However, it lacks usage guidelines and full parameter semantics, leaving some gaps for an agent to infer correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It mentions 'a collection in the specified scope,' implying parameters for bucket, scope, and collection, but doesn't explain what these parameters mean (e.g., bucket_name is a Couchbase bucket). The description adds minimal semantics beyond the schema's titles, failing to fully address the coverage gap. With 0% coverage, a baseline of 3 is generous here.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get the schema for a collection in the specified scope.' It specifies the verb ('Get') and resource ('schema for a collection'), and distinguishes it from siblings like get_collections_in_scope (which lists collections) or get_scopes_and_collections_in_bucket (which lists scopes and collections). However, it doesn't explicitly differentiate from other schema-related tools (none exist in siblings), so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid bucket/scope/collection), compare it to similar tools (e.g., if you want schema vs. data), or specify use cases (e.g., for data validation or query planning). This leaves the agent with minimal context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Couchbase-Ecosystem/mcp-server-couchbase'

If you have feedback or need assistance with the MCP directory API, please join our Discord server