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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of document to load | |
| databaseName | No | name of document database to load from |
Implementation Reference
- src/index.ts:434-458 (handler)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), }, ], }; }
- src/index.ts:83-86 (schema)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"], },