Skip to main content
Glama

MCP JSON Document Collection Server

by jimpick

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

NameRequiredDescriptionDefault
databaseNameYesdocument database to save to
docYesJSON 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

  • 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}`, } ] } }
  • 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"], }, },

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