@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.
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # @agiflowai/clawdbot-mcp-plugin
2
+
3
+ Clawdbot plugin for integrating Model Context Protocol (MCP) servers with progressive tool disclosure.
4
+
5
+ ## Overview
6
+
7
+ This plugin bridges the `@agiflowai/one-mcp` package to enable MCP server support in Clawdbot. It exposes only two tools (`mcp__describe_tools` and `mcp__use_tool`) using progressive disclosure, allowing agents to discover and use MCP tools on-demand without cluttering the tool list.
8
+
9
+ ## Features
10
+
11
+ - **Progressive Disclosure**: Only 2 tools registered (`mcp__describe_tools`, `mcp__use_tool`)
12
+ - **Dynamic Tool Discovery**: Tools are described on-demand, not pre-registered
13
+ - **Multiple MCP Servers**: Connect to multiple MCP servers simultaneously
14
+ - **Skill Support**: Integrate skills from file-based or prompt-based sources
15
+ - **Clean Separation**: Reuses one-mcp as a library dependency (no code duplication)
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @agiflowai/clawdbot-mcp-plugin
21
+ # or
22
+ pnpm add @agiflowai/clawdbot-mcp-plugin
23
+ ```
24
+
25
+ ## Configuration
26
+
27
+ ### Clawdbot Gateway Config
28
+
29
+ Add the plugin to your Clawdbot configuration (`~/.clawdbot/clawdbot.json`):
30
+
31
+ ```json
32
+ {
33
+ "plugins": {
34
+ "entries": {
35
+ "clawdbot-mcp-plugin": {
36
+ "enabled": true,
37
+ "config": {
38
+ "configFilePath": "/Users/username/.clawdbot/mcp-config.yaml",
39
+ "serverId": "clawdbot-toolkit",
40
+ "noCache": false
41
+ }
42
+ }
43
+ }
44
+ },
45
+ "agents": {
46
+ "list": [
47
+ {
48
+ "id": "main",
49
+ "tools": {
50
+ "allow": [
51
+ "mcp__describe_tools",
52
+ "mcp__use_tool"
53
+ ]
54
+ }
55
+ }
56
+ ]
57
+ }
58
+ }
59
+ ```
60
+
61
+ **Important**:
62
+ - Plugin config must be nested under `"config"` key
63
+ - Plugin ID in `entries` must match the plugin manifest ID: `"clawdbot-mcp-plugin"`
64
+ - Use absolute path for `configFilePath` to avoid path resolution issues
65
+
66
+ ### MCP Server Config
67
+
68
+ Create `.clawdbot/mcp-config.yaml`:
69
+
70
+ ```yaml
71
+ mcpServers:
72
+ memory:
73
+ name: "Memory Storage"
74
+ instruction: "Simple key-value storage"
75
+ transport: "stdio"
76
+ command: "npx"
77
+ args: ["-y", "@modelcontextprotocol/server-memory"]
78
+
79
+ filesystem:
80
+ name: "Filesystem Operations"
81
+ instruction: "File operations"
82
+ transport: "stdio"
83
+ command: "npx"
84
+ args: ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/workspace"]
85
+ ```
86
+
87
+ **Note**: `command` and `args` are at top level, NOT nested under `config`.
88
+
89
+ ## Usage
90
+
91
+ Agents use two tools to access MCP servers:
92
+
93
+ ```typescript
94
+ // 1. Discover tools
95
+ mcp__describe_tools({ toolNames: ["read_file", "write_file"] })
96
+
97
+ // 2. Execute tools
98
+ mcp__use_tool({
99
+ toolName: "read_file",
100
+ toolArgs: { path: "/path/to/file.txt" }
101
+ })
102
+ ```
103
+
104
+ ## Architecture
105
+
106
+ ### Plugin Structure
107
+
108
+ The plugin exports an object (not a function) with the following structure:
109
+
110
+ ```typescript
111
+ const mcpBridgePlugin = {
112
+ id: 'clawdbot-mcp-plugin',
113
+ name: 'MCP Server Bridge',
114
+ description: 'Enables MCP server integration...',
115
+ configSchema: Type.Object({
116
+ // TypeBox schema for config validation
117
+ }),
118
+ register(api: ClawdbotPluginApi) {
119
+ // Register services and tools
120
+ api.registerService({ id: 'mcp-server', start() {...}, stop() {...} });
121
+ api.registerTool({ name: 'mcp__describe_tools', ... }, { name: 'mcp__describe_tools' });
122
+ api.registerTool({ name: 'mcp__use_tool', ... }, { name: 'mcp__use_tool' });
123
+ }
124
+ };
125
+
126
+ export default mcpBridgePlugin;
127
+ ```
128
+
129
+ ### Plugin Lifecycle
130
+
131
+ 1. **Discovery & Loading**: Gateway scans plugin directories and loads manifests
132
+ 2. **Registration**: Gateway calls `plugin.register(api)` with Clawdbot API
133
+ 3. **Service Start**: Gateway calls all registered service `start()` methods (async initialization happens here)
134
+ 4. **Runtime**: Tools execute and forward requests to one-mcp
135
+ 5. **Service Stop**: Gateway calls service `stop()` methods on shutdown
136
+
137
+ ### Progressive Disclosure Pattern
138
+
139
+ - **Minimal Surface Area**: Only 2 tools exposed to agents
140
+ - **On-Demand Discovery**: Tools are described when requested via `mcp__describe_tools`
141
+ - **Dynamic Description**: Toolkit description generated after MCP servers connect
142
+ - **No Tool Bloat**: Avoid registering hundreds of individual MCP tools
143
+
144
+ ### Key Implementation Details
145
+
146
+ - **Plugin Object**: Exports object with `register()` method, not a plain function
147
+ - **Tool Registration**: Second parameter must be `{ name: 'tool_name' }`, not `{ optional: false }`
148
+ - **Service Registration**: Use `id:` property, not `name:`
149
+ - **API Access**: Use `api.pluginConfig` (not `api.getConfig()`), `api.logger` (not `api.log`), `api.registerTool`, `api.registerService`
150
+ - **Async Work**: Do all async initialization in `service.start()`, not in `register()` function
151
+
152
+ ## Development
153
+
154
+ ```bash
155
+ # Install dependencies
156
+ pnpm install
157
+
158
+ # Build the package
159
+ pnpm build
160
+
161
+ # Type check
162
+ pnpm typecheck
163
+
164
+ # Run tests
165
+ pnpm test
166
+ ```
167
+
168
+ ## Configuration Schema
169
+
170
+ The plugin accepts the following configuration options:
171
+
172
+ - `configFilePath` (string): Path to mcp-config.yaml file (default: `.clawdbot/mcp-config.yaml`)
173
+ - `serverId` (string): Unique identifier for the toolkit (default: `clawdbot-mcp`)
174
+ - `noCache` (boolean): Disable configuration caching (default: `false`)
175
+
176
+ ## Error Handling
177
+
178
+ - **Connection Failures**: Logged but don't crash the plugin
179
+ - **Tool Execution Errors**: Returned as structured error responses
180
+ - **Configuration Errors**: Validated against JSON schema, fail fast
181
+
182
+ ## License
183
+
184
+ AGPL-3.0
185
+
186
+ ## Contributing
187
+
188
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development guidelines.
@@ -0,0 +1,36 @@
1
+ {
2
+ "id": "clawdbot-mcp-plugin",
3
+ "name": "MCP Server Bridge",
4
+ "description": "Enables Model Context Protocol (MCP) server integration with progressive tool disclosure",
5
+ "version": "0.1.0",
6
+ "configSchema": {
7
+ "type": "object",
8
+ "properties": {
9
+ "configFilePath": {
10
+ "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": {
15
+ "type": "string",
16
+ "description": "Unique identifier for the toolkit",
17
+ "default": "clawdbot-mcp"
18
+ },
19
+ "noCache": {
20
+ "type": "boolean",
21
+ "description": "Disable configuration caching",
22
+ "default": false
23
+ }
24
+ }
25
+ },
26
+ "uiHints": {
27
+ "configFilePath": {
28
+ "label": "MCP Config File Path",
29
+ "placeholder": ".clawdbot/mcp-config.yaml"
30
+ },
31
+ "serverId": {
32
+ "label": "Server ID",
33
+ "placeholder": "clawdbot-mcp"
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,144 @@
1
+ //#region src/types/index.d.ts
2
+ /**
3
+ * @agiflowai/clawdbot-mcp-plugin - Type Definitions
4
+ *
5
+ * DESIGN PATTERNS:
6
+ * - Interface segregation: Keep interfaces focused and minimal
7
+ * - Type composition: Build complex types from simple primitives
8
+ * - Generics: Use type parameters for reusable, type-safe abstractions
9
+ *
10
+ * CODING STANDARDS:
11
+ * - Use PascalCase for type/interface names
12
+ * - Prefix interfaces with 'I' only for abstract contracts
13
+ * - Document complex types with JSDoc comments
14
+ * - Export all public types
15
+ *
16
+ * AVOID:
17
+ * - Any type unless absolutely necessary
18
+ * - Overly complex type gymnastics
19
+ * - Coupling types to implementation details
20
+ */
21
+ /**
22
+ * Clawdbot plugin configuration for one-mcp bridge.
23
+ * Simple config that just points to an mcp-config.yaml file.
24
+ */
25
+ interface PluginConfig {
26
+ /** Path to mcp-config.yaml file (supports one-mcp's YAML format) */
27
+ configFilePath?: string;
28
+ /** Unique identifier for the toolkit */
29
+ serverId?: string;
30
+ /** Disable configuration caching */
31
+ noCache?: boolean;
32
+ }
33
+ /**
34
+ * Tool definition for Clawdbot tool registration.
35
+ * Defines the structure and behavior of a Clawdbot tool.
36
+ */
37
+ interface ToolDefinition {
38
+ /** Unique tool name identifier */
39
+ name: string;
40
+ /** Human-readable tool description */
41
+ description: string;
42
+ /** JSON Schema for tool input parameters */
43
+ parameters: Record<string, unknown>;
44
+ /**
45
+ * Tool execution function
46
+ * @param id - Execution ID
47
+ * @param params - Tool input parameters
48
+ * @returns Tool execution result
49
+ */
50
+ execute: (id: string, params: Record<string, unknown>) => Promise<ToolResult>;
51
+ }
52
+ /**
53
+ * Tool execution result returned to Clawdbot.
54
+ * Matches MCP SDK CallToolResult structure.
55
+ */
56
+ interface ToolResult {
57
+ /** Result content array (can contain text, images, resources, etc.) */
58
+ content: Array<Record<string, unknown>>;
59
+ /** Whether the result represents an error */
60
+ isError?: boolean;
61
+ }
62
+ /**
63
+ * Tool registration options for Clawdbot.
64
+ * Note: The name field must match ToolDefinition.name for proper registration.
65
+ */
66
+ interface ToolOptions {
67
+ /** Tool name identifier (must match ToolDefinition.name) */
68
+ name: string;
69
+ }
70
+ /**
71
+ * Service definition for Clawdbot lifecycle management.
72
+ * Services can perform startup and cleanup tasks.
73
+ */
74
+ interface ServiceDefinition {
75
+ /** Unique service identifier */
76
+ id: string;
77
+ /**
78
+ * Service startup function
79
+ * Called when the gateway starts
80
+ */
81
+ start: () => Promise<void> | void;
82
+ /**
83
+ * Service shutdown function
84
+ * Called when the gateway stops
85
+ */
86
+ stop: () => Promise<void> | void;
87
+ }
88
+ /**
89
+ * Clawdbot API interface for plugin integration.
90
+ * Provides methods for registering tools and services with the Clawdbot gateway.
91
+ */
92
+ interface ClawdbotApi {
93
+ /**
94
+ * Plugin configuration object.
95
+ * Contains the configuration values for this plugin from clawdbot.json.
96
+ * Always present, even if empty object when no config provided.
97
+ */
98
+ pluginConfig: PluginConfig;
99
+ /**
100
+ * Register a tool with the Clawdbot gateway
101
+ * @param toolDef - The tool definition with name, description, and execute function
102
+ * @param options - Tool registration options with name identifier
103
+ * @example
104
+ * ```typescript
105
+ * api.registerTool(
106
+ * {
107
+ * name: 'mcp__describe_tools',
108
+ * description: 'Describe available MCP tools',
109
+ * parameters: { type: 'object', properties: {...} },
110
+ * execute: async (id, params) => ({
111
+ * content: [{ type: 'text', text: 'Tool list...' }]
112
+ * })
113
+ * },
114
+ * { name: 'mcp__describe_tools' }
115
+ * );
116
+ * ```
117
+ */
118
+ registerTool: (toolDef: ToolDefinition, options: ToolOptions) => void;
119
+ /**
120
+ * Register a service for lifecycle management
121
+ * @param service - The service definition with start and stop methods
122
+ */
123
+ registerService: (service: ServiceDefinition) => void;
124
+ /** Logging interface for plugin diagnostics */
125
+ logger: {
126
+ /**
127
+ * Log informational messages
128
+ * @param args - Message and optional additional data (strings, numbers, booleans)
129
+ */
130
+ info: (...args: (string | number | boolean)[]) => void;
131
+ /**
132
+ * Log error messages
133
+ * @param args - Error message and optional error details
134
+ */
135
+ error: (...args: (string | Error)[]) => void;
136
+ /**
137
+ * Log warning messages
138
+ * @param args - Warning message and optional additional data
139
+ */
140
+ warn: (...args: (string | number | boolean)[]) => void;
141
+ };
142
+ }
143
+ //#endregion
144
+ export { ToolOptions as a, ToolDefinition as i, PluginConfig as n, ToolResult as o, ServiceDefinition as r, ClawdbotApi as t };
@@ -0,0 +1,144 @@
1
+ //#region src/types/index.d.ts
2
+ /**
3
+ * @agiflowai/clawdbot-mcp-plugin - Type Definitions
4
+ *
5
+ * DESIGN PATTERNS:
6
+ * - Interface segregation: Keep interfaces focused and minimal
7
+ * - Type composition: Build complex types from simple primitives
8
+ * - Generics: Use type parameters for reusable, type-safe abstractions
9
+ *
10
+ * CODING STANDARDS:
11
+ * - Use PascalCase for type/interface names
12
+ * - Prefix interfaces with 'I' only for abstract contracts
13
+ * - Document complex types with JSDoc comments
14
+ * - Export all public types
15
+ *
16
+ * AVOID:
17
+ * - Any type unless absolutely necessary
18
+ * - Overly complex type gymnastics
19
+ * - Coupling types to implementation details
20
+ */
21
+ /**
22
+ * Clawdbot plugin configuration for one-mcp bridge.
23
+ * Simple config that just points to an mcp-config.yaml file.
24
+ */
25
+ interface PluginConfig {
26
+ /** Path to mcp-config.yaml file (supports one-mcp's YAML format) */
27
+ configFilePath?: string;
28
+ /** Unique identifier for the toolkit */
29
+ serverId?: string;
30
+ /** Disable configuration caching */
31
+ noCache?: boolean;
32
+ }
33
+ /**
34
+ * Tool definition for Clawdbot tool registration.
35
+ * Defines the structure and behavior of a Clawdbot tool.
36
+ */
37
+ interface ToolDefinition {
38
+ /** Unique tool name identifier */
39
+ name: string;
40
+ /** Human-readable tool description */
41
+ description: string;
42
+ /** JSON Schema for tool input parameters */
43
+ parameters: Record<string, unknown>;
44
+ /**
45
+ * Tool execution function
46
+ * @param id - Execution ID
47
+ * @param params - Tool input parameters
48
+ * @returns Tool execution result
49
+ */
50
+ execute: (id: string, params: Record<string, unknown>) => Promise<ToolResult>;
51
+ }
52
+ /**
53
+ * Tool execution result returned to Clawdbot.
54
+ * Matches MCP SDK CallToolResult structure.
55
+ */
56
+ interface ToolResult {
57
+ /** Result content array (can contain text, images, resources, etc.) */
58
+ content: Array<Record<string, unknown>>;
59
+ /** Whether the result represents an error */
60
+ isError?: boolean;
61
+ }
62
+ /**
63
+ * Tool registration options for Clawdbot.
64
+ * Note: The name field must match ToolDefinition.name for proper registration.
65
+ */
66
+ interface ToolOptions {
67
+ /** Tool name identifier (must match ToolDefinition.name) */
68
+ name: string;
69
+ }
70
+ /**
71
+ * Service definition for Clawdbot lifecycle management.
72
+ * Services can perform startup and cleanup tasks.
73
+ */
74
+ interface ServiceDefinition {
75
+ /** Unique service identifier */
76
+ id: string;
77
+ /**
78
+ * Service startup function
79
+ * Called when the gateway starts
80
+ */
81
+ start: () => Promise<void> | void;
82
+ /**
83
+ * Service shutdown function
84
+ * Called when the gateway stops
85
+ */
86
+ stop: () => Promise<void> | void;
87
+ }
88
+ /**
89
+ * Clawdbot API interface for plugin integration.
90
+ * Provides methods for registering tools and services with the Clawdbot gateway.
91
+ */
92
+ interface ClawdbotApi {
93
+ /**
94
+ * Plugin configuration object.
95
+ * Contains the configuration values for this plugin from clawdbot.json.
96
+ * Always present, even if empty object when no config provided.
97
+ */
98
+ pluginConfig: PluginConfig;
99
+ /**
100
+ * Register a tool with the Clawdbot gateway
101
+ * @param toolDef - The tool definition with name, description, and execute function
102
+ * @param options - Tool registration options with name identifier
103
+ * @example
104
+ * ```typescript
105
+ * api.registerTool(
106
+ * {
107
+ * name: 'mcp__describe_tools',
108
+ * description: 'Describe available MCP tools',
109
+ * parameters: { type: 'object', properties: {...} },
110
+ * execute: async (id, params) => ({
111
+ * content: [{ type: 'text', text: 'Tool list...' }]
112
+ * })
113
+ * },
114
+ * { name: 'mcp__describe_tools' }
115
+ * );
116
+ * ```
117
+ */
118
+ registerTool: (toolDef: ToolDefinition, options: ToolOptions) => void;
119
+ /**
120
+ * Register a service for lifecycle management
121
+ * @param service - The service definition with start and stop methods
122
+ */
123
+ registerService: (service: ServiceDefinition) => void;
124
+ /** Logging interface for plugin diagnostics */
125
+ logger: {
126
+ /**
127
+ * Log informational messages
128
+ * @param args - Message and optional additional data (strings, numbers, booleans)
129
+ */
130
+ info: (...args: (string | number | boolean)[]) => void;
131
+ /**
132
+ * Log error messages
133
+ * @param args - Error message and optional error details
134
+ */
135
+ error: (...args: (string | Error)[]) => void;
136
+ /**
137
+ * Log warning messages
138
+ * @param args - Warning message and optional additional data
139
+ */
140
+ warn: (...args: (string | number | boolean)[]) => void;
141
+ };
142
+ }
143
+ //#endregion
144
+ export { ToolOptions as a, ToolDefinition as i, PluginConfig as n, ToolResult as o, ServiceDefinition as r, ClawdbotApi as t };
package/dist/index.cjs ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ import { a as ToolOptions, i as ToolDefinition, n as PluginConfig, o as ToolResult, r as ServiceDefinition, t as ClawdbotApi } from "./index-BTWlYpm4.cjs";
2
+ export { ClawdbotApi, PluginConfig, ServiceDefinition, ToolDefinition, ToolOptions, ToolResult };
@@ -0,0 +1,2 @@
1
+ import { a as ToolOptions, i as ToolDefinition, n as PluginConfig, o as ToolResult, r as ServiceDefinition, t as ClawdbotApi } from "./index-Ca12Wuvd.js";
2
+ export { ClawdbotApi, PluginConfig, ServiceDefinition, ToolDefinition, ToolOptions, ToolResult };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { };