dsh-cothread-mcp 0.0.0-stage → 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 CHANGED
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # dsh-cothread-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 连接 **共序 CoThread** 远程 MCP 服务器,让 DeepSeek Harness 直接读写项目、迭代、任务、文档与群聊消息。
4
+
5
+ CoThread 是按账号身份和项目成员权限协作的 MCP 服务。本插件把该服务注册成 `mcp__cothread-mcp__*` 工具,模型即可在会话里调用。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ dsh plugin --profile web add dsh-cothread-mcp
11
+ ```
12
+
13
+ 安装后重启 DeepSeek Harness。
14
+
15
+ ## 配置
16
+
17
+ 插件在 profile 配置里声明以下字段:
18
+
19
+ | 字段 | 说明 |
20
+ | --- | --- |
21
+ | `url` | CoThread MCP 端点,默认 `https://cothread.z2l.top/mcp` |
22
+ | `serverName` | 工具前缀名,默认 `cothread-mcp`,工具名形如 `mcp__cothread-mcp__list_projects` |
23
+ | `token` | 账号令牌。只保存在插件配置里,不写入源码或日志 |
24
+
25
+ ```yaml
26
+ - id: cothread-mcp
27
+ name: dsh-cothread-mcp
28
+ config:
29
+ url: https://cothread.z2l.top/mcp
30
+ serverName: cothread-mcp
31
+ token: <你的账号令牌>
32
+ ```
33
+
34
+ ## 安全说明
35
+
36
+ - 令牌仅在该插件的配置中保存,不会出现在工具参数、源码或日志里。
37
+ - 服务端按账号身份与项目成员权限校验,插件不额外放大权限。
38
+ - 只读成员可读取,写入类操作受服务端权限约束。
39
+
40
+ ## 兼容性
41
+
42
+ - DeepSeek Harness:`>=0.2.1-rc.2 <0.3.0-0`,已在 0.2.1-rc.5 与 0.2.2-rc.1 上验证。
43
+ - Node.js:`>=22.19.0`。
44
+
45
+ ## 卸载
46
+
47
+ ```bash
48
+ dsh plugin --profile <name> remove dsh-cothread-mcp
49
+ ```
50
+
51
+ ## 许可证
52
+
53
+ MIT
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: cothread-mcp
3
+ name: dsh-cothread-mcp
package/icon.svg ADDED
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M9 7H6a5 5 0 0 0 0 10h3" />
3
+ <path d="M15 7h3a5 5 0 0 1 0 10h-3" />
4
+ <path d="M8.5 12h7" />
5
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "dsh-cothread-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "连接共序 CoThread 远程 MCP(https://cothread.z2l.top/mcp),按账号身份与项目成员权限协作。令牌只保存在插件配置里,不写入源码或日志。",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "src/index.js",
8
+ "exports": {
9
+ ".": "./src/index.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "src",
14
+ "cordis.patch.yml",
15
+ "icon.svg",
16
+ "README.md"
17
+ ],
18
+ "engines": {
19
+ "node": ">=22.19.0",
20
+ "dsh": ">=0.2.1-rc.2 <0.3.0-0"
21
+ },
22
+ "keywords": [
23
+ "dsh",
24
+ "dsh-plugin",
25
+ "deepseek",
26
+ "deepseek-harness",
27
+ "cordis",
28
+ "mcp",
29
+ "cothread"
30
+ ],
31
+ "icon": "./icon.svg",
32
+ "dsh": {
33
+ "manifestVersion": 1,
34
+ "bundle": {
35
+ "patch": "./cordis.patch.yml"
36
+ }
37
+ },
38
+ "peerDependencies": {
39
+ "@deepseek-ai/cordis": ">=4.0.4 <5.0.0",
40
+ "@deepseek-ai/dsh-mcp-client": ">=0.2.1-0 <0.3.0-0 || >=0.2.2-0 <0.3.0-0",
41
+ "@deepseek-ai/schemastery": ">=3.18.4 <4.0.0"
42
+ }
43
+ }
package/src/index.js ADDED
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @module dsh-cothread-mcp
3
+ *
4
+ * 把共序 CoThread 的远程 MCP(Streamable HTTP)挂到 DeepSeek Harness。
5
+ *
6
+ * 令牌只从插件配置读取,不写进源码,也不写进日志:连接失败时只报地址与状态,
7
+ * 不打印 Authorization 头的值。
8
+ */
9
+ import { apply as connectMcp, Config as McpConfig } from "@deepseek-ai/dsh-mcp-client";
10
+ import z from "@deepseek-ai/schemastery";
11
+
12
+ export const name = "cothread-mcp";
13
+ export const inject = ["tools"];
14
+
15
+ const DEFAULT_URL = "https://cothread.z2l.top/mcp";
16
+ const SERVER_NAME = /^[A-Za-z0-9_-]{1,32}$/;
17
+ const TOOL_CALL_TIMEOUT_MS = 180_000;
18
+
19
+ export const Config = z.object({
20
+ url: z.string().default(DEFAULT_URL),
21
+ serverName: z.string().pattern(SERVER_NAME).default("cothread-mcp"),
22
+ token: z.string().default(""),
23
+ toolCallTimeoutMs: z.number().default(TOOL_CALL_TIMEOUT_MS),
24
+ });
25
+
26
+ const mcpPlugin = {
27
+ name: "cothread-mcp-connection",
28
+ inject: ["tools"],
29
+ Config: McpConfig,
30
+ apply: connectMcp,
31
+ };
32
+
33
+ export function cothreadHeaders(token) {
34
+ const key = String(token || "").trim();
35
+ if (key === "") return undefined;
36
+ if (/[\r\n]/.test(key)) throw new Error("CoThread 令牌必须是单行文本");
37
+ return { Authorization: `Bearer ${key}` };
38
+ }
39
+
40
+ export function cothreadEndpoint(raw) {
41
+ const url = new URL(String(raw || DEFAULT_URL));
42
+ if (url.protocol !== "https:" && url.protocol !== "http:")
43
+ throw new Error("CoThread MCP 地址必须使用 http 或 https");
44
+ if (url.username !== "" || url.password !== "")
45
+ throw new Error("CoThread MCP 地址不能携带账号密码");
46
+ return url.href;
47
+ }
48
+
49
+ export async function apply(ctx, config) {
50
+ let endpoint;
51
+ let headers;
52
+ try {
53
+ endpoint = cothreadEndpoint(config.url);
54
+ headers = cothreadHeaders(config.token);
55
+ } catch (error) {
56
+ ctx.logger.error("CoThread MCP 配置无效。请检查 url 与令牌,不要把令牌写进地址。");
57
+ ctx.logger.error(String(error?.message || error));
58
+ return;
59
+ }
60
+ if (!headers)
61
+ ctx.logger.warn("CoThread MCP 未填写令牌,将在未授权状态下连接(服务端会返回 401)。");
62
+
63
+ const fiber = ctx.plugin(mcpPlugin, {
64
+ transport: "streamable-http",
65
+ serverName: config.serverName,
66
+ url: endpoint,
67
+ ...(headers ? { headers } : {}),
68
+ toolCallTimeoutMs: Number(config.toolCallTimeoutMs) || TOOL_CALL_TIMEOUT_MS,
69
+ failOnStartupError: false,
70
+ });
71
+ void Promise.resolve(fiber).catch((error) => {
72
+ ctx.logger.error("CoThread MCP 连接失败。请检查地址与令牌是否有效(令牌不会写入日志)。");
73
+ ctx.logger.error(String(error?.message || error));
74
+ });
75
+ }