UNPKG

@answerai/answeragent-mcp

Version:

A lightweight Model Context Protocol (MCP) server for Answer AI chatflow and document store management

118 lines (117 loc) 3.84 kB
import { DocumentStoreService } from "../services/document-store.js"; const service = DocumentStoreService.getInstance(); export const listDocumentStores = { name: "list_document_stores", description: "List document stores", inputSchema: { type: "object", properties: {} }, handler: async () => { const result = await service.listDocumentStores(); return { content: [{ type: "text", text: JSON.stringify(result) }] }; }, }; export const getDocumentStore = { name: "get_document_store", description: "Get a document store by ID", inputSchema: { type: "object", properties: { id: { type: "string" } }, required: ["id"], }, handler: async ({ id }) => { const result = await service.getDocumentStore(id); return { content: [{ type: "text", text: JSON.stringify(result) }] }; }, }; export const createDocumentStore = { name: "create_document_store", description: "Create a document store", inputSchema: { type: "object", properties: { name: { type: "string" }, description: { type: "string" }, }, required: ["name"], }, handler: async (data) => { const result = await service.createDocumentStore(data); return { content: [{ type: "text", text: JSON.stringify(result) }] }; }, }; export const updateDocumentStore = { name: "update_document_store", description: "Update a document store", inputSchema: { type: "object", properties: { id: { type: "string" }, updates: { type: "object" }, }, required: ["id", "updates"], }, handler: async ({ id, updates, }) => { const result = await service.updateDocumentStore(id, updates); return { content: [{ type: "text", text: JSON.stringify(result) }] }; }, }; export const deleteDocumentStore = { name: "delete_document_store", description: "Delete a document store", inputSchema: { type: "object", properties: { id: { type: "string" } }, required: ["id"], }, handler: async ({ id }) => { await service.deleteDocumentStore(id); return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] }; }, }; export const upsertDocument = { name: "upsert_document", description: "Upsert document to store", inputSchema: { type: "object", properties: { id: { type: "string" }, payload: { type: "object" }, }, required: ["id", "payload"], }, handler: async ({ id, payload }) => { const result = await service.upsertDocument(id, payload); return { content: [{ type: "text", text: JSON.stringify(result) }] }; }, }; export const refreshDocumentStore = { name: "refresh_document_store", description: "Refresh all documents in store", inputSchema: { type: "object", properties: { id: { type: "string" }, payload: { type: "object" }, }, required: ["id", "payload"], }, handler: async ({ id, payload }) => { const result = await service.refreshDocumentStore(id, payload); return { content: [{ type: "text", text: JSON.stringify(result) }] }; }, }; export const queryVectorStore = { name: "query_vector_store", description: "Query vector store", inputSchema: { type: "object", properties: { storeId: { type: "string" }, query: { type: "string" }, }, required: ["storeId", "query"], }, handler: async ({ storeId, query }) => { const result = await service.queryVectorStore({ storeId, query }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; }, };