@answerai/answeragent-mcp
Version:
A lightweight Model Context Protocol (MCP) server for Answer AI chatflow and document store management
70 lines (69 loc) • 2.13 kB
JavaScript
import { ToolsApiService } from "../services/tools-api.js";
const service = ToolsApiService.getInstance();
export const listToolsApi = {
name: "list_tools",
description: "List tools from AnswerAgent",
inputSchema: { type: "object", properties: {} },
handler: async () => {
const result = await service.listTools();
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const getToolApi = {
name: "get_tool",
description: "Get tool by ID",
inputSchema: {
type: "object",
properties: { id: { type: "string" } },
required: ["id"],
},
handler: async ({ id }) => {
const result = await service.getTool(id);
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const createToolApi = {
name: "create_tool",
description: "Create a tool",
inputSchema: {
type: "object",
properties: {
name: { type: "string" },
description: { type: "string" },
},
required: ["name"],
},
handler: async (data) => {
const result = await service.createTool(data);
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const updateToolApi = {
name: "update_tool",
description: "Update a tool",
inputSchema: {
type: "object",
properties: {
id: { type: "string" },
updates: { type: "object" },
},
required: ["id", "updates"],
},
handler: async ({ id, updates }) => {
const result = await service.updateTool(id, updates);
return { content: [{ type: "text", text: JSON.stringify(result) }] };
},
};
export const deleteToolApi = {
name: "delete_tool",
description: "Delete a tool",
inputSchema: {
type: "object",
properties: { id: { type: "string" } },
required: ["id"],
},
handler: async ({ id }) => {
await service.deleteTool(id);
return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] };
},
};