cwtools-mcp 0.2.0 → 0.2.2
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 +279 -279
- package/package.json +46 -46
package/README.md
CHANGED
|
@@ -1,279 +1,279 @@
|
|
|
1
|
-
# cwtools-mcp
|
|
2
|
-
|
|
3
|
-
[English](#english) | [中文](#zh-cn)
|
|
4
|
-
|
|
5
|
-
<a id="english"></a>
|
|
6
|
-
|
|
7
|
-
## English
|
|
8
|
-
|
|
9
|
-
CWTools MCP is the external-agent entry point for this extension's Paradox /
|
|
10
|
-
Stellaris semantic tools.
|
|
11
|
-
|
|
12
|
-
### Default Mode: Extension Bridge
|
|
13
|
-
|
|
14
|
-
By default, `cwtools-mcp` is a lightweight MCP proxy. It does **not** start a
|
|
15
|
-
second `CWTools Server` process. Instead, it connects to the MCP bridge started
|
|
16
|
-
inside the active VS Code-compatible extension host and reuses that host's:
|
|
17
|
-
|
|
18
|
-
- existing CWTools language client;
|
|
19
|
-
- current workspace root;
|
|
20
|
-
- Problems diagnostics from the IDE;
|
|
21
|
-
- rules/cache/localisation/user settings;
|
|
22
|
-
- shared indexes and AI read tools.
|
|
23
|
-
|
|
24
|
-
This keeps memory use low and makes MCP diagnostics match the IDE.
|
|
25
|
-
|
|
26
|
-
Bridge mode is deliberately strict about project identity without requiring a
|
|
27
|
-
project path in global MCP settings. By default, the proxy discovers the current
|
|
28
|
-
client workspace from MCP roots, known per-session environment variables, or the
|
|
29
|
-
MCP process cwd. That workspace must match the `workspaceRoot` served by the
|
|
30
|
-
extension bridge. If they do not match, tool calls return `bridge_unavailable`
|
|
31
|
-
instead of silently answering from a different project. `--workspace` remains an
|
|
32
|
-
optional override for clients that cannot expose a per-project root.
|
|
33
|
-
|
|
34
|
-
The extension writes both files below into the current host's own
|
|
35
|
-
`globalStorage/mcp/` directory when the project is active:
|
|
36
|
-
|
|
37
|
-
```text
|
|
38
|
-
cwtools-mcp.cjs
|
|
39
|
-
bridge-manifest.json
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
External agents should run the `cwtools-mcp.cjs` copied by the same host they are
|
|
43
|
-
using. The proxy reads `bridge-manifest.json` next to itself. This is host-name
|
|
44
|
-
agnostic: VS Code, Cursor, VSCodium, Antigravity, and other compatible hosts all
|
|
45
|
-
work as long as they support the VS Code extension APIs and activate this
|
|
46
|
-
extension.
|
|
47
|
-
|
|
48
|
-
### Quick Setup
|
|
49
|
-
|
|
50
|
-
Use the `globalStorage` path from the compatible host where the extension is
|
|
51
|
-
active. The placeholder below means the directory that contains the host's
|
|
52
|
-
`foreverskywalker.foreverskywalker-stellaris-cwtools` global storage folder.
|
|
53
|
-
|
|
54
|
-
#### Codex
|
|
55
|
-
|
|
56
|
-
```sh
|
|
57
|
-
codex mcp add cwtools -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
#### Claude Code
|
|
61
|
-
|
|
62
|
-
```sh
|
|
63
|
-
claude mcp add cwtools --scope user -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
#### Antigravity
|
|
67
|
-
|
|
68
|
-
Antigravity reads MCP servers from `~/.gemini/config/mcp_config.json`. Add this
|
|
69
|
-
server entry:
|
|
70
|
-
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"mcpServers": {
|
|
74
|
-
"cwtools": {
|
|
75
|
-
"command": "node",
|
|
76
|
-
"args": [
|
|
77
|
-
"<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs",
|
|
78
|
-
"--stdio"
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Or merge it into an existing config with a Node one-liner:
|
|
86
|
-
|
|
87
|
-
```sh
|
|
88
|
-
node -e "const fs=require('fs'),os=require('os'),path=require('path');const p=path.join(os.homedir(),'.gemini','config','mcp_config.json');const s=process.argv[1];const cfg=fs.existsSync(p)?JSON.parse(fs.readFileSync(p,'utf8')):{};cfg.mcpServers={...(cfg.mcpServers||{}),cwtools:{command:'node',args:[s,'--stdio']}};fs.mkdirSync(path.dirname(p),{recursive:true});fs.writeFileSync(p,JSON.stringify(cfg,null,2)+'\n')" "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs"
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
If the compatible host is closed, the workspace is not active, the manifest is
|
|
92
|
-
stale, or the client workspace differs from the bridge workspace, tool
|
|
93
|
-
calls return `bridge_unavailable` with recovery instructions. The proxy
|
|
94
|
-
intentionally does not silently fall back to a separate language server.
|
|
95
|
-
|
|
96
|
-
### Optional Standalone Mode
|
|
97
|
-
|
|
98
|
-
Use standalone mode only when you explicitly want the legacy behavior: the MCP
|
|
99
|
-
process starts its own CWTools language server and builds its own diagnostic
|
|
100
|
-
state.
|
|
101
|
-
|
|
102
|
-
```sh
|
|
103
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --stdio
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
HTTP transport is available in both modes:
|
|
107
|
-
|
|
108
|
-
```sh
|
|
109
|
-
cwtools-mcp --http --host 127.0.0.1 --port 3000
|
|
110
|
-
cwtools-mcp --standalone --workspace /path/to/mod --http --host 127.0.0.1 --port 3000
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Standalone Rules And Vanilla Cache
|
|
114
|
-
|
|
115
|
-
These options apply to standalone mode:
|
|
116
|
-
|
|
117
|
-
```sh
|
|
118
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --game-path "/path/to/Stellaris"
|
|
119
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --cache "/path/to/.cwtools"
|
|
120
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --rules "/path/to/rules/config"
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
When standalone mode lacks a vanilla `.cwb` cache or `--game-path`, vanilla IDs
|
|
124
|
-
may be absent and diagnostics can differ from the IDE. Bridge mode avoids this by
|
|
125
|
-
using the active extension host's loaded state.
|
|
126
|
-
|
|
127
|
-
### Tools
|
|
128
|
-
|
|
129
|
-
The MCP surface remains read-only. It exposes the generated CWTools semantic
|
|
130
|
-
tools such as:
|
|
131
|
-
|
|
132
|
-
- `query_types`
|
|
133
|
-
- `query_rules`
|
|
134
|
-
- `query_scope`
|
|
135
|
-
- `get_diagnostics`
|
|
136
|
-
- `explore_pdx_project` for a bounded live semantic graph with dependency edges and freshness
|
|
137
|
-
- `query_workspace_index`
|
|
138
|
-
- `query_localisation_index`
|
|
139
|
-
- `get_pdx_block`
|
|
140
|
-
- completion, document/workspace symbols, definition and reference lookup
|
|
141
|
-
- deep semantic queries for scripted effects/triggers, enums, static modifiers,
|
|
142
|
-
variables, and entity info
|
|
143
|
-
|
|
144
|
-
File edits are intentionally not exposed through this MCP server. External agents
|
|
145
|
-
should edit files through their own environment and then call MCP diagnostics or
|
|
146
|
-
semantic tools again.
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
<a id="zh-cn"></a>
|
|
151
|
-
|
|
152
|
-
## 中文
|
|
153
|
-
|
|
154
|
-
CWTools MCP 是本扩展提供给外部 Agent 的 Paradox / Stellaris 语义工具入口。
|
|
155
|
-
|
|
156
|
-
### 默认模式:插件内 Bridge
|
|
157
|
-
|
|
158
|
-
默认情况下,`cwtools-mcp` 是一个轻量 MCP 代理。它**不会**再启动第二个
|
|
159
|
-
`CWTools Server` 进程,而是连接当前已激活的 VS Code 兼容宿主内的 MCP
|
|
160
|
-
bridge,并复用该宿主中的:
|
|
161
|
-
|
|
162
|
-
- 已有 CWTools 语言客户端;
|
|
163
|
-
- 当前工作区根目录;
|
|
164
|
-
- IDE Problems 面板诊断;
|
|
165
|
-
- rules/cache/localisation/用户设置;
|
|
166
|
-
- 共享索引和 AI 只读工具。
|
|
167
|
-
|
|
168
|
-
这样可以降低内存占用,并让 MCP 诊断数量与 IDE 保持一致。
|
|
169
|
-
|
|
170
|
-
Bridge 模式会严格校验项目身份,但不要求把项目路径写死到全局 MCP 设置里。默认情况下,
|
|
171
|
-
代理会从 MCP roots、已知的按会话注入的环境变量或 MCP 进程 cwd 推断当前客户端工作区。
|
|
172
|
-
这个工作区必须与扩展 bridge 暴露的 `workspaceRoot` 一致。不一致时工具调用会返回
|
|
173
|
-
`bridge_unavailable`,不会静默使用另一个项目回答。`--workspace` 只保留给无法暴露
|
|
174
|
-
按项目 root 的客户端作为可选覆盖项。
|
|
175
|
-
|
|
176
|
-
项目激活时,扩展会把下面两个文件写入当前宿主自己的 `globalStorage/mcp/`
|
|
177
|
-
目录:
|
|
178
|
-
|
|
179
|
-
```text
|
|
180
|
-
cwtools-mcp.cjs
|
|
181
|
-
bridge-manifest.json
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
外部 Agent 应运行同一个宿主复制出来的 `cwtools-mcp.cjs`。代理会读取同目录的
|
|
185
|
-
`bridge-manifest.json`。这条主路径不依赖宿主目录名:VS Code、Cursor、
|
|
186
|
-
VSCodium、Antigravity,以及其他兼容 VS Code 扩展 API 的宿主都可以使用。
|
|
187
|
-
|
|
188
|
-
### 快速接入
|
|
189
|
-
|
|
190
|
-
请使用实际运行扩展的兼容宿主自己的 `globalStorage` 路径。下面的
|
|
191
|
-
`<host-globalStorage>` 代表该宿主下
|
|
192
|
-
`foreverskywalker.foreverskywalker-stellaris-cwtools` 全局存储目录所在位置。
|
|
193
|
-
|
|
194
|
-
#### Codex
|
|
195
|
-
|
|
196
|
-
```sh
|
|
197
|
-
codex mcp add cwtools -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
#### Claude Code
|
|
201
|
-
|
|
202
|
-
```sh
|
|
203
|
-
claude mcp add cwtools --scope user -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
#### Antigravity
|
|
207
|
-
|
|
208
|
-
Antigravity 从 `~/.gemini/config/mcp_config.json` 读取 MCP 服务器。添加下面这个
|
|
209
|
-
server 条目:
|
|
210
|
-
|
|
211
|
-
```json
|
|
212
|
-
{
|
|
213
|
-
"mcpServers": {
|
|
214
|
-
"cwtools": {
|
|
215
|
-
"command": "node",
|
|
216
|
-
"args": [
|
|
217
|
-
"<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs",
|
|
218
|
-
"--stdio"
|
|
219
|
-
]
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
也可以用下面的 Node 一行命令合并进已有配置,不会覆盖其他 MCP server:
|
|
226
|
-
|
|
227
|
-
```sh
|
|
228
|
-
node -e "const fs=require('fs'),os=require('os'),path=require('path');const p=path.join(os.homedir(),'.gemini','config','mcp_config.json');const s=process.argv[1];const cfg=fs.existsSync(p)?JSON.parse(fs.readFileSync(p,'utf8')):{};cfg.mcpServers={...(cfg.mcpServers||{}),cwtools:{command:'node',args:[s,'--stdio']}};fs.mkdirSync(path.dirname(p),{recursive:true});fs.writeFileSync(p,JSON.stringify(cfg,null,2)+'\n')" "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs"
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
如果兼容宿主未打开、工作区未激活、manifest 已失效,或客户端工作区与 bridge
|
|
232
|
-
工作区不一致,工具调用会返回 `bridge_unavailable` 和恢复说明。代理不会静默回退并启动单独的语言服务。
|
|
233
|
-
|
|
234
|
-
### 可选 Standalone 模式
|
|
235
|
-
|
|
236
|
-
只有在明确需要旧行为时才使用 standalone 模式:MCP 进程会自行启动一份 CWTools
|
|
237
|
-
语言服务器并构建独立诊断状态。
|
|
238
|
-
|
|
239
|
-
```sh
|
|
240
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --stdio
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
两种模式都支持 HTTP transport:
|
|
244
|
-
|
|
245
|
-
```sh
|
|
246
|
-
cwtools-mcp --http --host 127.0.0.1 --port 3000
|
|
247
|
-
cwtools-mcp --standalone --workspace /path/to/mod --http --host 127.0.0.1 --port 3000
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Standalone 的规则与原版缓存
|
|
251
|
-
|
|
252
|
-
下面这些参数只适用于 standalone 模式:
|
|
253
|
-
|
|
254
|
-
```sh
|
|
255
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --game-path "/path/to/Stellaris"
|
|
256
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --cache "/path/to/.cwtools"
|
|
257
|
-
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --rules "/path/to/rules/config"
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
如果 standalone 模式缺少 vanilla `.cwb` 缓存或 `--game-path`,原版 ID 可能缺失,
|
|
261
|
-
诊断也可能与 IDE 不一致。Bridge 模式通过复用当前扩展宿主的已加载状态来避免这个问题。
|
|
262
|
-
|
|
263
|
-
### 工具
|
|
264
|
-
|
|
265
|
-
MCP 入口仍保持只读。它暴露生成出来的 CWTools 语义工具,例如:
|
|
266
|
-
|
|
267
|
-
- `query_types`
|
|
268
|
-
- `query_rules`
|
|
269
|
-
- `query_scope`
|
|
270
|
-
- `get_diagnostics`
|
|
271
|
-
- `explore_pdx_project`:返回带依赖边与 freshness 的有界 live 语义图
|
|
272
|
-
- `query_workspace_index`
|
|
273
|
-
- `query_localisation_index`
|
|
274
|
-
- `get_pdx_block`
|
|
275
|
-
- 补全、document/workspace symbols、定义和引用查询
|
|
276
|
-
- scripted effects/triggers、enums、static modifiers、variables、entity info 等深层语义查询
|
|
277
|
-
|
|
278
|
-
文件写入不会通过这个 MCP server 暴露。外部 Agent 应使用自己的环境编辑文件,
|
|
279
|
-
然后再调用 MCP 诊断或语义工具复查。
|
|
1
|
+
# cwtools-mcp
|
|
2
|
+
|
|
3
|
+
[English](#english) | [中文](#zh-cn)
|
|
4
|
+
|
|
5
|
+
<a id="english"></a>
|
|
6
|
+
|
|
7
|
+
## English
|
|
8
|
+
|
|
9
|
+
CWTools MCP is the external-agent entry point for this extension's Paradox /
|
|
10
|
+
Stellaris semantic tools.
|
|
11
|
+
|
|
12
|
+
### Default Mode: Extension Bridge
|
|
13
|
+
|
|
14
|
+
By default, `cwtools-mcp` is a lightweight MCP proxy. It does **not** start a
|
|
15
|
+
second `CWTools Server` process. Instead, it connects to the MCP bridge started
|
|
16
|
+
inside the active VS Code-compatible extension host and reuses that host's:
|
|
17
|
+
|
|
18
|
+
- existing CWTools language client;
|
|
19
|
+
- current workspace root;
|
|
20
|
+
- Problems diagnostics from the IDE;
|
|
21
|
+
- rules/cache/localisation/user settings;
|
|
22
|
+
- shared indexes and AI read tools.
|
|
23
|
+
|
|
24
|
+
This keeps memory use low and makes MCP diagnostics match the IDE.
|
|
25
|
+
|
|
26
|
+
Bridge mode is deliberately strict about project identity without requiring a
|
|
27
|
+
project path in global MCP settings. By default, the proxy discovers the current
|
|
28
|
+
client workspace from MCP roots, known per-session environment variables, or the
|
|
29
|
+
MCP process cwd. That workspace must match the `workspaceRoot` served by the
|
|
30
|
+
extension bridge. If they do not match, tool calls return `bridge_unavailable`
|
|
31
|
+
instead of silently answering from a different project. `--workspace` remains an
|
|
32
|
+
optional override for clients that cannot expose a per-project root.
|
|
33
|
+
|
|
34
|
+
The extension writes both files below into the current host's own
|
|
35
|
+
`globalStorage/mcp/` directory when the project is active:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
cwtools-mcp.cjs
|
|
39
|
+
bridge-manifest.json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
External agents should run the `cwtools-mcp.cjs` copied by the same host they are
|
|
43
|
+
using. The proxy reads `bridge-manifest.json` next to itself. This is host-name
|
|
44
|
+
agnostic: VS Code, Cursor, VSCodium, Antigravity, and other compatible hosts all
|
|
45
|
+
work as long as they support the VS Code extension APIs and activate this
|
|
46
|
+
extension.
|
|
47
|
+
|
|
48
|
+
### Quick Setup
|
|
49
|
+
|
|
50
|
+
Use the `globalStorage` path from the compatible host where the extension is
|
|
51
|
+
active. The placeholder below means the directory that contains the host's
|
|
52
|
+
`foreverskywalker.foreverskywalker-stellaris-cwtools` global storage folder.
|
|
53
|
+
|
|
54
|
+
#### Codex
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
codex mcp add cwtools -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Claude Code
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
claude mcp add cwtools --scope user -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Antigravity
|
|
67
|
+
|
|
68
|
+
Antigravity reads MCP servers from `~/.gemini/config/mcp_config.json`. Add this
|
|
69
|
+
server entry:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"cwtools": {
|
|
75
|
+
"command": "node",
|
|
76
|
+
"args": [
|
|
77
|
+
"<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs",
|
|
78
|
+
"--stdio"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Or merge it into an existing config with a Node one-liner:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
node -e "const fs=require('fs'),os=require('os'),path=require('path');const p=path.join(os.homedir(),'.gemini','config','mcp_config.json');const s=process.argv[1];const cfg=fs.existsSync(p)?JSON.parse(fs.readFileSync(p,'utf8')):{};cfg.mcpServers={...(cfg.mcpServers||{}),cwtools:{command:'node',args:[s,'--stdio']}};fs.mkdirSync(path.dirname(p),{recursive:true});fs.writeFileSync(p,JSON.stringify(cfg,null,2)+'\n')" "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If the compatible host is closed, the workspace is not active, the manifest is
|
|
92
|
+
stale, or the client workspace differs from the bridge workspace, tool
|
|
93
|
+
calls return `bridge_unavailable` with recovery instructions. The proxy
|
|
94
|
+
intentionally does not silently fall back to a separate language server.
|
|
95
|
+
|
|
96
|
+
### Optional Standalone Mode
|
|
97
|
+
|
|
98
|
+
Use standalone mode only when you explicitly want the legacy behavior: the MCP
|
|
99
|
+
process starts its own CWTools language server and builds its own diagnostic
|
|
100
|
+
state.
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --stdio
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
HTTP transport is available in both modes:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
cwtools-mcp --http --host 127.0.0.1 --port 3000
|
|
110
|
+
cwtools-mcp --standalone --workspace /path/to/mod --http --host 127.0.0.1 --port 3000
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Standalone Rules And Vanilla Cache
|
|
114
|
+
|
|
115
|
+
These options apply to standalone mode:
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --game-path "/path/to/Stellaris"
|
|
119
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --cache "/path/to/.cwtools"
|
|
120
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --rules "/path/to/rules/config"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
When standalone mode lacks a vanilla `.cwb` cache or `--game-path`, vanilla IDs
|
|
124
|
+
may be absent and diagnostics can differ from the IDE. Bridge mode avoids this by
|
|
125
|
+
using the active extension host's loaded state.
|
|
126
|
+
|
|
127
|
+
### Tools
|
|
128
|
+
|
|
129
|
+
The MCP surface remains read-only. It exposes the generated CWTools semantic
|
|
130
|
+
tools such as:
|
|
131
|
+
|
|
132
|
+
- `query_types`
|
|
133
|
+
- `query_rules`
|
|
134
|
+
- `query_scope`
|
|
135
|
+
- `get_diagnostics`
|
|
136
|
+
- `explore_pdx_project` for a bounded live semantic graph with dependency edges and freshness
|
|
137
|
+
- `query_workspace_index`
|
|
138
|
+
- `query_localisation_index`
|
|
139
|
+
- `get_pdx_block`
|
|
140
|
+
- completion, document/workspace symbols, definition and reference lookup
|
|
141
|
+
- deep semantic queries for scripted effects/triggers, enums, static modifiers,
|
|
142
|
+
variables, and entity info
|
|
143
|
+
|
|
144
|
+
File edits are intentionally not exposed through this MCP server. External agents
|
|
145
|
+
should edit files through their own environment and then call MCP diagnostics or
|
|
146
|
+
semantic tools again.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
<a id="zh-cn"></a>
|
|
151
|
+
|
|
152
|
+
## 中文
|
|
153
|
+
|
|
154
|
+
CWTools MCP 是本扩展提供给外部 Agent 的 Paradox / Stellaris 语义工具入口。
|
|
155
|
+
|
|
156
|
+
### 默认模式:插件内 Bridge
|
|
157
|
+
|
|
158
|
+
默认情况下,`cwtools-mcp` 是一个轻量 MCP 代理。它**不会**再启动第二个
|
|
159
|
+
`CWTools Server` 进程,而是连接当前已激活的 VS Code 兼容宿主内的 MCP
|
|
160
|
+
bridge,并复用该宿主中的:
|
|
161
|
+
|
|
162
|
+
- 已有 CWTools 语言客户端;
|
|
163
|
+
- 当前工作区根目录;
|
|
164
|
+
- IDE Problems 面板诊断;
|
|
165
|
+
- rules/cache/localisation/用户设置;
|
|
166
|
+
- 共享索引和 AI 只读工具。
|
|
167
|
+
|
|
168
|
+
这样可以降低内存占用,并让 MCP 诊断数量与 IDE 保持一致。
|
|
169
|
+
|
|
170
|
+
Bridge 模式会严格校验项目身份,但不要求把项目路径写死到全局 MCP 设置里。默认情况下,
|
|
171
|
+
代理会从 MCP roots、已知的按会话注入的环境变量或 MCP 进程 cwd 推断当前客户端工作区。
|
|
172
|
+
这个工作区必须与扩展 bridge 暴露的 `workspaceRoot` 一致。不一致时工具调用会返回
|
|
173
|
+
`bridge_unavailable`,不会静默使用另一个项目回答。`--workspace` 只保留给无法暴露
|
|
174
|
+
按项目 root 的客户端作为可选覆盖项。
|
|
175
|
+
|
|
176
|
+
项目激活时,扩展会把下面两个文件写入当前宿主自己的 `globalStorage/mcp/`
|
|
177
|
+
目录:
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
cwtools-mcp.cjs
|
|
181
|
+
bridge-manifest.json
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
外部 Agent 应运行同一个宿主复制出来的 `cwtools-mcp.cjs`。代理会读取同目录的
|
|
185
|
+
`bridge-manifest.json`。这条主路径不依赖宿主目录名:VS Code、Cursor、
|
|
186
|
+
VSCodium、Antigravity,以及其他兼容 VS Code 扩展 API 的宿主都可以使用。
|
|
187
|
+
|
|
188
|
+
### 快速接入
|
|
189
|
+
|
|
190
|
+
请使用实际运行扩展的兼容宿主自己的 `globalStorage` 路径。下面的
|
|
191
|
+
`<host-globalStorage>` 代表该宿主下
|
|
192
|
+
`foreverskywalker.foreverskywalker-stellaris-cwtools` 全局存储目录所在位置。
|
|
193
|
+
|
|
194
|
+
#### Codex
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
codex mcp add cwtools -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Claude Code
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
claude mcp add cwtools --scope user -- node "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs" --stdio
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### Antigravity
|
|
207
|
+
|
|
208
|
+
Antigravity 从 `~/.gemini/config/mcp_config.json` 读取 MCP 服务器。添加下面这个
|
|
209
|
+
server 条目:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"mcpServers": {
|
|
214
|
+
"cwtools": {
|
|
215
|
+
"command": "node",
|
|
216
|
+
"args": [
|
|
217
|
+
"<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs",
|
|
218
|
+
"--stdio"
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
也可以用下面的 Node 一行命令合并进已有配置,不会覆盖其他 MCP server:
|
|
226
|
+
|
|
227
|
+
```sh
|
|
228
|
+
node -e "const fs=require('fs'),os=require('os'),path=require('path');const p=path.join(os.homedir(),'.gemini','config','mcp_config.json');const s=process.argv[1];const cfg=fs.existsSync(p)?JSON.parse(fs.readFileSync(p,'utf8')):{};cfg.mcpServers={...(cfg.mcpServers||{}),cwtools:{command:'node',args:[s,'--stdio']}};fs.mkdirSync(path.dirname(p),{recursive:true});fs.writeFileSync(p,JSON.stringify(cfg,null,2)+'\n')" "<host-globalStorage>/foreverskywalker.foreverskywalker-stellaris-cwtools/mcp/cwtools-mcp.cjs"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
如果兼容宿主未打开、工作区未激活、manifest 已失效,或客户端工作区与 bridge
|
|
232
|
+
工作区不一致,工具调用会返回 `bridge_unavailable` 和恢复说明。代理不会静默回退并启动单独的语言服务。
|
|
233
|
+
|
|
234
|
+
### 可选 Standalone 模式
|
|
235
|
+
|
|
236
|
+
只有在明确需要旧行为时才使用 standalone 模式:MCP 进程会自行启动一份 CWTools
|
|
237
|
+
语言服务器并构建独立诊断状态。
|
|
238
|
+
|
|
239
|
+
```sh
|
|
240
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --stdio
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
两种模式都支持 HTTP transport:
|
|
244
|
+
|
|
245
|
+
```sh
|
|
246
|
+
cwtools-mcp --http --host 127.0.0.1 --port 3000
|
|
247
|
+
cwtools-mcp --standalone --workspace /path/to/mod --http --host 127.0.0.1 --port 3000
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Standalone 的规则与原版缓存
|
|
251
|
+
|
|
252
|
+
下面这些参数只适用于 standalone 模式:
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --game-path "/path/to/Stellaris"
|
|
256
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --cache "/path/to/.cwtools"
|
|
257
|
+
cwtools-mcp --standalone --workspace /path/to/mod --game stellaris --rules "/path/to/rules/config"
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
如果 standalone 模式缺少 vanilla `.cwb` 缓存或 `--game-path`,原版 ID 可能缺失,
|
|
261
|
+
诊断也可能与 IDE 不一致。Bridge 模式通过复用当前扩展宿主的已加载状态来避免这个问题。
|
|
262
|
+
|
|
263
|
+
### 工具
|
|
264
|
+
|
|
265
|
+
MCP 入口仍保持只读。它暴露生成出来的 CWTools 语义工具,例如:
|
|
266
|
+
|
|
267
|
+
- `query_types`
|
|
268
|
+
- `query_rules`
|
|
269
|
+
- `query_scope`
|
|
270
|
+
- `get_diagnostics`
|
|
271
|
+
- `explore_pdx_project`:返回带依赖边与 freshness 的有界 live 语义图
|
|
272
|
+
- `query_workspace_index`
|
|
273
|
+
- `query_localisation_index`
|
|
274
|
+
- `get_pdx_block`
|
|
275
|
+
- 补全、document/workspace symbols、定义和引用查询
|
|
276
|
+
- scripted effects/triggers、enums、static modifiers、variables、entity info 等深层语义查询
|
|
277
|
+
|
|
278
|
+
文件写入不会通过这个 MCP server 暴露。外部 Agent 应使用自己的环境编辑文件,
|
|
279
|
+
然后再调用 MCP 诊断或语义工具复查。
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cwtools-mcp",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Read-only MCP server exposing CWTools Paradox/Stellaris semantic tools to external agents",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/Aa728848/cwtools-mcp.git"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"mcp",
|
|
12
|
-
"cwtools",
|
|
13
|
-
"stellaris",
|
|
14
|
-
"paradox",
|
|
15
|
-
"language-server"
|
|
16
|
-
],
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=18"
|
|
19
|
-
},
|
|
20
|
-
"main": "dist/index.js",
|
|
21
|
-
"types": "dist/index.d.ts",
|
|
22
|
-
"bin": {
|
|
23
|
-
"cwtools-mcp": "dist/cli.js"
|
|
24
|
-
},
|
|
25
|
-
"files": [
|
|
26
|
-
"dist",
|
|
27
|
-
"README.md",
|
|
28
|
-
"package.json"
|
|
29
|
-
],
|
|
30
|
-
"scripts": {
|
|
31
|
-
"prebuild": "npm run build -w cwtools-shared",
|
|
32
|
-
"build": "tsc -p tsconfig.json",
|
|
33
|
-
"bundle": "esbuild dist/cli.js --bundle --platform=node --format=cjs --target=node18 --outfile=dist/cwtools-mcp.cjs",
|
|
34
|
-
"prepack": "npm run build",
|
|
35
|
-
"test:contracts": "ts-mocha -p tsconfig.test.json \"src/test/**/*.test.ts\""
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
|
-
"chokidar": "^4.0.3",
|
|
40
|
-
"cwtools-shared": "0.2.
|
|
41
|
-
"vscode-jsonrpc": "^8.2.0"
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"esbuild": "^0.28.1"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cwtools-mcp",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Read-only MCP server exposing CWTools Paradox/Stellaris semantic tools to external agents",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Aa728848/cwtools-mcp.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"mcp",
|
|
12
|
+
"cwtools",
|
|
13
|
+
"stellaris",
|
|
14
|
+
"paradox",
|
|
15
|
+
"language-server"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
19
|
+
},
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"bin": {
|
|
23
|
+
"cwtools-mcp": "dist/cli.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"package.json"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"prebuild": "npm run build -w cwtools-shared",
|
|
32
|
+
"build": "tsc -p tsconfig.json",
|
|
33
|
+
"bundle": "esbuild dist/cli.js --bundle --platform=node --format=cjs --target=node18 --outfile=dist/cwtools-mcp.cjs",
|
|
34
|
+
"prepack": "npm run build",
|
|
35
|
+
"test:contracts": "ts-mocha -p tsconfig.test.json \"src/test/**/*.test.ts\""
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
|
+
"chokidar": "^4.0.3",
|
|
40
|
+
"cwtools-shared": "0.2.2",
|
|
41
|
+
"vscode-jsonrpc": "^8.2.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"esbuild": "^0.28.1"
|
|
45
|
+
}
|
|
46
|
+
}
|