@answerai/answeragent-mcp
Version:
A lightweight Model Context Protocol (MCP) server for Answer AI chatflow and document store management
73 lines (72 loc) • 2.33 kB
JavaScript
import { ChatflowsService } from "../services/chatflows.js";
const service = ChatflowsService.getInstance();
export const listChatflows = {
name: "list_chatflows",
description: "List all chatflows",
inputSchema: { type: "object", properties: {} },
handler: async () => {
const result = await service.listChatflows();
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const getChatflow = {
name: "get_chatflow",
description: "Get a chatflow by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string" },
includeFullFlowData: { type: "boolean", default: false },
},
required: ["id"],
},
handler: async ({ id, includeFullFlowData = false, }) => {
const result = await service.getChatflow(id, includeFullFlowData);
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const createChatflow = {
name: "create_chatflow",
description: "Create a new chatflow",
inputSchema: {
type: "object",
properties: {
name: { type: "string" },
flowData: { type: "string" },
},
required: ["name"],
},
handler: async (data) => {
const result = await service.createChatflow(data);
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const updateChatflow = {
name: "update_chatflow",
description: "Update a chatflow",
inputSchema: {
type: "object",
properties: {
id: { type: "string" },
updates: { type: "object" },
},
required: ["id", "updates"],
},
handler: async ({ id, updates }) => {
const result = await service.updateChatflow(id, updates);
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const deleteChatflow = {
name: "delete_chatflow",
description: "Delete a chatflow",
inputSchema: {
type: "object",
properties: { id: { type: "string" } },
required: ["id"],
},
handler: async ({ id }) => {
await service.deleteChatflow(id);
return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] };
},
};