lance-mcp
Version:
MCP server for interacting with LanceDB database
48 lines (47 loc) • 1.64 kB
JavaScript
import { client } from "../../mongodb/client.js";
import { BaseTool } from "../base/tool.js";
export class DeleteOneTool extends BaseTool {
constructor() {
super(...arguments);
this.name = "deleteOne";
this.description = "Delete a single document from a collection";
this.inputSchema = {
type: "object",
properties: {
database: {
type: "string",
description: "Name of the database to use",
},
collection: {
type: "string",
description: "Name of the collection",
},
filter: {
type: "object",
description: "Filter to identify document",
},
},
required: ["database", "collection", "filter"],
};
}
async execute(params) {
try {
const database = this.validateDatabase(params.database);
const collection = this.validateCollection(params.collection);
const filter = this.validateObject(params.filter, "Filter");
const result = await client.db(database).collection(collection).deleteOne(filter);
return {
content: [
{
type: "text",
text: JSON.stringify({ deleted: result.deletedCount }, null, 2),
},
],
isError: false,
};
}
catch (error) {
return this.handleError(error);
}
}
}