Skip to main content
Glama

query_json_docs

Sort JSON documents by a specified field in the mcp-database-server, enabling organized retrieval of structured data for efficient querying and analysis.

Instructions

Query JSON documents sorted by a field

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sort_fieldYesField to sort results by

Implementation Reference

  • Handler for the query_json_docs tool. Extracts sort_field from arguments, queries the Fireproof database (db.query) sorted descending with limit 10, and returns a JSON string of the document rows.
    case "query_json_docs": {
      const sortField = String(request.params.arguments?.sort_field);
      if (!sortField) {
        throw new Error("Sort field is required");
      }
    
      const results = await db.query(sortField, {
        includeDocs: true,
        descending: true,
        limit: 10
      });
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify(results.rows.map(row => row.doc))
        }]
      };
    }
  • src/index.ts:81-94 (registration)
    Registration of the query_json_docs tool in the ListTools response, defining its name, description, and input schema requiring a 'sort_field' string.
    {
      name: "query_json_docs",
      description: "Query JSON documents sorted by a field",
      inputSchema: {
        type: "object", 
        properties: {
          sort_field: {
            type: "string",
            description: "Field to sort results by"
          }
        },
        required: ["sort_field"]
      }
    }
Behavior2/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 mentions sorting behavior, but doesn't disclose critical traits like whether this is a read-only operation, if it requires authentication, what happens if no documents exist, or how results are returned (e.g., pagination, format). For a query tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence with no wasted words. It's front-loaded with the core action ('query JSON documents'), though it could be more structured by including key details like scope or output. Overall, it's concise but slightly under-specified.

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

Completeness2/5

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

Given the complexity of querying documents and lack of annotations or output schema, the description is incomplete. It doesn't explain what the query returns (e.g., list of documents, counts), error conditions, or dependencies on other tools like 'save_json_doc'. For a tool with no structured behavioral data, this leaves the agent with insufficient context.

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?

Schema description coverage is 100%, with the parameter 'sort_field' fully documented in the schema. The description adds no additional meaning beyond what the schema provides, such as examples of sortable fields or sorting order. Baseline score of 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

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

The description states the action ('query') and resource ('JSON documents'), but is vague about scope and mechanism. It doesn't specify whether this queries all documents, filtered subsets, or specific collections, nor does it distinguish from siblings like 'load_json_doc' (which might retrieve a single document). The purpose is understandable but lacks specificity.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, such as needing existing documents to query, or compare it to siblings like 'load_json_doc' for single-document retrieval. Usage context is implied from the name but not explicitly stated.

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

Related 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/fireproof-storage/mcp-database-server'

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