Skip to main content
Glama

MongoDB MCP Server for LLMs

by vivek1612
MIT License
109
  • Apple
drop-index.ts1.3 kB
import { db } from "../../mongodb/client.js"; import { BaseTool, ToolParams } from "../base/tool.js"; interface DropIndexParams extends ToolParams { collection: string; indexName: string; [key: string]: unknown; } export class DropIndexTool extends BaseTool<DropIndexParams> { name = "dropIndex"; description = "Drop an index from a collection"; inputSchema = { type: "object" as const, properties: { collection: { type: "string", description: "Name of the collection", }, indexName: { type: "string", description: "Name of the index to drop", }, }, required: ["collection", "indexName"], }; async execute(params: DropIndexParams) { try { const collection = this.validateCollection(params.collection); if (typeof params.indexName !== "string") { return this.handleError(new Error("Index name must be a string")); } const result = await db .collection(collection) .dropIndex(params.indexName); return { content: [ { type: "text" as const, text: JSON.stringify(result, 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