Skip to main content
Glama
jimpick

MCP JSON Document Collection Server

by jimpick

load_json_doc_from_db

Retrieve a JSON document from a database by specifying its unique ID. This tool accesses stored documents for viewing or processing within the MCP JSON Document Collection Server.

Instructions

Load a JSON document by ID from a document database

Input Schema

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

Implementation Reference

  • Handler for the 'load_json_doc_from_db' tool. Parses arguments using the schema, retrieves or initializes the Fireproof database, fetches the document by ID using db.get(), logs it, and returns the document as a JSON string in the tool response.
    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 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)
    Tool registration in the ListToolsResponse. Defines name, description, and inputSchema (hardcoded JSON schema equivalent to the Zod schema, with id required).
    {
      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"],
      },

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