Skip to main content
Glama
jimpick

MCP JSON Document Collection Server

by jimpick

query_json_docs_from_db

Query and retrieve JSON documents from a Fireproof database, sorted by a specified field or by _id if none is provided, enabling structured data access and organization.

Instructions

Query JSON documents sorted by a field from a document database. If no sortField is provided, use the _id field.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNameYes
sortFieldYes

Implementation Reference

  • Handler function for the query_json_docs_from_db tool. Parses arguments using the schema, ensures the database exists, queries the database sorted by the specified field in descending order including documents, and returns the JSON documents as a string.
    case "query_json_docs_from_db": { const parsed = QueryJsonDocsFromDbArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for query_json_docs_from_db: ${parsed.error}`); } const dbName = parsed.data.databaseName; if (!dbs[dbName]) { const newDb = fireproof(dbName); dbs[dbName] = { db: newDb }; } const db = dbs[dbName].db; const results = await db.query(parsed.data.sortField, { includeDocs: true, descending: true, }); return { content: [ { type: "text", text: JSON.stringify(results.rows.map((row) => row.doc)), }, ], }; }
  • Zod schema defining input arguments for query_json_docs_from_db: databaseName (string) and sortField (string).
    const QueryJsonDocsFromDbArgsSchema = z.object({ databaseName: z.string(), sortField: z.string(), });
  • src/index.ts:146-152 (registration)
    Registration of the query_json_docs_from_db tool in the listTools response, including name, description, input schema converted from Zod, and required fields.
    { name: "query_json_docs_from_db", description: "Query JSON documents sorted by a field from a document database. " + "If no sortField is provided, use the _id field.", inputSchema: zodToJsonSchema(QueryJsonDocsFromDbArgsSchema) as ToolInput, required: ["sortField"], },

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/jimpick/mcp-json-db-collection-server'

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