Skip to main content
Glama

MongoDB MCP Server for LLMs

by vivek1612
MIT License
109
  • Apple
delete-one.ts1.25 kB
import { db } from "../../mongodb/client.js"; import { BaseTool, ToolParams } from "../base/tool.js"; interface DeleteOneParams extends ToolParams { collection: string; filter: Record<string, unknown>; [key: string]: unknown; } export class DeleteOneTool extends BaseTool<DeleteOneParams> { name = "deleteOne"; description = "Delete a single document from a collection"; inputSchema = { type: "object" as const, properties: { collection: { type: "string", description: "Name of the collection", }, filter: { type: "object", description: "Filter to identify document", }, }, required: ["collection", "filter"], }; async execute(params: DeleteOneParams) { try { const collection = this.validateCollection(params.collection); const filter = this.validateObject(params.filter, "Filter"); const result = await db.collection(collection).deleteOne(filter); return { content: [ { type: "text" as const, text: JSON.stringify({ deleted: result.deletedCount }, null, 2), }, ], isError: false, }; } catch (error) { return this.handleError(error); } } }

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/vivek1612/mongodb-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server