@agiflowai/clawdbot-mcp-plugin 0.1.0

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,220 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ let __sinclair_typebox = require("@sinclair/typebox");
25
+ __sinclair_typebox = __toESM(__sinclair_typebox);
26
+ let __agiflowai_one_mcp = require("@agiflowai/one-mcp");
27
+ __agiflowai_one_mcp = __toESM(__agiflowai_one_mcp);
28
+
29
+ //#region src/plugin.ts
30
+ const mcpBridgePlugin = {
31
+ id: "clawdbot-mcp-plugin",
32
+ name: "MCP Server Bridge",
33
+ description: "Enables Model Context Protocol (MCP) server integration with progressive tool disclosure",
34
+ configSchema: __sinclair_typebox.Type.Object({
35
+ configFilePath: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.String({
36
+ description: "Path to mcp-config.yaml file (supports one-mcp's YAML format)",
37
+ default: ".clawdbot/mcp-config.yaml"
38
+ })),
39
+ serverId: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.String({
40
+ description: "Unique identifier for the toolkit",
41
+ default: "clawdbot-mcp"
42
+ })),
43
+ noCache: __sinclair_typebox.Type.Optional(__sinclair_typebox.Type.Boolean({
44
+ description: "Disable configuration caching",
45
+ default: false
46
+ }))
47
+ }),
48
+ register(api) {
49
+ const pluginConfig = api.pluginConfig || {};
50
+ const serverOptions = {
51
+ configFilePath: pluginConfig.configFilePath || ".clawdbot/mcp-config.yaml",
52
+ serverId: pluginConfig.serverId || "clawdbot-mcp",
53
+ noCache: pluginConfig.noCache || false
54
+ };
55
+ let describeToolsToolInstance = null;
56
+ let useToolToolInstance = null;
57
+ let isInitialized = false;
58
+ let toolkitDescription = null;
59
+ api.registerService({
60
+ id: "mcp-server",
61
+ async start() {
62
+ try {
63
+ api.logger.info(`[one-mcp] Initializing MCP server with config: ${serverOptions.configFilePath}`);
64
+ const clientManager = new __agiflowai_one_mcp.McpClientManagerService();
65
+ const config = await new __agiflowai_one_mcp.ConfigFetcherService({
66
+ configFilePath: serverOptions.configFilePath,
67
+ useCache: !serverOptions.noCache
68
+ }).fetchConfiguration(serverOptions.noCache || false);
69
+ const connectionPromises = Object.entries(config.mcpServers).map(async ([serverName, serverConfig]) => {
70
+ try {
71
+ await clientManager.connectToServer(serverName, serverConfig);
72
+ api.logger.info(`[one-mcp] Connected to MCP server: ${serverName}`);
73
+ } catch (error) {
74
+ const errorMessage = error instanceof Error ? error.message : String(error);
75
+ api.logger.error(`[one-mcp] Failed to connect to ${serverName}:`, errorMessage);
76
+ }
77
+ });
78
+ await Promise.all(connectionPromises);
79
+ const skillsConfig = config.skills;
80
+ const skillService = skillsConfig && skillsConfig.paths.length > 0 ? new __agiflowai_one_mcp.SkillService(process.cwd(), skillsConfig.paths) : void 0;
81
+ describeToolsToolInstance = new __agiflowai_one_mcp.DescribeToolsTool(clientManager, skillService, serverOptions.serverId);
82
+ useToolToolInstance = new __agiflowai_one_mcp.UseToolTool(clientManager, skillService, serverOptions.serverId);
83
+ toolkitDescription = (await describeToolsToolInstance.getDefinition()).description;
84
+ isInitialized = true;
85
+ api.logger.info("[one-mcp] MCP server initialized successfully");
86
+ } catch (error) {
87
+ const errorMessage = error instanceof Error ? error.message : String(error);
88
+ api.logger.error("[one-mcp] Failed to initialize MCP server:", errorMessage);
89
+ throw error;
90
+ }
91
+ },
92
+ async stop() {
93
+ api.logger.info("[one-mcp] MCP server stopping");
94
+ isInitialized = false;
95
+ describeToolsToolInstance = null;
96
+ useToolToolInstance = null;
97
+ }
98
+ });
99
+ api.registerTool({
100
+ name: "mcp__describe_tools",
101
+ description: `
102
+ <toolkit id="${serverOptions.serverId}">
103
+ <instruction>
104
+ Before you use any capabilities below, you MUST call this tool with a list of names to learn how to use them properly; this includes:
105
+ - For tools: Arguments schema needed to pass to use_tool
106
+ - For skills: Detailed instructions that will expand when invoked (Prefer to be explored first when relevant)
107
+
108
+ This tool is optimized for batch queries - you can request multiple capabilities at once for better performance.
109
+
110
+ How to invoke:
111
+ - For MCP tools: Use use_tool with toolName and toolArgs based on the schema
112
+ - For skills: Use this tool with the skill name to get expanded instructions
113
+ </instruction>
114
+
115
+ <available_capabilities>
116
+ <!-- Capabilities will be populated dynamically after MCP servers connect -->
117
+ </available_capabilities>
118
+ </toolkit>
119
+ `.trim(),
120
+ parameters: {
121
+ type: "object",
122
+ additionalProperties: false,
123
+ properties: { toolNames: {
124
+ description: "List of tool names to get detailed information about",
125
+ items: {
126
+ minLength: 1,
127
+ type: "string"
128
+ },
129
+ minItems: 1,
130
+ type: "array"
131
+ } },
132
+ required: ["toolNames"]
133
+ },
134
+ async execute(_id, params) {
135
+ if (!isInitialized || !describeToolsToolInstance) return {
136
+ content: [{
137
+ type: "text",
138
+ text: "MCP server not initialized yet. Please wait for service startup to complete."
139
+ }],
140
+ isError: true
141
+ };
142
+ try {
143
+ const result = await describeToolsToolInstance.execute(params);
144
+ const responseText = result.content?.[0]?.type === "text" ? result.content[0].text : JSON.stringify(result, null, 2);
145
+ return { content: [{
146
+ type: "text",
147
+ text: toolkitDescription ? `${toolkitDescription}\n\n---\n\nDetailed Information:\n${responseText}` : responseText
148
+ }] };
149
+ } catch (error) {
150
+ const errorMessage = error instanceof Error ? error.message : String(error);
151
+ api.logger.error("[one-mcp] describe_tools error:", errorMessage);
152
+ return {
153
+ content: [{
154
+ type: "text",
155
+ text: `Error executing describe_tools: ${errorMessage}`
156
+ }],
157
+ isError: true
158
+ };
159
+ }
160
+ }
161
+ }, { name: "mcp__describe_tools" });
162
+ api.registerTool({
163
+ name: "mcp__use_tool",
164
+ description: `
165
+ Execute an MCP tool (NOT Skill) with provided arguments. You MUST call describe_tools first to discover the tool's correct arguments. Then to use tool:
166
+ - Provide toolName and toolArgs based on the schema
167
+ - If multiple servers provide the same tool, specify serverName
168
+
169
+ IMPORTANT: Only use tools discovered from describe_tools with id="${serverOptions.serverId}".
170
+ `.trim(),
171
+ parameters: {
172
+ type: "object",
173
+ additionalProperties: false,
174
+ properties: {
175
+ toolArgs: {
176
+ description: "Arguments to pass to the tool, as discovered from describe_tools",
177
+ type: "object"
178
+ },
179
+ toolName: {
180
+ description: "Name of the tool to execute",
181
+ minLength: 1,
182
+ type: "string"
183
+ }
184
+ },
185
+ required: ["toolName"]
186
+ },
187
+ async execute(_id, params) {
188
+ if (!isInitialized || !useToolToolInstance) return {
189
+ content: [{
190
+ type: "text",
191
+ text: "MCP server not initialized yet. Please wait for service startup to complete."
192
+ }],
193
+ isError: true
194
+ };
195
+ try {
196
+ const result = await useToolToolInstance.execute(params);
197
+ return { content: result.content || [{
198
+ type: "text",
199
+ text: JSON.stringify(result, null, 2)
200
+ }] };
201
+ } catch (error) {
202
+ const errorMessage = error instanceof Error ? error.message : String(error);
203
+ api.logger.error("[one-mcp] use_tool error:", errorMessage);
204
+ return {
205
+ content: [{
206
+ type: "text",
207
+ text: `Error executing tool: ${errorMessage}`
208
+ }],
209
+ isError: true
210
+ };
211
+ }
212
+ }
213
+ }, { name: "mcp__use_tool" });
214
+ api.logger.info("[one-mcp] Tools registered: mcp__describe_tools, mcp__use_tool");
215
+ }
216
+ };
217
+ var plugin_default = mcpBridgePlugin;
218
+
219
+ //#endregion
220
+ module.exports = plugin_default;
@@ -0,0 +1,17 @@
1
+ import { t as ClawdbotApi } from "./index-BTWlYpm4.cjs";
2
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
3
+
4
+ //#region src/plugin.d.ts
5
+
6
+ declare const mcpBridgePlugin: {
7
+ id: string;
8
+ name: string;
9
+ description: string;
10
+ configSchema: _sinclair_typebox0.TObject<{
11
+ configFilePath: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
12
+ serverId: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
13
+ noCache: _sinclair_typebox0.TOptional<_sinclair_typebox0.TBoolean>;
14
+ }>;
15
+ register(api: ClawdbotApi): void;
16
+ };
17
+ export = mcpBridgePlugin;
@@ -0,0 +1,18 @@
1
+ import { t as ClawdbotApi } from "./index-Ca12Wuvd.js";
2
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
3
+
4
+ //#region src/plugin.d.ts
5
+
6
+ declare const mcpBridgePlugin: {
7
+ id: string;
8
+ name: string;
9
+ description: string;
10
+ configSchema: _sinclair_typebox0.TObject<{
11
+ configFilePath: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
12
+ serverId: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
13
+ noCache: _sinclair_typebox0.TOptional<_sinclair_typebox0.TBoolean>;
14
+ }>;
15
+ register(api: ClawdbotApi): void;
16
+ };
17
+ //#endregion
18
+ export { mcpBridgePlugin as default };
package/dist/plugin.js ADDED
@@ -0,0 +1,195 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { ConfigFetcherService, DescribeToolsTool, McpClientManagerService, SkillService, UseToolTool } from "@agiflowai/one-mcp";
3
+
4
+ //#region src/plugin.ts
5
+ const mcpBridgePlugin = {
6
+ id: "clawdbot-mcp-plugin",
7
+ name: "MCP Server Bridge",
8
+ description: "Enables Model Context Protocol (MCP) server integration with progressive tool disclosure",
9
+ configSchema: Type.Object({
10
+ configFilePath: Type.Optional(Type.String({
11
+ description: "Path to mcp-config.yaml file (supports one-mcp's YAML format)",
12
+ default: ".clawdbot/mcp-config.yaml"
13
+ })),
14
+ serverId: Type.Optional(Type.String({
15
+ description: "Unique identifier for the toolkit",
16
+ default: "clawdbot-mcp"
17
+ })),
18
+ noCache: Type.Optional(Type.Boolean({
19
+ description: "Disable configuration caching",
20
+ default: false
21
+ }))
22
+ }),
23
+ register(api) {
24
+ const pluginConfig = api.pluginConfig || {};
25
+ const serverOptions = {
26
+ configFilePath: pluginConfig.configFilePath || ".clawdbot/mcp-config.yaml",
27
+ serverId: pluginConfig.serverId || "clawdbot-mcp",
28
+ noCache: pluginConfig.noCache || false
29
+ };
30
+ let describeToolsToolInstance = null;
31
+ let useToolToolInstance = null;
32
+ let isInitialized = false;
33
+ let toolkitDescription = null;
34
+ api.registerService({
35
+ id: "mcp-server",
36
+ async start() {
37
+ try {
38
+ api.logger.info(`[one-mcp] Initializing MCP server with config: ${serverOptions.configFilePath}`);
39
+ const clientManager = new McpClientManagerService();
40
+ const config = await new ConfigFetcherService({
41
+ configFilePath: serverOptions.configFilePath,
42
+ useCache: !serverOptions.noCache
43
+ }).fetchConfiguration(serverOptions.noCache || false);
44
+ const connectionPromises = Object.entries(config.mcpServers).map(async ([serverName, serverConfig]) => {
45
+ try {
46
+ await clientManager.connectToServer(serverName, serverConfig);
47
+ api.logger.info(`[one-mcp] Connected to MCP server: ${serverName}`);
48
+ } catch (error) {
49
+ const errorMessage = error instanceof Error ? error.message : String(error);
50
+ api.logger.error(`[one-mcp] Failed to connect to ${serverName}:`, errorMessage);
51
+ }
52
+ });
53
+ await Promise.all(connectionPromises);
54
+ const skillsConfig = config.skills;
55
+ const skillService = skillsConfig && skillsConfig.paths.length > 0 ? new SkillService(process.cwd(), skillsConfig.paths) : void 0;
56
+ describeToolsToolInstance = new DescribeToolsTool(clientManager, skillService, serverOptions.serverId);
57
+ useToolToolInstance = new UseToolTool(clientManager, skillService, serverOptions.serverId);
58
+ toolkitDescription = (await describeToolsToolInstance.getDefinition()).description;
59
+ isInitialized = true;
60
+ api.logger.info("[one-mcp] MCP server initialized successfully");
61
+ } catch (error) {
62
+ const errorMessage = error instanceof Error ? error.message : String(error);
63
+ api.logger.error("[one-mcp] Failed to initialize MCP server:", errorMessage);
64
+ throw error;
65
+ }
66
+ },
67
+ async stop() {
68
+ api.logger.info("[one-mcp] MCP server stopping");
69
+ isInitialized = false;
70
+ describeToolsToolInstance = null;
71
+ useToolToolInstance = null;
72
+ }
73
+ });
74
+ api.registerTool({
75
+ name: "mcp__describe_tools",
76
+ description: `
77
+ <toolkit id="${serverOptions.serverId}">
78
+ <instruction>
79
+ Before you use any capabilities below, you MUST call this tool with a list of names to learn how to use them properly; this includes:
80
+ - For tools: Arguments schema needed to pass to use_tool
81
+ - For skills: Detailed instructions that will expand when invoked (Prefer to be explored first when relevant)
82
+
83
+ This tool is optimized for batch queries - you can request multiple capabilities at once for better performance.
84
+
85
+ How to invoke:
86
+ - For MCP tools: Use use_tool with toolName and toolArgs based on the schema
87
+ - For skills: Use this tool with the skill name to get expanded instructions
88
+ </instruction>
89
+
90
+ <available_capabilities>
91
+ <!-- Capabilities will be populated dynamically after MCP servers connect -->
92
+ </available_capabilities>
93
+ </toolkit>
94
+ `.trim(),
95
+ parameters: {
96
+ type: "object",
97
+ additionalProperties: false,
98
+ properties: { toolNames: {
99
+ description: "List of tool names to get detailed information about",
100
+ items: {
101
+ minLength: 1,
102
+ type: "string"
103
+ },
104
+ minItems: 1,
105
+ type: "array"
106
+ } },
107
+ required: ["toolNames"]
108
+ },
109
+ async execute(_id, params) {
110
+ if (!isInitialized || !describeToolsToolInstance) return {
111
+ content: [{
112
+ type: "text",
113
+ text: "MCP server not initialized yet. Please wait for service startup to complete."
114
+ }],
115
+ isError: true
116
+ };
117
+ try {
118
+ const result = await describeToolsToolInstance.execute(params);
119
+ const responseText = result.content?.[0]?.type === "text" ? result.content[0].text : JSON.stringify(result, null, 2);
120
+ return { content: [{
121
+ type: "text",
122
+ text: toolkitDescription ? `${toolkitDescription}\n\n---\n\nDetailed Information:\n${responseText}` : responseText
123
+ }] };
124
+ } catch (error) {
125
+ const errorMessage = error instanceof Error ? error.message : String(error);
126
+ api.logger.error("[one-mcp] describe_tools error:", errorMessage);
127
+ return {
128
+ content: [{
129
+ type: "text",
130
+ text: `Error executing describe_tools: ${errorMessage}`
131
+ }],
132
+ isError: true
133
+ };
134
+ }
135
+ }
136
+ }, { name: "mcp__describe_tools" });
137
+ api.registerTool({
138
+ name: "mcp__use_tool",
139
+ description: `
140
+ Execute an MCP tool (NOT Skill) with provided arguments. You MUST call describe_tools first to discover the tool's correct arguments. Then to use tool:
141
+ - Provide toolName and toolArgs based on the schema
142
+ - If multiple servers provide the same tool, specify serverName
143
+
144
+ IMPORTANT: Only use tools discovered from describe_tools with id="${serverOptions.serverId}".
145
+ `.trim(),
146
+ parameters: {
147
+ type: "object",
148
+ additionalProperties: false,
149
+ properties: {
150
+ toolArgs: {
151
+ description: "Arguments to pass to the tool, as discovered from describe_tools",
152
+ type: "object"
153
+ },
154
+ toolName: {
155
+ description: "Name of the tool to execute",
156
+ minLength: 1,
157
+ type: "string"
158
+ }
159
+ },
160
+ required: ["toolName"]
161
+ },
162
+ async execute(_id, params) {
163
+ if (!isInitialized || !useToolToolInstance) return {
164
+ content: [{
165
+ type: "text",
166
+ text: "MCP server not initialized yet. Please wait for service startup to complete."
167
+ }],
168
+ isError: true
169
+ };
170
+ try {
171
+ const result = await useToolToolInstance.execute(params);
172
+ return { content: result.content || [{
173
+ type: "text",
174
+ text: JSON.stringify(result, null, 2)
175
+ }] };
176
+ } catch (error) {
177
+ const errorMessage = error instanceof Error ? error.message : String(error);
178
+ api.logger.error("[one-mcp] use_tool error:", errorMessage);
179
+ return {
180
+ content: [{
181
+ type: "text",
182
+ text: `Error executing tool: ${errorMessage}`
183
+ }],
184
+ isError: true
185
+ };
186
+ }
187
+ }
188
+ }, { name: "mcp__use_tool" });
189
+ api.logger.info("[one-mcp] Tools registered: mcp__describe_tools, mcp__use_tool");
190
+ }
191
+ };
192
+ var plugin_default = mcpBridgePlugin;
193
+
194
+ //#endregion
195
+ export { plugin_default as default };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@agiflowai/clawdbot-mcp-plugin",
3
+ "description": "Clawdbot plugin for MCP server integration with progressive tool disclosure",
4
+ "version": "0.1.0",
5
+ "license": "AGPL-3.0",
6
+ "author": "AgiflowIO",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/AgiFlow/aicode-toolkit.git",
10
+ "directory": "packages/clawdbot-mcp-plugin"
11
+ },
12
+ "homepage": "https://github.com/AgiFlow/aicode-toolkit#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/AgiFlow/aicode-toolkit/issues"
15
+ },
16
+ "keywords": [
17
+ "typescript",
18
+ "library",
19
+ "clawdbot",
20
+ "mcp",
21
+ "plugin"
22
+ ],
23
+ "clawdbot": {
24
+ "extensions": [
25
+ "dist/plugin.js"
26
+ ]
27
+ },
28
+ "main": "./dist/index.cjs",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/index.d.cts",
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "clawdbot.plugin.json"
35
+ ],
36
+ "dependencies": {
37
+ "@sinclair/typebox": "^0.34.0",
38
+ "@agiflowai/one-mcp": "0.3.6"
39
+ },
40
+ "devDependencies": {
41
+ "@modelcontextprotocol/sdk": "1.24.0",
42
+ "@types/node": "^22.0.0",
43
+ "@vitest/coverage-v8": "^3.0.0",
44
+ "tsdown": "^0.15.6",
45
+ "typescript": "5.9.3",
46
+ "vitest": "4.0.15"
47
+ },
48
+ "peerDependencies": {
49
+ "clawdbot": ">=0.1.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "clawdbot": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "type": "module",
57
+ "exports": {
58
+ ".": {
59
+ "import": "./dist/index.js",
60
+ "require": "./dist/index.cjs"
61
+ },
62
+ "./plugin": {
63
+ "import": "./dist/plugin.js",
64
+ "require": "./dist/plugin.cjs"
65
+ },
66
+ "./package.json": "./package.json"
67
+ },
68
+ "scripts": {
69
+ "build": "tsdown",
70
+ "test": "vitest --run",
71
+ "typecheck": "tsc --noEmit"
72
+ }
73
+ }