UNPKG

lance-mcp

Version:

MCP server for interacting with LanceDB database

41 lines (40 loc) 1.29 kB
import { chunksVectorStore } from "../../lancedb/client.js"; import { BaseTool } from "../base/tool.js"; export class SearchTool extends BaseTool { constructor() { super(...arguments); this.name = "chunks_search"; this.description = "Search for relevant document chunks in the vector store"; this.inputSchema = { type: "object", properties: { text: { type: "string", description: "Search string", default: {}, }, source: { type: "string", description: "Optional source document to filter the search", default: {}, }, }, required: ["text", "source"], }; } async execute(params) { try { const retriever = chunksVectorStore.asRetriever(); const results = await retriever.invoke(params.text); return { content: [ { type: "text", text: JSON.stringify(results, null, 2) }, ], isError: false, }; } catch (error) { return this.handleError(error); } } }