shizai-agent-mcp 0.1.2 → 0.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 +10 -6
- package/bin/shizai-agent-mcp.js +53 -10
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# shizai-agent-mcp
|
|
2
2
|
|
|
3
|
-
实在 Agent 本地 MCP 的 npm/npx
|
|
3
|
+
实在 Agent 本地 MCP 的 npm/npx 安装器。一个 npm 包同时提供 Shizai MCP、BrowserMCP 和 Playwright MCP 注册能力,用户不需要分别安装多个 npm 包。
|
|
4
4
|
|
|
5
5
|
## 使用
|
|
6
6
|
|
|
7
7
|
```powershell
|
|
8
8
|
npx -y shizai-agent-mcp install
|
|
9
|
-
npx -y shizai-agent-mcp register codex
|
|
9
|
+
npx -y shizai-agent-mcp register codex --with-browsers
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
也可以注册 Cursor 或 Claude Desktop:
|
|
13
13
|
|
|
14
14
|
```powershell
|
|
15
|
-
npx -y shizai-agent-mcp register cursor
|
|
16
|
-
npx -y shizai-agent-mcp register claude
|
|
15
|
+
npx -y shizai-agent-mcp register cursor --with-browsers
|
|
16
|
+
npx -y shizai-agent-mcp register claude --with-browsers
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
常用命令:
|
|
@@ -24,8 +24,12 @@ npx -y shizai-agent-mcp path
|
|
|
24
24
|
npx -y shizai-agent-mcp uninstall
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
当前 npm launcher 版本为 `0.
|
|
28
|
-
`shizai-agent-v0.
|
|
27
|
+
当前 npm launcher 版本为 `0.2.0`,默认下载最新的 `v0.6.0` Windows x64 资产:
|
|
28
|
+
`shizai-agent-v0.6.0-windows-x64.zip`。`@playwright/mcp` 会作为 npm 依赖自动安装。
|
|
29
|
+
|
|
30
|
+
注册默认会加入 `browsermcp` 服务,它配合 Browser MCP Chrome 扩展连接当前已登录标签页;
|
|
31
|
+
`--with-playwright` 或 `--with-browsers` 会额外加入隔离的 `playwright` 服务。
|
|
32
|
+
`--playwright-only` 可关闭默认的 BrowserMCP。
|
|
29
33
|
|
|
30
34
|
发布 Release 时需要同时上传同名 `.sha256` 文件。测试企业内网镜像时,可设置
|
|
31
35
|
`SHIZAI_AGENT_RELEASE_BASE_URL`;测试其他版本可设置 `SHIZAI_AGENT_VERSION`。
|
package/bin/shizai-agent-mcp.js
CHANGED
|
@@ -9,7 +9,9 @@ const { execFileSync, spawn } = require('node:child_process');
|
|
|
9
9
|
|
|
10
10
|
const SERVER = 'shizai-agent';
|
|
11
11
|
const REPO = process.env.SHIZAI_AGENT_REPO || 'yimoxzy/shizai-agent';
|
|
12
|
-
const DEFAULT_VERSION = process.env.SHIZAI_AGENT_VERSION || '0.
|
|
12
|
+
const DEFAULT_VERSION = process.env.SHIZAI_AGENT_VERSION || '0.6.0';
|
|
13
|
+
const BROWSERMCP_VERSION = process.env.SHIZAI_BROWSERMCP_VERSION || '0.1.3';
|
|
14
|
+
const PLAYWRIGHT_VERSION = process.env.SHIZAI_PLAYWRIGHT_VERSION || '0.0.79';
|
|
13
15
|
const installRoot = process.env.SHIZAI_AGENT_HOME || path.join(
|
|
14
16
|
process.env.LOCALAPPDATA || path.join(os.homedir(), '.local'), 'Programs', 'ShizaiAgent'
|
|
15
17
|
);
|
|
@@ -17,7 +19,7 @@ const installRoot = process.env.SHIZAI_AGENT_HOME || path.join(
|
|
|
17
19
|
function fail(message) { console.error(`shizai-agent-mcp: ${message}`); process.exitCode = 1; }
|
|
18
20
|
function json(value) { console.log(JSON.stringify(value, null, 2)); }
|
|
19
21
|
function help() {
|
|
20
|
-
console.log(`Shizai Agent MCP installer\n\nUsage:\n shizai-agent-mcp install [--version VERSION]\n shizai-agent-mcp register <codex|cursor|claude
|
|
22
|
+
console.log(`Shizai Agent MCP installer\n\nUsage:\n shizai-agent-mcp install [--version VERSION]\n shizai-agent-mcp register <codex|cursor|claude> [--with-browsermcp]\n shizai-agent-mcp register <codex|cursor|claude> [--with-playwright]\n shizai-agent-mcp register <codex|cursor|claude> --with-browsers\n shizai-agent-mcp status\n shizai-agent-mcp path\n shizai-agent-mcp uninstall\n\nEnvironment:\n SHIZAI_AGENT_VERSION Release version (default: ${DEFAULT_VERSION})\n SHIZAI_AGENT_HOME Installation directory\n SHIZAI_AGENT_REPO GitHub repository owner/name\n SHIZAI_AGENT_RELEASE_BASE_URL Override release asset base URL\n SHIZAI_BROWSERMCP_VERSION BrowserMCP version (default: ${BROWSERMCP_VERSION})\n SHIZAI_PLAYWRIGHT_VERSION Bundled Playwright MCP version (default: ${PLAYWRIGHT_VERSION})\n`);
|
|
21
23
|
}
|
|
22
24
|
function binaryPath() { return path.join(installRoot, 'shizai-agent-mcp.exe'); }
|
|
23
25
|
function psQuote(value) { return `'${String(value).replaceAll("'", "''")}'`; }
|
|
@@ -75,16 +77,47 @@ function replaceTomlSection(content, section, replacement) {
|
|
|
75
77
|
const next = content.replace(pattern, '').trimEnd();
|
|
76
78
|
return `${next}${next ? '\r\n\r\n' : ''}${replacement.trim()}\r\n`;
|
|
77
79
|
}
|
|
78
|
-
function
|
|
80
|
+
function playwrightSpec() {
|
|
81
|
+
try {
|
|
82
|
+
const packageJSON = require.resolve('@playwright/mcp/package.json');
|
|
83
|
+
const packageRoot = path.dirname(packageJSON);
|
|
84
|
+
return { command: process.execPath, args: [path.join(packageRoot, 'cli.js')] };
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return { command: 'npx', args: ['-y', `@playwright/mcp@${PLAYWRIGHT_VERSION}`] };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function browserMcpSpec() {
|
|
90
|
+
try {
|
|
91
|
+
const packageJSON = require.resolve('@browsermcp/mcp/package.json');
|
|
92
|
+
const packageRoot = path.dirname(packageJSON);
|
|
93
|
+
return { command: process.execPath, args: [path.join(packageRoot, 'dist', 'index.js')] };
|
|
94
|
+
} catch (error) {
|
|
95
|
+
return { command: 'npx', args: ['-y', `@browsermcp/mcp@${BROWSERMCP_VERSION}`] };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function tomlString(value) { return JSON.stringify(String(value)); }
|
|
99
|
+
function tomlArray(values) { return `[${values.map(tomlString).join(', ')}]`; }
|
|
100
|
+
function registerCodex(withPlaywright = false, withBrowserMcp = true) {
|
|
79
101
|
const config = process.env.SHIZAI_CODEX_CONFIG || path.join(os.homedir(), '.codex', 'config.toml');
|
|
80
102
|
fs.mkdirSync(path.dirname(config), { recursive: true });
|
|
81
103
|
const old = fs.existsSync(config) ? fs.readFileSync(config, 'utf8') : '';
|
|
82
104
|
if (old) fs.copyFileSync(config, `${config}.shizai-agent.bak`);
|
|
83
105
|
const section = `[mcp_servers.${SERVER}]\ncommand = ${psQuote(binaryPath())}\nargs = []\nstartup_timeout_sec = 30\ntool_timeout_sec = 120`;
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
let next = replaceTomlSection(old, `mcp_servers.${SERVER}`, section);
|
|
107
|
+
if (withPlaywright) {
|
|
108
|
+
const spec = playwrightSpec();
|
|
109
|
+
const browserSection = `[mcp_servers.playwright]\ncommand = ${tomlString(spec.command)}\nargs = ${tomlArray(spec.args)}\nstartup_timeout_sec = 30\ntool_timeout_sec = 120`;
|
|
110
|
+
next = replaceTomlSection(next, 'mcp_servers.playwright', browserSection);
|
|
111
|
+
}
|
|
112
|
+
if (withBrowserMcp) {
|
|
113
|
+
const spec = browserMcpSpec();
|
|
114
|
+
const browserMcpSection = `[mcp_servers.browsermcp]\ncommand = ${tomlString(spec.command)}\nargs = ${tomlArray(spec.args)}\nstartup_timeout_sec = 30\ntool_timeout_sec = 120`;
|
|
115
|
+
next = replaceTomlSection(next, 'mcp_servers.browsermcp', browserMcpSection);
|
|
116
|
+
}
|
|
117
|
+
fs.writeFileSync(config, next, 'utf8');
|
|
118
|
+
json({ registered: true, client: 'codex', config, command: binaryPath(), browsermcp: withBrowserMcp ? browserMcpSpec() : null, playwright: withPlaywright ? playwrightSpec() : null });
|
|
86
119
|
}
|
|
87
|
-
function registerJsonClient(client) {
|
|
120
|
+
function registerJsonClient(client, withPlaywright = false, withBrowserMcp = true) {
|
|
88
121
|
const locations = {
|
|
89
122
|
cursor: process.env.SHIZAI_CURSOR_CONFIG || path.join(process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'), 'Cursor', 'User', 'globalStorage', 'mcp.json'),
|
|
90
123
|
claude: process.env.SHIZAI_CLAUDE_CONFIG || path.join(process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json')
|
|
@@ -95,8 +128,16 @@ function registerJsonClient(client) {
|
|
|
95
128
|
const data = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
|
|
96
129
|
data.mcpServers = data.mcpServers || {};
|
|
97
130
|
data.mcpServers[SERVER] = { command: binaryPath(), args: [] };
|
|
131
|
+
if (withPlaywright) {
|
|
132
|
+
const spec = playwrightSpec();
|
|
133
|
+
data.mcpServers.playwright = { command: spec.command, args: spec.args };
|
|
134
|
+
}
|
|
135
|
+
if (withBrowserMcp) {
|
|
136
|
+
const spec = browserMcpSpec();
|
|
137
|
+
data.mcpServers.browsermcp = { command: spec.command, args: spec.args };
|
|
138
|
+
}
|
|
98
139
|
fs.writeFileSync(file, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
|
|
99
|
-
json({ registered: true, client, config: file, command: binaryPath() });
|
|
140
|
+
json({ registered: true, client, config: file, command: binaryPath(), browsermcp: withBrowserMcp ? browserMcpSpec() : null, playwright: withPlaywright ? playwrightSpec() : null });
|
|
100
141
|
}
|
|
101
142
|
function launch() {
|
|
102
143
|
if (!fs.existsSync(binaryPath())) install(DEFAULT_VERSION);
|
|
@@ -113,11 +154,13 @@ function main() {
|
|
|
113
154
|
}
|
|
114
155
|
if (command === 'register') {
|
|
115
156
|
if (!fs.existsSync(binaryPath())) throw new Error('尚未安装,请先运行 install');
|
|
116
|
-
|
|
117
|
-
|
|
157
|
+
const withPlaywright = rest.includes('--with-playwright') || rest.includes('--with-browsers');
|
|
158
|
+
const withBrowserMcp = !rest.includes('--playwright-only');
|
|
159
|
+
if (target === 'codex') return registerCodex(withPlaywright, withBrowserMcp);
|
|
160
|
+
if (target === 'cursor' || target === 'claude') return registerJsonClient(target, withPlaywright, withBrowserMcp);
|
|
118
161
|
throw new Error('请指定 codex、cursor 或 claude');
|
|
119
162
|
}
|
|
120
|
-
if (command === 'status') return json({ installed: fs.existsSync(binaryPath()), directory: installRoot, command: binaryPath(), versionFile: path.join(installRoot, 'version.json') });
|
|
163
|
+
if (command === 'status') return json({ installed: fs.existsSync(binaryPath()), directory: installRoot, command: binaryPath(), versionFile: path.join(installRoot, 'version.json'), browsermcp: browserMcpSpec(), playwright: playwrightSpec() });
|
|
121
164
|
if (command === 'path') return console.log(binaryPath());
|
|
122
165
|
if (command === 'uninstall') { if (fs.existsSync(installRoot)) fs.rmSync(installRoot, { recursive: true, force: true }); return json({ uninstalled: true, directory: installRoot }); }
|
|
123
166
|
throw new Error(`未知命令:${command}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shizai-agent-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Installer and launcher for the Shizai Agent local MCP server",
|
|
5
5
|
"bin": {
|
|
6
6
|
"shizai-agent-mcp": "bin/shizai-agent-mcp.js"
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"bin",
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@browsermcp/mcp": "0.1.3",
|
|
17
|
+
"@playwright/mcp": "0.0.79"
|
|
18
|
+
},
|
|
15
19
|
"keywords": ["mcp", "shizai-agent", "codex", "cursor", "claude"],
|
|
16
20
|
"license": "MIT"
|
|
17
21
|
}
|