@answerai/answeragent-mcp 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,72 @@
1
+ import { ChatflowsService } from "../services/chatflows.js";
2
+ const service = ChatflowsService.getInstance();
3
+ export const listChatflows = {
4
+ name: "list_chatflows",
5
+ description: "List all chatflows",
6
+ inputSchema: { type: "object", properties: {} },
7
+ handler: async () => {
8
+ const result = await service.listChatflows();
9
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
10
+ },
11
+ };
12
+ export const getChatflow = {
13
+ name: "get_chatflow",
14
+ description: "Get a chatflow by ID",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ id: { type: "string" },
19
+ includeFullFlowData: { type: "boolean", default: false },
20
+ },
21
+ required: ["id"],
22
+ },
23
+ handler: async ({ id, includeFullFlowData = false, }) => {
24
+ const result = await service.getChatflow(id, includeFullFlowData);
25
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
26
+ },
27
+ };
28
+ export const createChatflow = {
29
+ name: "create_chatflow",
30
+ description: "Create a new chatflow",
31
+ inputSchema: {
32
+ type: "object",
33
+ properties: {
34
+ name: { type: "string" },
35
+ flowData: { type: "string" },
36
+ },
37
+ required: ["name"],
38
+ },
39
+ handler: async (data) => {
40
+ const result = await service.createChatflow(data);
41
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
42
+ },
43
+ };
44
+ export const updateChatflow = {
45
+ name: "update_chatflow",
46
+ description: "Update a chatflow",
47
+ inputSchema: {
48
+ type: "object",
49
+ properties: {
50
+ id: { type: "string" },
51
+ updates: { type: "object" },
52
+ },
53
+ required: ["id", "updates"],
54
+ },
55
+ handler: async ({ id, updates }) => {
56
+ const result = await service.updateChatflow(id, updates);
57
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
58
+ },
59
+ };
60
+ export const deleteChatflow = {
61
+ name: "delete_chatflow",
62
+ description: "Delete a chatflow",
63
+ inputSchema: {
64
+ type: "object",
65
+ properties: { id: { type: "string" } },
66
+ required: ["id"],
67
+ },
68
+ handler: async ({ id }) => {
69
+ await service.deleteChatflow(id);
70
+ return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] };
71
+ },
72
+ };
@@ -0,0 +1,70 @@
1
+ import { DocumentLoaderService } from "../services/document-loader.js";
2
+ const service = DocumentLoaderService.getInstance();
3
+ export const deleteLoaderTool = {
4
+ name: "delete_loader",
5
+ description: "Delete a loader from a document store",
6
+ inputSchema: {
7
+ type: "object",
8
+ properties: {
9
+ storeId: { type: "string" },
10
+ loaderId: { type: "string" },
11
+ },
12
+ required: ["storeId", "loaderId"],
13
+ },
14
+ handler: async ({ storeId, loaderId }) => {
15
+ await service.deleteLoader(storeId, loaderId);
16
+ return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] };
17
+ },
18
+ };
19
+ export const getLoaderChunksTool = {
20
+ name: "get_loader_chunks",
21
+ description: "Get document loader chunks",
22
+ inputSchema: {
23
+ type: "object",
24
+ properties: {
25
+ storeId: { type: "string" },
26
+ loaderId: { type: "string" },
27
+ pageNo: { type: "string" },
28
+ },
29
+ required: ["storeId", "loaderId", "pageNo"],
30
+ },
31
+ handler: async ({ storeId, loaderId, pageNo }) => {
32
+ const result = await service.getChunks(storeId, loaderId, pageNo);
33
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
34
+ },
35
+ };
36
+ export const updateLoaderChunkTool = {
37
+ name: "update_loader_chunk",
38
+ description: "Update a loader chunk",
39
+ inputSchema: {
40
+ type: "object",
41
+ properties: {
42
+ storeId: { type: "string" },
43
+ loaderId: { type: "string" },
44
+ chunkId: { type: "string" },
45
+ payload: { type: "object" },
46
+ },
47
+ required: ["storeId", "loaderId", "chunkId", "payload"],
48
+ },
49
+ handler: async ({ storeId, loaderId, chunkId, payload }) => {
50
+ const result = await service.updateChunk(storeId, loaderId, chunkId, payload);
51
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
52
+ },
53
+ };
54
+ export const deleteLoaderChunkTool = {
55
+ name: "delete_loader_chunk",
56
+ description: "Delete a loader chunk",
57
+ inputSchema: {
58
+ type: "object",
59
+ properties: {
60
+ storeId: { type: "string" },
61
+ loaderId: { type: "string" },
62
+ chunkId: { type: "string" },
63
+ },
64
+ required: ["storeId", "loaderId", "chunkId"],
65
+ },
66
+ handler: async ({ storeId, loaderId, chunkId }) => {
67
+ await service.deleteChunk(storeId, loaderId, chunkId);
68
+ return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] };
69
+ },
70
+ };
@@ -0,0 +1,117 @@
1
+ import { DocumentStoreService } from "../services/document-store.js";
2
+ const service = DocumentStoreService.getInstance();
3
+ export const listDocumentStores = {
4
+ name: "list_document_stores",
5
+ description: "List document stores",
6
+ inputSchema: { type: "object", properties: {} },
7
+ handler: async () => {
8
+ const result = await service.listDocumentStores();
9
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
10
+ },
11
+ };
12
+ export const getDocumentStore = {
13
+ name: "get_document_store",
14
+ description: "Get a document store by ID",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: { id: { type: "string" } },
18
+ required: ["id"],
19
+ },
20
+ handler: async ({ id }) => {
21
+ const result = await service.getDocumentStore(id);
22
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
23
+ },
24
+ };
25
+ export const createDocumentStore = {
26
+ name: "create_document_store",
27
+ description: "Create a document store",
28
+ inputSchema: {
29
+ type: "object",
30
+ properties: {
31
+ name: { type: "string" },
32
+ description: { type: "string" },
33
+ },
34
+ required: ["name"],
35
+ },
36
+ handler: async (data) => {
37
+ const result = await service.createDocumentStore(data);
38
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
39
+ },
40
+ };
41
+ export const updateDocumentStore = {
42
+ name: "update_document_store",
43
+ description: "Update a document store",
44
+ inputSchema: {
45
+ type: "object",
46
+ properties: {
47
+ id: { type: "string" },
48
+ updates: { type: "object" },
49
+ },
50
+ required: ["id", "updates"],
51
+ },
52
+ handler: async ({ id, updates, }) => {
53
+ const result = await service.updateDocumentStore(id, updates);
54
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
55
+ },
56
+ };
57
+ export const deleteDocumentStore = {
58
+ name: "delete_document_store",
59
+ description: "Delete a document store",
60
+ inputSchema: {
61
+ type: "object",
62
+ properties: { id: { type: "string" } },
63
+ required: ["id"],
64
+ },
65
+ handler: async ({ id }) => {
66
+ await service.deleteDocumentStore(id);
67
+ return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] };
68
+ },
69
+ };
70
+ export const upsertDocument = {
71
+ name: "upsert_document",
72
+ description: "Upsert document to store",
73
+ inputSchema: {
74
+ type: "object",
75
+ properties: {
76
+ id: { type: "string" },
77
+ payload: { type: "object" },
78
+ },
79
+ required: ["id", "payload"],
80
+ },
81
+ handler: async ({ id, payload }) => {
82
+ const result = await service.upsertDocument(id, payload);
83
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
84
+ },
85
+ };
86
+ export const refreshDocumentStore = {
87
+ name: "refresh_document_store",
88
+ description: "Refresh all documents in store",
89
+ inputSchema: {
90
+ type: "object",
91
+ properties: {
92
+ id: { type: "string" },
93
+ payload: { type: "object" },
94
+ },
95
+ required: ["id", "payload"],
96
+ },
97
+ handler: async ({ id, payload }) => {
98
+ const result = await service.refreshDocumentStore(id, payload);
99
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
100
+ },
101
+ };
102
+ export const queryVectorStore = {
103
+ name: "query_vector_store",
104
+ description: "Query vector store",
105
+ inputSchema: {
106
+ type: "object",
107
+ properties: {
108
+ storeId: { type: "string" },
109
+ query: { type: "string" },
110
+ },
111
+ required: ["storeId", "query"],
112
+ },
113
+ handler: async ({ storeId, query }) => {
114
+ const result = await service.queryVectorStore({ storeId, query });
115
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
116
+ },
117
+ };
@@ -0,0 +1,109 @@
1
+ import * as chatflowTools from "./chatflows.js";
2
+ import * as documentStoreTools from "./document-stores.js";
3
+ import * as toolsApiTools from "./tools-api.js";
4
+ import * as assistantTools from "./assistants.js";
5
+ import * as documentLoaderTools from "./document-loaders.js";
6
+ // Get all available tools for listing
7
+ export const getAllTools = () => {
8
+ const tools = [];
9
+ // Add Chatflow Tools
10
+ for (const tool of Object.values(chatflowTools)) {
11
+ const schema = tool.inputSchema;
12
+ tools.push({
13
+ name: tool.name,
14
+ description: tool.description,
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: schema.properties,
18
+ ...(schema.required ? { required: schema.required } : {}),
19
+ },
20
+ });
21
+ }
22
+ // Add Document Store Tools
23
+ for (const tool of Object.values(documentStoreTools)) {
24
+ const schema = tool.inputSchema;
25
+ tools.push({
26
+ name: tool.name,
27
+ description: tool.description,
28
+ inputSchema: {
29
+ type: "object",
30
+ properties: schema.properties,
31
+ ...(schema.required ? { required: schema.required } : {}),
32
+ },
33
+ });
34
+ }
35
+ // Add Tools API Tools
36
+ for (const tool of Object.values(toolsApiTools)) {
37
+ const schema = tool.inputSchema;
38
+ tools.push({
39
+ name: tool.name,
40
+ description: tool.description,
41
+ inputSchema: {
42
+ type: "object",
43
+ properties: schema.properties,
44
+ ...(schema.required ? { required: schema.required } : {}),
45
+ },
46
+ });
47
+ }
48
+ // Add Assistant Tools
49
+ for (const tool of Object.values(assistantTools)) {
50
+ const schema = tool.inputSchema;
51
+ tools.push({
52
+ name: tool.name,
53
+ description: tool.description,
54
+ inputSchema: {
55
+ type: "object",
56
+ properties: schema.properties,
57
+ ...(schema.required ? { required: schema.required } : {}),
58
+ },
59
+ });
60
+ }
61
+ // Add Document Loader Tools
62
+ for (const tool of Object.values(documentLoaderTools)) {
63
+ const schema = tool.inputSchema;
64
+ tools.push({
65
+ name: tool.name,
66
+ description: tool.description,
67
+ inputSchema: {
68
+ type: "object",
69
+ properties: schema.properties,
70
+ ...(schema.required ? { required: schema.required } : {}),
71
+ },
72
+ });
73
+ }
74
+ return tools;
75
+ };
76
+ // Handle tool calls
77
+ export async function handleToolCall(name, args) {
78
+ // Check chatflow tools
79
+ for (const tool of Object.values(chatflowTools)) {
80
+ if (tool.name === name) {
81
+ return await tool.handler(args);
82
+ }
83
+ }
84
+ // Check document store tools
85
+ for (const tool of Object.values(documentStoreTools)) {
86
+ if (tool.name === name) {
87
+ return await tool.handler(args);
88
+ }
89
+ }
90
+ // Check tools API tools
91
+ for (const tool of Object.values(toolsApiTools)) {
92
+ if (tool.name === name) {
93
+ return await tool.handler(args);
94
+ }
95
+ }
96
+ // Check assistant tools
97
+ for (const tool of Object.values(assistantTools)) {
98
+ if (tool.name === name) {
99
+ return await tool.handler(args);
100
+ }
101
+ }
102
+ // Check document loader tools
103
+ for (const tool of Object.values(documentLoaderTools)) {
104
+ if (tool.name === name) {
105
+ return await tool.handler(args);
106
+ }
107
+ }
108
+ throw new Error(`Unknown tool: ${name}`);
109
+ }
@@ -0,0 +1,69 @@
1
+ import { ToolsApiService } from "../services/tools-api.js";
2
+ const service = ToolsApiService.getInstance();
3
+ export const listToolsApi = {
4
+ name: "list_tools",
5
+ description: "List tools from AnswerAgent",
6
+ inputSchema: { type: "object", properties: {} },
7
+ handler: async () => {
8
+ const result = await service.listTools();
9
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
10
+ },
11
+ };
12
+ export const getToolApi = {
13
+ name: "get_tool",
14
+ description: "Get tool by ID",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: { id: { type: "string" } },
18
+ required: ["id"],
19
+ },
20
+ handler: async ({ id }) => {
21
+ const result = await service.getTool(id);
22
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
23
+ },
24
+ };
25
+ export const createToolApi = {
26
+ name: "create_tool",
27
+ description: "Create a tool",
28
+ inputSchema: {
29
+ type: "object",
30
+ properties: {
31
+ name: { type: "string" },
32
+ description: { type: "string" },
33
+ },
34
+ required: ["name"],
35
+ },
36
+ handler: async (data) => {
37
+ const result = await service.createTool(data);
38
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
39
+ },
40
+ };
41
+ export const updateToolApi = {
42
+ name: "update_tool",
43
+ description: "Update a tool",
44
+ inputSchema: {
45
+ type: "object",
46
+ properties: {
47
+ id: { type: "string" },
48
+ updates: { type: "object" },
49
+ },
50
+ required: ["id", "updates"],
51
+ },
52
+ handler: async ({ id, updates }) => {
53
+ const result = await service.updateTool(id, updates);
54
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
55
+ },
56
+ };
57
+ export const deleteToolApi = {
58
+ name: "delete_tool",
59
+ description: "Delete a tool",
60
+ inputSchema: {
61
+ type: "object",
62
+ properties: { id: { type: "string" } },
63
+ required: ["id"],
64
+ },
65
+ handler: async ({ id }) => {
66
+ await service.deleteTool(id);
67
+ return { content: [{ type: "text", text: JSON.stringify({ success: true }) }] };
68
+ },
69
+ };
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ export const AssistantDetailsSchema = z.object({
3
+ id: z.string().optional(),
4
+ name: z.string().optional(),
5
+ description: z.string().optional(),
6
+ model: z.string().optional(),
7
+ instructions: z.string().optional(),
8
+ temperature: z.number().optional(),
9
+ top_p: z.number().optional(),
10
+ tools: z.array(z.string()).optional(),
11
+ tool_resources: z.record(z.any()).optional(),
12
+ });
13
+ export const AssistantSchema = z.object({
14
+ id: z.string().uuid().optional(),
15
+ details: AssistantDetailsSchema.optional(),
16
+ credential: z.string().optional(),
17
+ iconSrc: z.string().optional(),
18
+ createdDate: z.string().datetime().optional(),
19
+ updatedDate: z.string().datetime().optional(),
20
+ });
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ // Define schema for parsed flow data structure
3
+ export const ParsedNodeSchema = z.object({
4
+ id: z.string(),
5
+ type: z.string(),
6
+ label: z.string(),
7
+ description: z.string().optional(),
8
+ category: z.string().optional(),
9
+ credential: z.string().optional(),
10
+ prompts: z.object({
11
+ systemMessagePrompt: z.string().optional(),
12
+ humanMessagePrompt: z.string().optional(),
13
+ agentInstructions: z.string().optional(),
14
+ }).optional(),
15
+ });
16
+ export const ParsedFlowDataSchema = z.object({
17
+ nodes: z.array(ParsedNodeSchema),
18
+ credentialIds: z.array(z.string()),
19
+ });
20
+ export const ChatflowSchema = z.object({
21
+ id: z.string().uuid().optional(),
22
+ name: z.string(),
23
+ description: z.string().optional(),
24
+ visibility: z.string().optional(),
25
+ flowData: z.string().optional(),
26
+ deployed: z.boolean().optional(),
27
+ isPublic: z.boolean().optional(),
28
+ apikeyid: z.string().optional(),
29
+ chatbotConfig: z.string().optional(),
30
+ apiConfig: z.string().optional(),
31
+ analytic: z.string().optional(),
32
+ speechToText: z.string().optional(),
33
+ category: z.string().optional(),
34
+ type: z.string().optional(),
35
+ userId: z.string().optional(),
36
+ organizationId: z.string().optional(),
37
+ createdDate: z.string().datetime().optional(),
38
+ updatedDate: z.string().datetime().optional(),
39
+ deleteDate: z.string().datetime().optional(),
40
+ badge: z.string().optional(),
41
+ isOwner: z.boolean().optional(),
42
+ canEdit: z.boolean().optional(),
43
+ parsedFlowData: ParsedFlowDataSchema.optional(),
44
+ });
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ export const DocumentLoaderSchema = z.object({
3
+ id: z.string().uuid().optional(),
4
+ status: z.string().optional(),
5
+ storeId: z.string().optional(),
6
+ source: z.string().optional(),
7
+ credential: z.string().optional(),
8
+ rehydrated: z.boolean().optional(),
9
+ preview: z.boolean().optional(),
10
+ previewChunkCount: z.number().optional(),
11
+ });
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ export const DocumentStoreSchema = z.object({
3
+ id: z.string().uuid().optional(),
4
+ name: z.string(),
5
+ description: z.string().optional(),
6
+ loaders: z.string().optional(),
7
+ whereUsed: z.string().optional(),
8
+ status: z.string().optional(),
9
+ vectorStoreConfig: z.string().optional(),
10
+ embeddingConfig: z.string().optional(),
11
+ recordManagerConfig: z.string().optional(),
12
+ createdDate: z.string().datetime().optional(),
13
+ updatedDate: z.string().datetime().optional(),
14
+ });
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ export const ToolSchema = z.object({
3
+ id: z.string().uuid().optional(),
4
+ name: z.string(),
5
+ description: z.string().optional(),
6
+ color: z.string().optional(),
7
+ iconSrc: z.string().nullable().optional(),
8
+ schema: z.string().nullable().optional(),
9
+ func: z.string().nullable().optional(),
10
+ createdDate: z.string().datetime().optional(),
11
+ updatedDate: z.string().datetime().optional(),
12
+ });
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@answerai/answeragent-mcp",
3
+ "version": "1.0.1",
4
+ "description": "A lightweight Model Context Protocol (MCP) server for Answer AI chatflow and document store management",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "answerai-mcp": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "keywords": [
15
+ "mcp",
16
+ "model-context-protocol",
17
+ "answer-ai",
18
+ "chatflow",
19
+ "document-store",
20
+ "api",
21
+ "ai-tools"
22
+ ],
23
+ "author": "Bradley Taylor",
24
+ "license": "ISC",
25
+ "homepage": "https://github.com/bradtaylor/answerai-mcp#readme",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/bradtaylor/answerai-mcp.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/bradtaylor/answerai-mcp/issues"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "engines": {
37
+ "node": ">=18.0.0"
38
+ },
39
+ "dependencies": {
40
+ "@modelcontextprotocol/sdk": "0.6.0",
41
+ "axios": "^1.8.4",
42
+ "dotenv": "^16.4.7",
43
+ "express": "^4.21.2",
44
+ "zod": "^3.24.2"
45
+ },
46
+ "devDependencies": {
47
+ "@types/express": "^5.0.1",
48
+ "@types/node": "^20.11.24",
49
+ "nodemon": "^3.1.9",
50
+ "ts-node": "^10.9.2",
51
+ "tsx": "^4.19.3",
52
+ "typescript": "^5.3.3",
53
+ "vite": "^6.2.3"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc && chmod +x dist/index.js",
57
+ "start": "node dist/index.js",
58
+ "dev": "nodemon --exec 'node --loader ts-node/esm src/index.ts'",
59
+ "inspect": "node bin/run-inspector.js",
60
+ "inspect-watch": "nodemon --exec 'node bin/run-inspector.js'",
61
+ "test": "node --loader ts-node/esm --test"
62
+ }
63
+ }