@actiondock/mcp 2.0.2 → 2.0.3

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.
Files changed (3) hide show
  1. package/README.md +49 -22
  2. package/package.json +2 -2
  3. package/src/http.ts +4 -7
package/README.md CHANGED
@@ -1,43 +1,70 @@
1
1
  # @actiondock/mcp
2
2
 
3
- Model Context Protocol (MCP) adapter for ActionDock 2.0.
3
+ ActionDock 2.0 模型上下文协议适配器。
4
4
 
5
- [![Bun](https://img.shields.io/badge/Bun-%3E%3D1.2-black?logo=bun)](https://bun.sh/)
5
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22-green?logo=node.js)](https://nodejs.org/)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?logo=typescript)](https://www.typescriptlang.org/)
7
+ [![MCP](https://img.shields.io/badge/MCP-Protocol%20Compliant-purple)](https://modelcontextprotocol.io/)
7
8
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
9
 
9
- > **Runtime requirement**: [Bun](https://bun.sh/) >= 1.2.0 is required.
10
-
11
- `@actiondock/mcp` connects ActionDock Actions directly to the Model Context Protocol (MCP), exposing Actions as fully-typed MCP Tools over STDIO and HTTP transports.
10
+ `@actiondock/mcp` ActionDock 中的原子 Action 映射为标准的模型上下文协议工具,无缝接入各类主流 AI 智能体与开发环境。
12
11
 
13
12
  ---
14
13
 
15
- ## Installation
14
+ ## 核心能力
16
15
 
17
- ```bash
18
- bun add @actiondock/mcp
19
- # or
20
- npm install @actiondock/mcp
21
- ```
16
+ ### 双协议传输通道
22
17
 
23
- ---
18
+ - **STDIO 标准输入输出通道**:专为本地客户端(如 Claude Code、Cursor、Windsurf 等开发工具)设计,直接通过子进程标准流双向通信,安全且免配置端口。
19
+ - **HTTP 传输通道**:专为远程服务与容器化部署设计,基于 Web 标准请求与响应实现流式传输,支持跨域策略配置与鉴权令牌校验。
20
+
21
+ ### 工具模式自动转换
22
+
23
+ - 自动解析每个 Action 的 `inputSchema` 与 `outputSchema`,转换为标准 MCP Tool 契约。
24
+ - 智能处理多包聚合场景下的动作标识冲突,自动使用包命名空间前缀消除歧义。
25
+ - 严格遵循输入格式校验,在参数违规时向模型返回结构化诊断提示。
26
+ - 执行结果自动封装为包含文本内容块与结构化数据的 MCP 格式信封,并在异常时正确标记错误标识。
27
+
28
+ ### 协同取消信号向下传播
29
+
30
+ - 当 MCP 客户端发起取消请求时,适配层自动捕获中断事件。
31
+ - 取消信号直接传递至底层的 `ActionRunner` 调度器,并联动激活当前任务上下文中的 `ctx.signal`。
32
+ - 业务代码可通过监听 `AbortSignal` 安全释放资源或提前终止执行。
33
+
34
+ ### Tasks 异步任务映射扩展
24
35
 
25
- ## Features
36
+ 针对长周期、重资源消耗的复杂任务,完整适配 MCP Tasks 异步协议扩展:
26
37
 
27
- - **STDIO & HTTP Transport**: Run locally via STDIO (for Claude Code, Cursor, Windsurf) or over HTTP with authentication and CORS.
28
- - **Dynamic Tool Mapping**: Automatically converts Action `inputSchema` / `outputSchema` into standard MCP Tool contracts.
29
- - **Cancellation Propagation**: Propagates MCP client cancellations directly to `ctx.signal` (`AbortSignal`).
30
- - **Tasks Extension**: Supports asynchronous background tool calls via MCP Tasks extension (`tasks/get`, `tasks/cancel`, `tasks/list`).
38
+ - **任务状态查询**:通过 `tasks/get` 端点根据任务标识检索当前运行状态、执行进度与部分输出快照。
39
+ - **任务主动取消**:通过 `tasks/cancel` 端点向正在后台执行的长周期任务发出中止指令。
40
+ - **任务清单列举**:通过 `tasks/list` 端点批量查询当前会话及宿主下的活跃与历史任务列表。
31
41
 
32
42
  ---
33
43
 
34
- ## 📖 Documentation
44
+ ## 快速使用
35
45
 
36
- - [MCP Integration Guide](../../docs/consumer/use-as-mcp.md)
37
- - [Action API Reference](../../docs/reference/action-api.md)
46
+ 通过命令行一键启动 MCP 服务:
47
+
48
+ ```bash
49
+ # 以 STDIO 协议启动
50
+ ad mcp
51
+
52
+ # 以 HTTP 协议启动并在指定端口监听
53
+ ad mcp --transport http --port 8080
54
+ ```
55
+
56
+ 也可以在代码中通过编程方式创建适配器服务:
57
+
58
+ ```ts
59
+ import { startMcpStdioServer } from "@actiondock/mcp";
60
+
61
+ await startMcpStdioServer({
62
+ projectRoot: process.cwd(),
63
+ });
64
+ ```
38
65
 
39
66
  ---
40
67
 
41
- ## License
68
+ ## 开源协议
42
69
 
43
- [Apache-2.0](../../LICENSE) © team4u
70
+ 本项目采用 Apache-2.0 开源协议。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actiondock/mcp",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "ActionDock MCP Adapter for exposing Actions as Model Context Protocol (MCP) Tools",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -17,7 +17,7 @@
17
17
  "README.md"
18
18
  ],
19
19
  "engines": {
20
- "bun": ">=1.2.0"
20
+ "node": ">=22.12.0"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public",
package/src/http.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  isLoopbackHost,
3
+ launchHttpServer,
3
4
  resolveCorsHeaders,
4
5
  ServerRuntimeRegistry,
5
6
  verifyBearerToken,
@@ -42,11 +43,7 @@ export function startMcpHttpServer(
42
43
  }
43
44
  );
44
45
 
45
-
46
- const server = Bun.serve({
47
- port,
48
- hostname: host,
49
- async fetch(req) {
46
+ const server = launchHttpServer(port, host, async (req) => {
50
47
  const origin = req.headers.get("origin");
51
48
  const corsHeaders = resolveCorsHeaders(origin, options.corsOrigins);
52
49
 
@@ -147,8 +144,8 @@ export function startMcpHttpServer(
147
144
  },
148
145
  }
149
146
  );
150
- },
151
- });
147
+ }
148
+ );
152
149
 
153
150
  const actualHost = host === "0.0.0.0" ? "127.0.0.1" : host;
154
151
  const url = `http://${actualHost}:${server.port}`;