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"]
      }
    }
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