UNPKG

lance-mcp

Version:

MCP server for interacting with LanceDB database

40 lines (39 loc) 1.26 kB
import { client } from "../../mongodb/client.js"; import { BaseTool } from "../base/tool.js"; export class ListCollectionsTool extends BaseTool { constructor() { super(...arguments); this.name = "listCollections"; this.description = "List all available collections in the database"; this.inputSchema = { type: "object", properties: { database: { type: "string", description: "Name of the database to use to list collections", }, required: ["database"], }, }; } async execute(_params) { try { const collections = await client.db(_params.database).listCollections().toArray(); return { content: [ { type: "text", text: JSON.stringify(collections.map((c) => ({ name: c.name, type: c.type, })), null, 2), }, ], isError: false, }; } catch (error) { return this.handleError(error); } } }