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
| Name | Required | Description | Default |
|---|---|---|---|
| sort_field | Yes | Field to sort results by |
Input Schema (JSON Schema)
{
"properties": {
"sort_field": {
"description": "Field to sort results by",
"type": "string"
}
},
"required": [
"sort_field"
],
"type": "object"
}
Implementation Reference
- src/index.ts:151-169 (handler)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"] } }