wwise-waapi-mcp 1.0.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.
Files changed (38) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +221 -0
  3. package/README_ZH.md +221 -0
  4. package/config/domains.json +130 -0
  5. package/config/runtime.json +4 -0
  6. package/dist/src/core/server.js +80 -0
  7. package/dist/src/core/transport.js +92 -0
  8. package/dist/src/domains/audio/tools.js +193 -0
  9. package/dist/src/domains/catalog/tools.js +198 -0
  10. package/dist/src/domains/debug/tools.js +139 -0
  11. package/dist/src/domains/example/tools.js +56 -0
  12. package/dist/src/domains/log/tools.js +79 -0
  13. package/dist/src/domains/object/tools.js +499 -0
  14. package/dist/src/domains/plugin/tools.js +45 -0
  15. package/dist/src/domains/profiler/tools.js +266 -0
  16. package/dist/src/domains/project/tools.js +179 -0
  17. package/dist/src/domains/remote/tools.js +73 -0
  18. package/dist/src/domains/sound/tools.js +38 -0
  19. package/dist/src/domains/soundbank/tools.js +137 -0
  20. package/dist/src/domains/soundengine/tools.js +529 -0
  21. package/dist/src/domains/sourceControl/tools.js +191 -0
  22. package/dist/src/domains/switchContainer/tools.js +64 -0
  23. package/dist/src/domains/transport/tools.js +116 -0
  24. package/dist/src/domains/ui/tools.js +126 -0
  25. package/dist/src/domains/undo/tools.js +75 -0
  26. package/dist/src/index.js +95 -0
  27. package/dist/src/lib/errors.js +31 -0
  28. package/dist/src/lib/logger.js +43 -0
  29. package/dist/src/lib/referenceCatalog.js +167 -0
  30. package/dist/src/lib/response.js +88 -0
  31. package/dist/src/lib/runtimePaths.js +21 -0
  32. package/dist/src/lib/toolFactory.js +73 -0
  33. package/dist/src/lib/waapiClient.js +97 -0
  34. package/dist/src/lib/waapiSchemaResolver.js +120 -0
  35. package/dist/src/registry/toolRegistry.js +180 -0
  36. package/dist/src/registry/types.js +2 -0
  37. package/dist/tests/verify.js +119 -0
  38. package/package.json +56 -0
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright 2026 Li Major
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the “Software”), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,221 @@
1
+ # Wwise MCP Server
2
+
3
+ [中文文档](README_ZH.md)
4
+
5
+ Lightweight Node.js + TypeScript MCP server for Wwise WAAPI.
6
+
7
+ ⭐ Uses progressive tool discovery. Avoiding consuming large tokens by exposing the full WAAPI tool surface at once.
8
+
9
+ ⭐ Use locally installed Wwise's WAAPI Json Schema for full WAAPI capabilities.
10
+
11
+ ## Quick start
12
+
13
+ ### Install dependencies
14
+
15
+ ```bash
16
+ npm i
17
+ ```
18
+
19
+ ### Configure Wwise install ROOT and WAAPI connection
20
+
21
+ Configurations are stored in `config/runtime.json`
22
+
23
+ If you leave the `wwiseRoot` configuration empty, or the path is invalid, the tool will use `%WWISEROOT%` to try finding the path.
24
+
25
+ The `waapiUrl` defaults to `ws://127.0.0.1:8080/waapi` if not specified.
26
+
27
+ ```json
28
+ // Example
29
+ {
30
+ "wwiseRoot": "C:/Program Files (x86)/Audiokinetic/Wwise 2024.1.0.8669",
31
+ "waapiUrl": "ws://127.0.0.1:8080/waapi"
32
+ }
33
+ ```
34
+
35
+ ### Run in development (stdio default)
36
+
37
+ ```bash
38
+ npm run dev
39
+ ```
40
+
41
+ ### Or build and run
42
+
43
+ ```bash
44
+ npm run build
45
+ npm start
46
+ ```
47
+
48
+ ## Schema source and startup requirements
49
+
50
+ This project does not redistribute Audiokinetic WAAPI schema JSON files.
51
+
52
+ At startup, the server resolves WAAPI schema directory using this priority:
53
+
54
+ 1. `config/runtime.json` -> `wwiseRoot`
55
+ 2. `WWISEROOT` environment variable
56
+ 3. Live WAAPI probe:
57
+ - call `ak.wwise.core.getProjectInfo` to confirm a project is open
58
+ - call `ak.wwise.core.getInfo` and read `directories.install`
59
+
60
+ Expected schema path under root:
61
+
62
+ ```text
63
+ <WwiseRoot>/Authoring/Data/Schemas/WAAPI
64
+ ```
65
+
66
+ If all probes fail, startup exits with `waapi_schema_not_found`.
67
+
68
+ ## Core capabilities
69
+
70
+ - Layered architecture: `core` + `registry` + `domains` + `lib`.
71
+ - Progressive-disclosure MCP surface:
72
+ - `tools/list` only exposes discovery tools, not every runtime WAAPI tool
73
+ - currently exposed discovery tools:
74
+ - `catalog.listDomains`
75
+ - `catalog.listTools`
76
+ - `catalog.getToolSchema`
77
+ - `catalog.executeTool`
78
+ - Discovery and execution flow:
79
+ - `catalog.listDomains`
80
+ - `catalog.listTools`
81
+ - `catalog.getToolSchema`
82
+ - `catalog.executeTool`
83
+ - Runtime-backed WAAPI tools across major domains.
84
+ - Standard response envelope:
85
+ - success: `{ ok: true, data: ... }`
86
+ - failure: `{ ok: false, error: { code, message, details? } }`
87
+ - Structured tool call logs with sensitive-field redaction.
88
+
89
+ Implemented WAAPI surface details are tracked in `docs/implemented-waapi.md`.
90
+
91
+ ## Transport modes
92
+
93
+ ### stdio mode (default)
94
+
95
+ Use for standard MCP clients that spawn the server as a subprocess.
96
+
97
+ ```bash
98
+ npm run dev
99
+ ```
100
+
101
+ ```bash
102
+ npm start
103
+ # equivalent to: node dist/src/index.js
104
+ ```
105
+
106
+ Example MCP client config:
107
+
108
+ ```json
109
+ {
110
+ "servers": {
111
+ "wwise-mcp": {
112
+ "type": "stdio",
113
+ "command": "node",
114
+ "args": ["dist/src/index.js"]
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ ### HTTP/SSE mode
121
+
122
+ Use when you want a long-running MCP endpoint over HTTP.
123
+
124
+ ```bash
125
+ node dist/src/index.js --http
126
+ ```
127
+
128
+ ```bash
129
+ node dist/src/index.js --http --port 8080
130
+ ```
131
+
132
+ ```bash
133
+ MCP_TRANSPORT=http PORT=8080 node dist/src/index.js
134
+ ```
135
+
136
+ HTTP endpoint summary:
137
+
138
+ | Method | Path | Purpose |
139
+ | :-- | :-- | :-- |
140
+ | `POST` | `/mcp` | Send JSON-RPC requests. Omit `mcp-session-id` on first `initialize` to create session. |
141
+ | `GET` | `/mcp` | Open standalone SSE stream for server notifications. Requires `mcp-session-id`. |
142
+ | `DELETE` | `/mcp` | Close session. Requires `mcp-session-id`. |
143
+
144
+ Port selection priority:
145
+
146
+ 1. `--port <n>`
147
+ 2. `PORT` env var
148
+ 3. default `3000`
149
+
150
+ The HTTP server binds to `127.0.0.1` by default.
151
+
152
+ ## Verify
153
+
154
+ ```bash
155
+ npm run build
156
+ npm run verify
157
+ ```
158
+
159
+ Verification checks:
160
+
161
+ - only discovery tools are registered through MCP `tools/list`
162
+ - domains can be enumerated through `catalog.listDomains`
163
+ - domain-local tools can be discovered through `catalog.listTools`
164
+ - one tool schema can be queried through `catalog.getToolSchema`
165
+ - one runtime WAAPI call can be executed through `catalog.executeTool`
166
+ - WAAPI failure is still returned as a structured error when WAAPI is unavailable
167
+
168
+ Note: verify requires schema path resolution to succeed first.
169
+
170
+ ## WAAPI connection
171
+
172
+ Default WAAPI URL:
173
+
174
+ ```bash
175
+ ws://127.0.0.1:8080/waapi
176
+ ```
177
+
178
+ Configure in `config/runtime.json`:
179
+
180
+ ```json
181
+ {
182
+ "waapiUrl": "ws://host:port/waapi"
183
+ }
184
+ ```
185
+
186
+ ## Access filtering
187
+
188
+ Optional startup filters:
189
+
190
+ - `WWISE_MCP_ALLOWED_DOMAINS=object,soundengine`
191
+ - `WWISE_MCP_ALLOWED_RISKS=low,medium`
192
+ - `WWISE_MCP_ALLOWED_PERMISSIONS=waapi:authoring:read,waapi:runtime`
193
+
194
+ ## Package as EXE
195
+
196
+ ```bash
197
+ npm run package:exe
198
+ ```
199
+
200
+ Output file: `bin/wwise-mcp.exe`
201
+
202
+ ## Manual validation
203
+
204
+ After startup, call tools in this order:
205
+
206
+ 1. `catalog.listDomains`
207
+ 2. `catalog.listTools` with `{ "domain": "object", "includePlanned": true }`
208
+ 3. `catalog.getToolSchema` with `{ "toolName": "ak.wwise.core.object.get" }`
209
+ 4. `catalog.executeTool` with `{ "toolName": "ak.wwise.core.object.get", "arguments": { ... } }`
210
+
211
+ This is the intended progressive-disclosure path: domain summary -> tool summary -> schema details -> execution.
212
+
213
+ The practical implication is that MCP clients no longer receive the full callable WAAPI surface during `tools/list`. They first discover available domains and tools, then request schema details for one tool, and only then execute that tool through the unified `catalog.executeTool` entrypoint.
214
+
215
+ ## Extend with new domains
216
+
217
+ 1. Copy `src/domains/example/tools.ts` to a new domain folder.
218
+ 2. Export `getYourDomainTools()` returning `ToolDefinition[]`.
219
+ 3. Add domain metadata to `config/domains.json`.
220
+ 4. Import/register tools in `src/index.ts`.
221
+ 5. Extend `src/lib/referenceCatalog.ts` mapping when needed.
package/README_ZH.md ADDED
@@ -0,0 +1,221 @@
1
+ # Wwise MCP 服务器
2
+
3
+ [English Doc](README.md)
4
+
5
+ 一个轻量级的 Node.js + TypeScript Wwise WAAPI MCP 服务器
6
+
7
+ ⭐ 使用渐进式工具发现,避免同时给出大量 MCP 工具而消耗大量 Tokens
8
+
9
+ ⭐ 该工具依赖本地安装的 Wwise 中附带的 WAAPI Json Schema,因此可以提供完全的 WAAPI 能力。
10
+
11
+ ## 快速开始
12
+
13
+ ### 安装依赖
14
+
15
+ ```bash
16
+ npm i
17
+ ```
18
+
19
+ ### 配置 Wwise 安装目录和 WAAPI 连接地址
20
+
21
+ 在 `config/runtime.json` 中进行配置
22
+
23
+ 如果 `wwiseRoot` 配置留空,或路径无效,工具会尝试使用 `%WWISEROOT%` 查找路径
24
+
25
+ 若未指定 `waapiUrl`,则默认使用 `ws://127.0.0.1:8080/waapi`
26
+
27
+ ```json
28
+ // 示例
29
+ {
30
+ "wwiseRoot": "C:/Program Files (x86)/Audiokinetic/Wwise 2024.1.0.8669",
31
+ "waapiUrl": "ws://127.0.0.1:8080/waapi"
32
+ }
33
+ ```
34
+
35
+ ### 开发模式运行(默认 stdio)
36
+
37
+ ```bash
38
+ npm run dev
39
+ ```
40
+
41
+ ### 或者先构建再运行
42
+
43
+ ```bash
44
+ npm run build
45
+ npm start
46
+ ```
47
+
48
+ ## Schema 来源与启动要求
49
+
50
+ 本项目不会重新分发 Audiokinetic 的 WAAPI schema JSON 文件。
51
+
52
+ 启动时,服务器会按以下优先级解析 WAAPI schema 目录:
53
+
54
+ 1. `config/runtime.json` -> `wwiseRoot`
55
+ 2. `WWISEROOT` 环境变量
56
+ 3. 在线 WAAPI 探测:
57
+ - 调用 `ak.wwise.core.getProjectInfo` 确认当前有已打开工程
58
+ - 调用 `ak.wwise.core.getInfo` 并读取 `directories.install`
59
+
60
+ 期望的 schema 子目录为:
61
+
62
+ ```text
63
+ <WwiseRoot>/Authoring/Data/Schemas/WAAPI
64
+ ```
65
+
66
+ 如果以上探测都失败,启动会以 `waapi_schema_not_found` 退出。
67
+
68
+ ## 核心能力
69
+
70
+ - 分层架构:`core` + `registry` + `domains` + `lib`。
71
+ - 渐进式对外暴露:
72
+ - MCP 的 `tools/list` 只暴露发现工具,不会一次性暴露所有运行时 WAAPI 工具
73
+ - 当前对外暴露的发现工具为:
74
+ - `catalog.listDomains`
75
+ - `catalog.listTools`
76
+ - `catalog.getToolSchema`
77
+ - `catalog.executeTool`
78
+ - 渐进式发现与执行流程:
79
+ - `catalog.listDomains`
80
+ - `catalog.listTools`
81
+ - `catalog.getToolSchema`
82
+ - `catalog.executeTool`
83
+ - 覆盖主要 Domain 的 WAAPI 运行时工具。
84
+ - 统一响应封装:
85
+ - 成功:`{ ok: true, data: ... }`
86
+ - 失败:`{ ok: false, error: { code, message, details? } }`
87
+ - 结构化工具调用日志,并对敏感字段做脱敏处理。
88
+
89
+ 已实现的 WAAPI 接口覆盖详情见 `docs/implemented-waapi.md`。
90
+
91
+ ## 传输模式
92
+
93
+ ### stdio 模式(默认)
94
+
95
+ 用于标准 MCP 客户端以子进程方式拉起服务器的场景。
96
+
97
+ ```bash
98
+ npm run dev
99
+ ```
100
+
101
+ ```bash
102
+ npm start
103
+ # 等价于: node dist/src/index.js
104
+ ```
105
+
106
+ MCP 客户端配置示例:
107
+
108
+ ```json
109
+ {
110
+ "servers": {
111
+ "wwise-mcp": {
112
+ "type": "stdio",
113
+ "command": "node",
114
+ "args": ["dist/src/index.js"]
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ ### HTTP/SSE 模式
121
+
122
+ 用于以 HTTP 形式长期运行 MCP 端点的场景。
123
+
124
+ ```bash
125
+ node dist/src/index.js --http
126
+ ```
127
+
128
+ ```bash
129
+ node dist/src/index.js --http --port 8080
130
+ ```
131
+
132
+ ```bash
133
+ MCP_TRANSPORT=http PORT=8080 node dist/src/index.js
134
+ ```
135
+
136
+ HTTP 端点说明:
137
+
138
+ | Method | Path | Purpose |
139
+ | :-- | :-- | :-- |
140
+ | `POST` | `/mcp` | 发送 JSON-RPC 请求。首次 `initialize` 不带 `mcp-session-id` 以创建会话。 |
141
+ | `GET` | `/mcp` | 打开独立 SSE 通道用于服务端通知。需要 `mcp-session-id`。 |
142
+ | `DELETE` | `/mcp` | 关闭会话。需要 `mcp-session-id`。 |
143
+
144
+ 端口选择优先级:
145
+
146
+ 1. `--port <n>`
147
+ 2. `PORT` 环境变量
148
+ 3. 默认 `3000`
149
+
150
+ HTTP 服务器默认绑定 `127.0.0.1`。
151
+
152
+ ## 验证
153
+
154
+ ```bash
155
+ npm run build
156
+ npm run verify
157
+ ```
158
+
159
+ 验证脚本会检查:
160
+
161
+ - MCP `tools/list` 是否只注册了发现工具
162
+ - 是否可以通过 `catalog.listDomains` 枚举 Domain
163
+ - 是否可以通过 `catalog.listTools` 发现 Domain 下的工具
164
+ - 是否可以通过 `catalog.getToolSchema` 查询某个工具的 schema
165
+ - 是否可以通过 `catalog.executeTool` 执行某个运行时工具
166
+ - WAAPI 不可用时,运行时 WAAPI 调用是否仍会结构化失败
167
+
168
+ 注意:执行 verify 前需要先确保 schema 路径解析成功。
169
+
170
+ ## WAAPI 连接
171
+
172
+ 默认 WAAPI URL:
173
+
174
+ ```bash
175
+ ws://127.0.0.1:8080/waapi
176
+ ```
177
+
178
+ 在 `config/runtime.json` 中配置:
179
+
180
+ ```json
181
+ {
182
+ "waapiUrl": "ws://host:port/waapi"
183
+ }
184
+ ```
185
+
186
+ ## 访问过滤
187
+
188
+ 可选的启动过滤变量:
189
+
190
+ - `WWISE_MCP_ALLOWED_DOMAINS=object,soundengine`
191
+ - `WWISE_MCP_ALLOWED_RISKS=low,medium`
192
+ - `WWISE_MCP_ALLOWED_PERMISSIONS=waapi:authoring:read,waapi:runtime`
193
+
194
+ ## 打包为 EXE
195
+
196
+ ```bash
197
+ npm run package:exe
198
+ ```
199
+
200
+ 输出文件:`bin/wwise-mcp.exe`
201
+
202
+ ## 手动验证
203
+
204
+ 服务启动后,按以下顺序调用工具:
205
+
206
+ 1. `catalog.listDomains`
207
+ 2. `catalog.listTools`,参数 `{ "domain": "object", "includePlanned": true }`
208
+ 3. `catalog.getToolSchema`,参数 `{ "toolName": "ak.wwise.core.object.get" }`
209
+ 4. `catalog.executeTool`,参数 `{ "toolName": "ak.wwise.core.object.get", "arguments": { ... } }`
210
+
211
+ 这是预期的渐进式发现路径:Domain 摘要 -> 工具摘要 -> schema 详情 -> 工具执行。
212
+
213
+ 这意味着 MCP 客户端在调用 `tools/list` 时,不会再直接拿到全部 callable WAAPI 工具,而是先发现 Domain 和工具,再按需请求某个工具的 schema,最后通过统一入口 `catalog.executeTool` 执行该工具。
214
+
215
+ ## 扩展新 Domain
216
+
217
+ 1. 复制 `src/domains/example/tools.ts` 到新的 Domain 目录。
218
+ 2. 导出 `getYourDomainTools()` 并返回 `ToolDefinition[]`。
219
+ 3. 在 `config/domains.json` 添加 Domain 元数据。
220
+ 4. 在 `src/index.ts` 中导入并注册该 Domain 工具。
221
+ 5. 如有需要,扩展 `src/lib/referenceCatalog.ts` 中的 Domain 映射。
@@ -0,0 +1,130 @@
1
+ {
2
+ "domains": [
3
+ {
4
+ "name": "catalog",
5
+ "title": "Catalog",
6
+ "description": "System discovery tools for progressive domain and schema disclosure.",
7
+ "risk": "low",
8
+ "tags": ["system", "discovery", "metadata"]
9
+ },
10
+ {
11
+ "name": "example",
12
+ "title": "Example",
13
+ "description": "Sample business domain showing how to add a non-WAAPI tool module.",
14
+ "risk": "low",
15
+ "tags": ["example", "sample"]
16
+ },
17
+ {
18
+ "name": "soundengine",
19
+ "title": "SoundEngine",
20
+ "description": "Runtime game-audio control for events, RTPCs, switches, listeners, and banks.",
21
+ "risk": "high",
22
+ "tags": ["runtime", "audio", "game"]
23
+ },
24
+ {
25
+ "name": "object",
26
+ "title": "Object",
27
+ "description": "Wwise authoring object queries, creation, property mutation, and hierarchy operations.",
28
+ "risk": "high",
29
+ "tags": ["authoring", "objects", "waql"]
30
+ },
31
+ {
32
+ "name": "audio",
33
+ "title": "Audio",
34
+ "description": "Audio import, solo or mute actions, and source peak analysis.",
35
+ "risk": "medium",
36
+ "tags": ["audio", "import", "analysis"]
37
+ },
38
+ {
39
+ "name": "soundbank",
40
+ "title": "SoundBank",
41
+ "description": "SoundBank generation, inclusion management, and external source conversion.",
42
+ "risk": "high",
43
+ "tags": ["build", "banks", "packaging"]
44
+ },
45
+ {
46
+ "name": "transport",
47
+ "title": "Transport",
48
+ "description": "Editor transport lifecycle and playback control.",
49
+ "risk": "medium",
50
+ "tags": ["transport", "playback"]
51
+ },
52
+ {
53
+ "name": "profiler",
54
+ "title": "Profiler",
55
+ "description": "Capture, performance telemetry, voice inspection, and profiler state.",
56
+ "risk": "medium",
57
+ "tags": ["profiling", "telemetry", "capture"]
58
+ },
59
+ {
60
+ "name": "project",
61
+ "title": "Project",
62
+ "description": "Project open, create, close, and save workflows across console, core, and UI APIs.",
63
+ "risk": "high",
64
+ "tags": ["project", "lifecycle"]
65
+ },
66
+ {
67
+ "name": "remote",
68
+ "title": "Remote",
69
+ "description": "Remote console discovery and connection management.",
70
+ "risk": "medium",
71
+ "tags": ["remote", "connection"]
72
+ },
73
+ {
74
+ "name": "ui",
75
+ "title": "UI",
76
+ "description": "Editor UI commands, selections, screenshots, and command registration.",
77
+ "risk": "medium",
78
+ "tags": ["ui", "editor"]
79
+ },
80
+ {
81
+ "name": "debug",
82
+ "title": "Debug",
83
+ "description": "Debug, CLI automation, logging, assertions, and Lua execution surfaces.",
84
+ "risk": "high",
85
+ "tags": ["debug", "cli", "automation"]
86
+ },
87
+ {
88
+ "name": "switchContainer",
89
+ "title": "Switch Container",
90
+ "description": "Switch Container child-to-state/switch assignment management.",
91
+ "risk": "medium",
92
+ "tags": ["authoring", "switch", "assignment"]
93
+ },
94
+ {
95
+ "name": "undo",
96
+ "title": "Undo",
97
+ "description": "Undo group management and redo operations for batched authoring changes.",
98
+ "risk": "high",
99
+ "tags": ["authoring", "undo", "redo"]
100
+ },
101
+ {
102
+ "name": "log",
103
+ "title": "Log",
104
+ "description": "Wwise log channel read, write, and clear operations.",
105
+ "risk": "low",
106
+ "tags": ["log", "diagnostics"]
107
+ },
108
+ {
109
+ "name": "plugin",
110
+ "title": "Plugin",
111
+ "description": "Wwise plug-in discovery and property schema inspection.",
112
+ "risk": "low",
113
+ "tags": ["plugin", "metadata", "discovery"]
114
+ },
115
+ {
116
+ "name": "sourceControl",
117
+ "title": "Source Control",
118
+ "description": "Source control file operations: add, check out, commit, revert, status, and provider configuration.",
119
+ "risk": "high",
120
+ "tags": ["vcs", "files", "sourceControl"]
121
+ },
122
+ {
123
+ "name": "sound",
124
+ "title": "Sound",
125
+ "description": "Sound object authoring operations such as active audio source selection.",
126
+ "risk": "high",
127
+ "tags": ["authoring", "sound", "source"]
128
+ }
129
+ ]
130
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "wwiseRoot": "",
3
+ "waapiUrl": "ws://127.0.0.1:8080/waapi"
4
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createServer = createServer;
4
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const logger_js_1 = require("../lib/logger.js");
6
+ const errors_js_1 = require("../lib/errors.js");
7
+ const response_js_1 = require("../lib/response.js");
8
+ /**
9
+ * 判断一个值是否为失败响应包结构。
10
+ * 用于工具处理器返回响应包(而非抛出异常)时的业务层失败检测。
11
+ */
12
+ function isFailureResponse(value) {
13
+ return Boolean(value &&
14
+ typeof value === "object" &&
15
+ "ok" in value &&
16
+ value.ok === false &&
17
+ "error" in value);
18
+ }
19
+ /**
20
+ * 创建 MCP 服务器实例,只注册标记为发现工具(isDiscoveryTool=true)的工具到MCP。
21
+ * 其他工具存活在注册表中,客户端通过catalog.executeTool动态执行。
22
+ *
23
+ * 这实现了渐进式披露设计:
24
+ * 1. 客户端只在 tools/list 中看到发现工具
25
+ * 2. 通过 catalog.listDomains → catalog.listTools → catalog.getToolSchema 逐步探索
26
+ * 3. 通过 catalog.executeTool 执行发现到的任何工具
27
+ *
28
+ * 每个工具被包装了统一的错误处理和日志记录逻辑。
29
+ * 错误和业务层失败均会序列化为标准 JSON 包并通过 MCP 文本内容返回。
30
+ */
31
+ function createServer(registry, policy) {
32
+ const server = new mcp_js_1.McpServer({
33
+ name: "wwise-mcp",
34
+ version: "0.1.0"
35
+ }, {
36
+ capabilities: {
37
+ logging: {}
38
+ }
39
+ });
40
+ // 只注册发现工具到 MCP(实现渐进式披露)
41
+ for (const tool of registry.getCallableTools(policy)) {
42
+ if (!tool.isDiscoveryTool) {
43
+ continue;
44
+ }
45
+ server.registerTool(tool.name, {
46
+ title: tool.title,
47
+ description: tool.description,
48
+ inputSchema: tool.inputSchema
49
+ }, async (args, extra) => {
50
+ const startedAt = Date.now();
51
+ try {
52
+ if (!tool.handler) {
53
+ throw new Error(`Tool ${tool.name} does not have a handler.`);
54
+ }
55
+ const response = await tool.handler(args, extra);
56
+ const failure = isFailureResponse(response) ? response : undefined;
57
+ (0, logger_js_1.logToolCall)({
58
+ toolName: tool.name,
59
+ durationMs: Date.now() - startedAt,
60
+ success: !failure,
61
+ errorCode: failure?.error.code,
62
+ args: args
63
+ });
64
+ return (0, response_js_1.toMcpToolResult)(response);
65
+ }
66
+ catch (error) {
67
+ const failure = (0, errors_js_1.toFailureResponse)(error);
68
+ (0, logger_js_1.logToolCall)({
69
+ toolName: tool.name,
70
+ durationMs: Date.now() - startedAt,
71
+ success: false,
72
+ errorCode: failure.error.code,
73
+ args: args
74
+ });
75
+ return (0, response_js_1.toMcpToolResult)(failure);
76
+ }
77
+ });
78
+ }
79
+ return server;
80
+ }