save_json_doc_to_db
Store JSON documents in specified databases using MCP JSON Document Collection Server, enabling efficient document management and organization.
Instructions
Save a JSON document to a document database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| databaseName | Yes | document database to save to | |
| doc | Yes | JSON document to save |
Input Schema (JSON Schema)
{
"properties": {
"databaseName": {
"description": "document database to save to",
"type": "string"
},
"doc": {
"description": "JSON document to save",
"type": "object"
}
},
"required": [
"doc",
"databaseName"
],
"type": "object"
}
Implementation Reference
- src/index.ts:375-404 (handler)Handler for the 'save_json_doc_to_db' tool. Validates input using SaveJsonDocToDbArgsSchema, retrieves or creates the Fireproof database, saves the JSON document with a created timestamp, and returns the document ID.case "save_json_doc_to_db": { const parsed = SaveJsonDocToDbArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for save_json_doc_to_db: ${parsed.error}`); } const doc = request.params.arguments?.doc; if (!doc) { throw new Error("Document is required"); } const dbName = parsed.data.databaseName; if (!dbs[dbName]) { const newDb = fireproof(dbName); dbs[dbName] = { db: newDb }; } const db = dbs[dbName].db; const response = await db.put({ ...doc, created: Date.now(), }); return { content: [ { type: "text", text: `Saved document with ID: ${response.id} to database: ${dbName}`, } ] } }
- src/index.ts:73-76 (schema)Zod schema defining the input arguments for the save_json_doc_to_db tool: databaseName (string) and doc (object).const SaveJsonDocToDbArgsSchema = z.object({ databaseName: z.string(), doc: z.object({}) });
- src/index.ts:128-145 (registration)Registration of the 'save_json_doc_to_db' tool in the ListTools response, providing name, description, and JSON input schema.{ name: "save_json_doc_to_db", description: "Save a JSON document to a document database", inputSchema: { type: "object", properties: { doc: { type: "object", description: "JSON document to save", }, databaseName: { type: "string", description: "document database to save to", }, }, required: ["doc", "databaseName"], }, },