@bigbrain-work/mcp-connect 1.0.0 → 1.2.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
@@ -2,9 +2,19 @@
2
2
 
3
3
  石榴 AI MCP 一键配置工具。用于将石榴 AI 的远程 MCP 服务接入 Codex、Claude Code 或 Cursor。
4
4
 
5
+ 客户不需要指定版本号。`npx` 会从 npm 获取 `latest` 对应的最新版:
6
+
5
7
  ## 使用
6
8
 
7
- 先在石榴 AI 页面复制当前账户的 API Key,然后执行对应命令:
9
+ 先在石榴 AI 页面复制当前账户的 API Key。推荐直接运行智能一键配置,安装器会检测本机已有的 Codex、Claude Code 和 Cursor:
10
+
11
+ ```bash
12
+ npx -y @bigbrain-work/mcp-connect
13
+ ```
14
+
15
+ 连接完成后,Agent 可通过同一个 MCP 地址调用 `get_openstoryline_installer`,获取 Windows 或 macOS 本地 AI 剪辑工具的短期安装地址。
16
+
17
+ 也可以明确指定客户端:
8
18
 
9
19
  ```bash
10
20
  npx -y @bigbrain-work/mcp-connect --agent codex
@@ -12,6 +22,15 @@ npx -y @bigbrain-work/mcp-connect --agent claude
12
22
  npx -y @bigbrain-work/mcp-connect --agent cursor
13
23
  ```
14
24
 
25
+ 其他 Agent 也可以使用任意名称,例如:
26
+
27
+ ```bash
28
+ npx -y @bigbrain-work/mcp-connect --agent openclaw
29
+ npx -y @bigbrain-work/mcp-connect --agent workbuddy
30
+ ```
31
+
32
+ 对于尚未内置配置适配器的 Agent,安装器不会修改未知配置文件,而是输出石榴 AI 的通用 HTTP MCP 地址和认证方式。
33
+
15
34
  安装器会隐藏输入 API Key。配置完成后,重启对应客户端并检查连接:
16
35
 
17
36
  ```bash
@@ -31,6 +50,7 @@ npx -y @bigbrain-work/mcp-connect status
31
50
  ## 服务信息
32
51
 
33
52
  - MCP 地址:`https://api.bigbrain.work/shiliu/mcp`
53
+ - MCP 地址是 Agent 连接服务所用的完整 HTTP 接口地址,不需要另配其他域名。
34
54
  - 认证方式:`Authorization: Bearer <API_KEY>`
35
55
  - 配置名称:`shiliu_mcp`
36
56
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bigbrain-work/mcp-connect",
3
- "version": "1.0.0",
4
- "description": "石榴 AI MCP 一键配置工具,支持 Codex、Claude Code Cursor。",
3
+ "version": "1.2.0",
4
+ "description": "石榴 AI MCP 智能配置工具,支持自动检测、通用 HTTP MCP 接入和本地 AI 剪辑工具安装。",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "mcp-connect": "bin/mcp-connect.js"
package/src/arguments.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import { parseArgs } from 'node:util'
2
2
 
3
- import { SUPPORTED_AGENTS } from './constants.js'
4
-
5
3
  export function parseCliArguments(args) {
6
4
  const parsed = parseArgs({
7
5
  args,
@@ -38,11 +36,8 @@ export function parseCliArguments(args) {
38
36
  }
39
37
 
40
38
  const agent = parsed.values.agent?.toLowerCase()
41
- if (agent && !SUPPORTED_AGENTS.includes(agent)) {
42
- throw new Error(`不支持的客户端:${agent}。可选值:${SUPPORTED_AGENTS.join('')}`)
43
- }
44
- if (command === 'install' && !agent && !parsed.values.help && !parsed.values.version) {
45
- throw new Error('请通过 --agent 指定客户端:codex、claude 或 cursor')
39
+ if (agent && !/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(agent)) {
40
+ throw new Error('客户端名称只能包含小写字母、数字、下划线和连字符')
46
41
  }
47
42
 
48
43
  return {
package/src/cli.js CHANGED
@@ -3,11 +3,13 @@ import path from 'node:path'
3
3
 
4
4
  import { parseCliArguments } from './arguments.js'
5
5
  import { configureAgent } from './configurators.js'
6
+ import { detectInstalledAgents } from './detection.js'
6
7
  import {
7
8
  API_KEY_ENV,
8
9
  MCP_URL,
9
10
  PACKAGE_NAME,
10
11
  PACKAGE_VERSION,
12
+ SERVER_NAME,
11
13
  SUPPORTED_AGENTS,
12
14
  } from './constants.js'
13
15
  import { persistApiKey, resolveApiKey } from './credentials.js'
@@ -17,7 +19,8 @@ function printHelp() {
17
19
  console.log(`${PACKAGE_NAME} ${PACKAGE_VERSION}
18
20
 
19
21
  用法:
20
- mcp-connect --agent <${SUPPORTED_AGENTS.join('|')}>
22
+ mcp-connect
23
+ mcp-connect --agent <name>
21
24
  mcp-connect status
22
25
 
23
26
  选项:
@@ -29,7 +32,21 @@ function printHelp() {
29
32
 
30
33
  认证:
31
34
  安装器优先读取 ${API_KEY_ENV};未设置时会隐藏提示输入。
32
- 真实 API Key 不会写入生成的 MCP 配置。`)
35
+ 真实 API Key 不会写入生成的 MCP 配置。
36
+
37
+ 智能配置:
38
+ 不指定 --agent 时,自动检测并配置已安装的 ${SUPPORTED_AGENTS.join('、')}。
39
+ 其他 Agent 名称也可传入;未内置适配器时会输出通用 HTTP MCP 配置。`)
40
+ }
41
+
42
+ function printGenericInstructions(agent, { dryRun = false } = {}) {
43
+ console.log(`暂未内置 ${agent} 的自动配置适配器,请在该 Agent 中添加远程 HTTP MCP:
44
+
45
+ 名称:${SERVER_NAME}
46
+ 地址:${MCP_URL}
47
+ 认证头:Authorization: Bearer <你的石榴 AI API Key>
48
+
49
+ ${dryRun ? `演练模式未保存 API Key;正式运行时会安全保存到 ${API_KEY_ENV}。` : `API Key 已安全保存到 ${API_KEY_ENV}。`}请勿将真实 API Key 写入项目代码或提交到 Git。`)
33
50
  }
34
51
 
35
52
  export async function runCli(argv = process.argv.slice(2)) {
@@ -57,12 +74,28 @@ export async function runCli(argv = process.argv.slice(2)) {
57
74
  dryRun: options.dryRun,
58
75
  home,
59
76
  })
60
- await configureAgent(options.agent, {
61
- dryRun: options.dryRun,
62
- home,
63
- })
77
+ const requestedAgent = options.agent === 'auto' ? undefined : options.agent
78
+ if (requestedAgent && !SUPPORTED_AGENTS.includes(requestedAgent)) {
79
+ printGenericInstructions(requestedAgent, { dryRun: options.dryRun })
80
+ return
81
+ }
82
+
83
+ const agents = requestedAgent
84
+ ? [requestedAgent]
85
+ : await detectInstalledAgents({ home })
86
+ if (agents.length === 0) {
87
+ printGenericInstructions('当前客户端', { dryRun: options.dryRun })
88
+ return
89
+ }
90
+
91
+ for (const agent of agents) {
92
+ await configureAgent(agent, {
93
+ dryRun: options.dryRun,
94
+ home,
95
+ })
96
+ }
64
97
 
65
98
  console.log(options.dryRun
66
- ? `检查完成:将为 ${options.agent} 配置 ${MCP_URL},未写入任何文件。`
67
- : `配置完成:${options.agent} 已接入石榴 AI MCP。请重启客户端后运行 ${PACKAGE_NAME} status 检查连接。`)
99
+ ? `检查完成:将为 ${agents.join('、')} 配置 ${MCP_URL},未写入任何文件。`
100
+ : `配置完成:${agents.join('、')} 已接入石榴 AI MCP。请重启客户端后运行 ${PACKAGE_NAME} status 检查连接。`)
68
101
  }
package/src/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const PACKAGE_NAME = '@bigbrain-work/mcp-connect'
2
- export const PACKAGE_VERSION = '1.0.0'
2
+ export const PACKAGE_VERSION = '1.2.0'
3
3
  export const SERVER_NAME = 'shiliu_mcp'
4
4
  export const MCP_URL = 'https://api.bigbrain.work/shiliu/mcp'
5
5
  export const API_KEY_ENV = 'SHILIU_AI_API_KEY'
@@ -0,0 +1,41 @@
1
+ import { access } from 'node:fs/promises'
2
+ import path from 'node:path'
3
+ import { spawnSync } from 'node:child_process'
4
+
5
+
6
+ export function commandExists(command, spawn = spawnSync) {
7
+ const result = spawn(command, ['--version'], {
8
+ encoding: 'utf8',
9
+ windowsHide: true,
10
+ shell: false,
11
+ timeout: 5000,
12
+ })
13
+ return !result.error && result.status === 0
14
+ }
15
+
16
+ async function pathExists(targetPath) {
17
+ try {
18
+ await access(targetPath)
19
+ return true
20
+ } catch {
21
+ return false
22
+ }
23
+ }
24
+
25
+ export async function detectInstalledAgents({
26
+ home,
27
+ hasCommand = commandExists,
28
+ exists = pathExists,
29
+ } = {}) {
30
+ const agents = []
31
+ if (hasCommand('codex')) {
32
+ agents.push('codex')
33
+ }
34
+ if (hasCommand('claude')) {
35
+ agents.push('claude')
36
+ }
37
+ if (hasCommand('cursor') || await exists(path.join(home, '.cursor'))) {
38
+ agents.push('cursor')
39
+ }
40
+ return agents
41
+ }