Skip to main content
Glama
jimpick

MCP JSON Document Collection Server

by jimpick

load_json_doc_from_db

Retrieve a JSON document by specifying its ID and the database name for efficient data access and management in the MCP environment.

Instructions

Load a JSON document by ID from a document database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNameNoname of document database to load from
idYesID of document to load

Implementation Reference

  • Handler function for the 'load_json_doc_from_db' tool. It validates input arguments using LoadJsonDocFromDbArgsSchema, ensures the database exists (creating it if necessary), retrieves the document by ID using db.get(), logs it, and returns the document as a JSON string in the tool response format.
    case "load_json_doc_from_db": { const parsed = LoadJsonDocFromDbArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for load_json_doc_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 doc = await db.get(parsed.data.id); console.error("doc", doc); return { content: [ { type: "text", text: JSON.stringify(doc), }, ], }; }
  • Zod schema defining the input arguments for the 'load_json_doc_from_db' tool: databaseName (string) and id (string). Used for validation in the handler.
    const LoadJsonDocFromDbArgsSchema = z.object({ databaseName: z.string(), id: z.string(), });
  • src/index.ts:153-170 (registration)
    Registration of the 'load_json_doc_from_db' tool in the listTools response. Includes name, description, and a hardcoded JSON schema for input (noted comment for Zod conversion).
    { name: "load_json_doc_from_db", description: "Load a JSON document by ID from a document database", inputSchema: { type: "object", properties: { id: { type: "string", description: "ID of document to load", }, databaseName: { type: "string", description: "name of document database to load from", }, }, // properties: zodToJsonSchema(LoadJsonDocFromDbArgsSchema), required: ["id"], },

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