keyshot-mcp 0.0.0 → 0.4.1
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/CONTRIBUTING.md +45 -0
- package/LICENSE +21 -0
- package/README.md +537 -3
- package/SECURITY.md +33 -0
- package/dist/cli/status.js +5 -0
- package/dist/config.js +51 -0
- package/dist/index.js +126 -0
- package/dist/presets.js +67 -0
- package/dist/queue.js +70 -0
- package/dist/result.js +21 -0
- package/dist/runner.js +147 -0
- package/dist/schemas.js +110 -0
- package/dist/types.js +1 -0
- package/examples/claude-desktop.example.json +13 -0
- package/examples/codex.example.json +14 -0
- package/examples/mcp-client.example.json +13 -0
- package/package.json +53 -4
- package/presets/materials.json +14 -0
- package/scripts/keyshot_bridge.py +609 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Contributing / 贡献指南
|
|
2
|
+
|
|
3
|
+
## English
|
|
4
|
+
|
|
5
|
+
Contributions are welcome.
|
|
6
|
+
|
|
7
|
+
Useful areas:
|
|
8
|
+
|
|
9
|
+
- Test with more KeyShot versions.
|
|
10
|
+
- Improve compatibility with macOS and Linux paths.
|
|
11
|
+
- Add examples for Claude Desktop, Codex, and other MCP clients.
|
|
12
|
+
- Add more precise wrappers for KeyShot `lux` APIs.
|
|
13
|
+
|
|
14
|
+
Before opening a pull request:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install
|
|
18
|
+
npm run build
|
|
19
|
+
npm run status
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Do not include proprietary KeyShot scenes, license data, customer assets, or private render outputs in issues or pull requests.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 中文
|
|
27
|
+
|
|
28
|
+
欢迎参与贡献。
|
|
29
|
+
|
|
30
|
+
比较有价值的方向:
|
|
31
|
+
|
|
32
|
+
- 测试更多 KeyShot 版本。
|
|
33
|
+
- 改进 macOS 和 Linux 路径兼容。
|
|
34
|
+
- 增加 Claude Desktop、Codex 和其他 MCP 客户端示例。
|
|
35
|
+
- 为 KeyShot `lux` API 增加更精确的封装。
|
|
36
|
+
|
|
37
|
+
提交修改前建议先运行:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install
|
|
41
|
+
npm run build
|
|
42
|
+
npm run status
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
请不要在 issue 或 pull request 里上传专有 KeyShot 场景、许可证数据、客户资产或私人渲染结果。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KeyShot MCP contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,538 @@
|
|
|
1
|
-
|
|
1
|
+
# KeyShot MCP
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](https://lobehub.com/mcp/truman-t3-keyshot-mcp)
|
|
4
|
+
[](https://github.com/truman-t3/keyshot-mcp/releases)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
English | [中文](#中文说明)
|
|
8
|
+
|
|
9
|
+
A local MCP server for controlling KeyShot Studio through KeyShot headless scripting.
|
|
10
|
+
|
|
11
|
+
It lets an AI app that supports MCP ask KeyShot to inspect scenes, render images, import models, change materials, adjust cameras, set environments, and save scenes.
|
|
12
|
+
|
|
13
|
+
Optimized for Windows-based KeyShot Studio product visualization workflows.
|
|
14
|
+
|
|
15
|
+
Unlike GUI-only automation scripts, this project targets KeyShot headless workflows and keeps a stable MCP interface for AI agents.
|
|
16
|
+
|
|
17
|
+
## Who This Is For
|
|
18
|
+
|
|
19
|
+
- Designers who want AI-assisted KeyShot rendering.
|
|
20
|
+
- Developers who want a simple stdio MCP bridge for KeyShot.
|
|
21
|
+
- Teams that already have KeyShot licenses configured on their machines.
|
|
22
|
+
|
|
23
|
+
This project does not include KeyShot, does not bypass licensing, and does not store license keys.
|
|
24
|
+
|
|
25
|
+
## What It Can Do
|
|
26
|
+
|
|
27
|
+
- Check whether KeyShot headless can start.
|
|
28
|
+
- Inspect a `.bip` or supported KeyShot scene file.
|
|
29
|
+
- Render a scene to an image.
|
|
30
|
+
- Batch render multiple named cameras from one scene.
|
|
31
|
+
- Import a model into a scene.
|
|
32
|
+
- Apply a material to an object.
|
|
33
|
+
- Create or update a camera.
|
|
34
|
+
- Set an environment when the installed KeyShot version exposes that function.
|
|
35
|
+
- Save a scene to a new file.
|
|
36
|
+
|
|
37
|
+
## Example Workflows
|
|
38
|
+
|
|
39
|
+
- Batch render multiple camera views from one KeyShot scene.
|
|
40
|
+
- Test several material options on the same product model.
|
|
41
|
+
- Generate product hero images with consistent resolution and output naming.
|
|
42
|
+
- Import a model, apply a material preset, set a camera, and render in one AI instruction.
|
|
43
|
+
|
|
44
|
+
## Workflow
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
- KeyShot Studio with `keyshot_headless` support.
|
|
51
|
+
- Node.js 20 or newer.
|
|
52
|
+
- A valid KeyShot license already configured on the computer.
|
|
53
|
+
|
|
54
|
+
## Compatibility
|
|
55
|
+
|
|
56
|
+
| Platform | KeyShot Version | Node Version | Status |
|
|
57
|
+
| --- | --- | --- | --- |
|
|
58
|
+
| Windows 11 | KeyShot Studio 2025 / 14.1 | Node 22 | Tested |
|
|
59
|
+
| macOS | Not tested | - | Need contributors |
|
|
60
|
+
| Linux | Not tested | - | Need contributors |
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
### Install the published npm package
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install -g keyshot-mcp
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The current release line is `0.4.1`. The published package is the easiest option
|
|
71
|
+
when you only want to use the MCP server. You still need KeyShot Studio and a
|
|
72
|
+
local KeyShot license.
|
|
73
|
+
|
|
74
|
+
### Install from source
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install
|
|
78
|
+
npm run build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Copy-Paste Setup Prompt for an Agent
|
|
82
|
+
|
|
83
|
+
If you use Codex or another coding agent, you can copy this prompt and let the agent install the MCP server for you:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
Install the KeyShot MCP server from https://github.com/truman-t3/keyshot-mcp.
|
|
87
|
+
|
|
88
|
+
Please:
|
|
89
|
+
1. Clone the repository or use my local copy if it already exists.
|
|
90
|
+
2. Run npm install and npm run build.
|
|
91
|
+
3. Find my KeyShot headless executable path.
|
|
92
|
+
4. Add a keyshot MCP server entry to my MCP client configuration.
|
|
93
|
+
5. Set KEYSHOT_HEADLESS_EXE to the detected keyshot_headless path.
|
|
94
|
+
6. Test the setup by running the keyshot_status tool.
|
|
95
|
+
7. Tell me the exact config that was added and whether the status check passed.
|
|
96
|
+
|
|
97
|
+
Do not store license keys or account passwords. Use my existing local KeyShot license configuration.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Configure
|
|
101
|
+
|
|
102
|
+
Set the path to your KeyShot headless executable.
|
|
103
|
+
|
|
104
|
+
Windows PowerShell example:
|
|
105
|
+
|
|
106
|
+
```powershell
|
|
107
|
+
$env:KEYSHOT_HEADLESS_EXE="C:\Program Files\KeyShot Studio\bin\keyshot_headless.exe"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
macOS/Linux shell example:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
export KEYSHOT_HEADLESS_EXE="/Applications/KeyShot Studio.app/Contents/MacOS/keyshot_headless"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Then test startup:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm run status
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## MCP Client Example
|
|
123
|
+
|
|
124
|
+
Add a server like this to your MCP client config:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"mcpServers": {
|
|
129
|
+
"keyshot": {
|
|
130
|
+
"command": "node",
|
|
131
|
+
"args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
|
|
132
|
+
"env": {
|
|
133
|
+
"KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
A generic Codex configuration template is in:
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
examples/codex.example.json
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Codex Configuration
|
|
147
|
+
|
|
148
|
+
For Codex, add a `keyshot` MCP server entry to your Codex MCP configuration and point it to the built server file:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"keyshot": {
|
|
154
|
+
"command": "node",
|
|
155
|
+
"args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
|
|
156
|
+
"env": {
|
|
157
|
+
"KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Use `examples/codex.example.json` as a starting point and replace all paths with paths on your own computer.
|
|
165
|
+
|
|
166
|
+
## Prompt Examples
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
Render the current KeyShot scene into three views: front, 45-degree perspective, and top-down. Use 1920x1080 resolution and save the outputs to the configured output folder.
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
Import the model file at /path/to/model.step, apply a brushed metal material to the main housing, set a 45-degree camera, and render a product hero image.
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
Inspect this KeyShot scene and summarize the available objects, cameras, materials, and renderable outputs.
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
```text
|
|
181
|
+
List the cameras in this KeyShot scene, create or update a camera named "Hero",
|
|
182
|
+
save the scene to a new file, and render one preview from that camera.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Environment Variables
|
|
186
|
+
|
|
187
|
+
- `KEYSHOT_HEADLESS_EXE`: path to `keyshot_headless` or `keyshot_headless.exe`.
|
|
188
|
+
- `KEYSHOT_OUTPUT_DIR`: default output folder for renders.
|
|
189
|
+
- `KEYSHOT_LICENSE_ARGS`: optional KeyShot headless license arguments. Empty by default.
|
|
190
|
+
- `KEYSHOT_TIMEOUT_MS`: operation timeout in milliseconds. Default: `600000`.
|
|
191
|
+
|
|
192
|
+
`samples` and `maxTimeSeconds` select different KeyShot render modes. Provide one
|
|
193
|
+
or the other, not both.
|
|
194
|
+
|
|
195
|
+
## MCP Tools
|
|
196
|
+
|
|
197
|
+
- `keyshot_status`
|
|
198
|
+
- `keyshot_inspect_scene`
|
|
199
|
+
- `keyshot_list_cameras`: list available camera names in a scene (handy before batch rendering)
|
|
200
|
+
- `keyshot_render`: render a single image
|
|
201
|
+
- `keyshot_batch_render`
|
|
202
|
+
- `keyshot_render_queue`: run several render jobs sequentially (stops at first failure unless `continueOnError`)
|
|
203
|
+
- `keyshot_import_model`
|
|
204
|
+
- `keyshot_apply_material`
|
|
205
|
+
- `keyshot_list_material_presets`: list presets from the material preset library
|
|
206
|
+
- `keyshot_apply_material_preset`: apply a named preset from the library to an object
|
|
207
|
+
- `keyshot_set_camera`
|
|
208
|
+
- `keyshot_set_environment`
|
|
209
|
+
- `keyshot_save_scene`
|
|
210
|
+
|
|
211
|
+
### Material preset library
|
|
212
|
+
|
|
213
|
+
`keyshot_apply_material_preset` reads a small JSON registry so you can reuse named
|
|
214
|
+
looks instead of remembering exact KeyShot material names. Default location:
|
|
215
|
+
`presets/materials.json` (override with the `KEYSHOT_MATERIAL_PRESETS` env var).
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"Brushed Steel": { "materialName": "Steel Brushed", "description": "metal parts" },
|
|
220
|
+
"Clear Glass": { "materialPath": "C:/materials/glass_clear.mtl" }
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Each preset must have a `materialName` or a `materialPath`. Use
|
|
225
|
+
`keyshot_list_material_presets` to see what is available.
|
|
226
|
+
|
|
227
|
+
## MCP Prompts and Resources
|
|
228
|
+
|
|
229
|
+
- Prompt: `keyshot_product_render`
|
|
230
|
+
- Resource: `keyshot://workflow`
|
|
231
|
+
|
|
232
|
+
Each tool returns JSON with:
|
|
233
|
+
|
|
234
|
+
- `ok`
|
|
235
|
+
- `data`
|
|
236
|
+
- `outputFiles`
|
|
237
|
+
- `warnings`
|
|
238
|
+
- `keyshotStdoutTail`
|
|
239
|
+
- `error`
|
|
240
|
+
|
|
241
|
+
## Notes
|
|
242
|
+
|
|
243
|
+
KeyShot's Python `lux` API changes across versions. This server keeps the MCP interface stable and returns a clear error when an installed KeyShot version does not expose a requested headless function.
|
|
244
|
+
|
|
245
|
+
## Roadmap
|
|
246
|
+
|
|
247
|
+
- [ ] Auto-discover and batch render all cameras in a scene
|
|
248
|
+
- [x] Material preset library
|
|
249
|
+
- [ ] Camera preset templates
|
|
250
|
+
- [x] Sequential render queue
|
|
251
|
+
- [ ] Safer output directory restrictions
|
|
252
|
+
- [ ] More tested KeyShot versions
|
|
253
|
+
- [ ] macOS compatibility verification
|
|
254
|
+
- [x] Claude Desktop / Cursor / Codex config examples
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
MIT
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
# 中文说明
|
|
263
|
+
|
|
264
|
+
[English](#keyshot-mcp) | 中文
|
|
265
|
+
|
|
266
|
+
这是一个本地 KeyShot MCP 服务,可以让支持 MCP 的 AI 工具通过 KeyShot 的无界面脚本能力控制 KeyShot Studio。
|
|
267
|
+
|
|
268
|
+
简单说:你可以让 AI 帮你检查 KeyShot 场景、渲染图片、导入模型、替换材质、调整相机、设置环境并保存场景。
|
|
269
|
+
|
|
270
|
+
本项目优先面向 Windows 环境下的 KeyShot Studio 产品渲染自动化流程。
|
|
271
|
+
|
|
272
|
+
与仅面向界面操作的自动化脚本不同,本项目优先面向 KeyShot 无界面工作流,并为 AI Agent 提供稳定的 MCP 工具接口。
|
|
273
|
+
|
|
274
|
+
## 适合谁使用
|
|
275
|
+
|
|
276
|
+
- 希望用 AI 辅助 KeyShot 渲染的设计师。
|
|
277
|
+
- 想要 KeyShot MCP 桥接工具的开发者。
|
|
278
|
+
- 已经在电脑上配置好 KeyShot 授权的团队。
|
|
279
|
+
|
|
280
|
+
这个项目不包含 KeyShot,不绕过 KeyShot 授权,也不会保存许可证密钥。
|
|
281
|
+
|
|
282
|
+
## 能做什么
|
|
283
|
+
|
|
284
|
+
- 检查 KeyShot 无界面程序是否能启动。
|
|
285
|
+
- 检查 `.bip` 或 KeyShot 支持的场景文件。
|
|
286
|
+
- 把场景渲染成图片。
|
|
287
|
+
- 从同一个场景批量渲染多个指定相机。
|
|
288
|
+
- 把模型导入场景。
|
|
289
|
+
- 给对象替换材质。
|
|
290
|
+
- 创建或更新相机。
|
|
291
|
+
- 在当前 KeyShot 版本支持时设置环境。
|
|
292
|
+
- 把场景保存为新文件。
|
|
293
|
+
|
|
294
|
+
## 典型使用场景
|
|
295
|
+
|
|
296
|
+
- 批量渲染同一个 KeyShot 场景的多个相机视角。
|
|
297
|
+
- 对同一个产品模型快速测试多组材质方案。
|
|
298
|
+
- 统一输出产品首图、封面图、详情页渲染图。
|
|
299
|
+
- 用一句自然语言完成导入模型、替换材质、设置相机、渲染出图。
|
|
300
|
+
|
|
301
|
+
## 工作流程
|
|
302
|
+
|
|
303
|
+

|
|
304
|
+
|
|
305
|
+
## 使用要求
|
|
306
|
+
|
|
307
|
+
- 已安装支持 `keyshot_headless` 的 KeyShot Studio。
|
|
308
|
+
- Node.js 20 或更新版本。
|
|
309
|
+
- 电脑上已经配置好有效的 KeyShot 授权。
|
|
310
|
+
|
|
311
|
+
## 版本兼容表
|
|
312
|
+
|
|
313
|
+
| 平台 | KeyShot 版本 | Node 版本 | 状态 |
|
|
314
|
+
| --- | --- | --- | --- |
|
|
315
|
+
| Windows 11 | KeyShot Studio 2025 / 14.1 | Node 22 | 已测试 |
|
|
316
|
+
| macOS | 未测试 | - | 需要贡献者 |
|
|
317
|
+
| Linux | 未测试 | - | 需要贡献者 |
|
|
318
|
+
|
|
319
|
+
## 安装
|
|
320
|
+
|
|
321
|
+
### 安装已发布的 npm 包
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
npm install -g keyshot-mcp
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
当前发布版本为 `0.4.1`。如果你只是想使用 MCP 服务,直接安装 npm 包最简单。
|
|
328
|
+
电脑仍需要安装 KeyShot Studio,并且已经配置好本地 KeyShot 授权。
|
|
329
|
+
|
|
330
|
+
### 从源码安装
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
npm install
|
|
334
|
+
npm run build
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## 复制给 Agent 的安装提示词
|
|
338
|
+
|
|
339
|
+
如果你使用 Codex 或其他编程 Agent,可以复制下面这段话,让 Agent 帮你安装和配置 MCP:
|
|
340
|
+
|
|
341
|
+
```text
|
|
342
|
+
请帮我安装 KeyShot MCP Server:https://github.com/truman-t3/keyshot-mcp。
|
|
343
|
+
|
|
344
|
+
请你:
|
|
345
|
+
1. 克隆这个仓库;如果本地已有,就使用本地版本。
|
|
346
|
+
2. 运行 npm install 和 npm run build。
|
|
347
|
+
3. 查找我电脑上的 KeyShot headless 可执行文件路径。
|
|
348
|
+
4. 把 keyshot MCP server 添加到我的 MCP 客户端配置里。
|
|
349
|
+
5. 把 KEYSHOT_HEADLESS_EXE 设置为检测到的 keyshot_headless 路径。
|
|
350
|
+
6. 用 keyshot_status 工具测试是否配置成功。
|
|
351
|
+
7. 最后告诉我实际添加的配置,以及状态检查是否通过。
|
|
352
|
+
|
|
353
|
+
不要保存许可证密钥、账号密码或授权信息。直接使用我电脑上已有的 KeyShot 本地授权配置。
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## 配置
|
|
357
|
+
|
|
358
|
+
需要告诉 MCP 服务 KeyShot 无界面程序在哪里。
|
|
359
|
+
|
|
360
|
+
Windows PowerShell 示例:
|
|
361
|
+
|
|
362
|
+
```powershell
|
|
363
|
+
$env:KEYSHOT_HEADLESS_EXE="C:\Program Files\KeyShot Studio\bin\keyshot_headless.exe"
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
macOS/Linux 示例:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
export KEYSHOT_HEADLESS_EXE="/Applications/KeyShot Studio.app/Contents/MacOS/keyshot_headless"
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
然后测试能否启动:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
npm run status
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## MCP 客户端配置示例
|
|
379
|
+
|
|
380
|
+
把类似下面的配置加到你的 MCP 客户端里:
|
|
381
|
+
|
|
382
|
+
```json
|
|
383
|
+
{
|
|
384
|
+
"mcpServers": {
|
|
385
|
+
"keyshot": {
|
|
386
|
+
"command": "node",
|
|
387
|
+
"args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
|
|
388
|
+
"env": {
|
|
389
|
+
"KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
通用 Codex 配置模板在:
|
|
397
|
+
|
|
398
|
+
```text
|
|
399
|
+
examples/codex.example.json
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Codex 配置
|
|
403
|
+
|
|
404
|
+
如果你使用 Codex,请在 Codex 的 MCP 配置里添加一个 `keyshot` 服务,并指向构建后的服务文件:
|
|
405
|
+
|
|
406
|
+
```json
|
|
407
|
+
{
|
|
408
|
+
"mcpServers": {
|
|
409
|
+
"keyshot": {
|
|
410
|
+
"command": "node",
|
|
411
|
+
"args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
|
|
412
|
+
"env": {
|
|
413
|
+
"KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
`examples/codex.example.json` 是通用配置模板。使用时请把里面的路径换成自己电脑上的路径。
|
|
421
|
+
|
|
422
|
+
## 提示词示例
|
|
423
|
+
|
|
424
|
+
```text
|
|
425
|
+
把当前 KeyShot 场景渲染成三个视角:正视图、45 度透视图和俯视图。分辨率为 1920x1080,并保存到默认输出文件夹。
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
```text
|
|
429
|
+
导入 /path/to/model.step,给主体外壳应用拉丝金属材质,设置 45 度相机,并渲染一张产品主视觉图。
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
```text
|
|
433
|
+
检查当前 KeyShot 场景,并总结场景中的对象、相机、材质和可渲染输出。
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
```text
|
|
437
|
+
列出当前 KeyShot 场景中的相机,创建或更新一个名为“Hero”的相机,
|
|
438
|
+
把场景保存为新文件,并用这个相机渲染一张预览图。
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## 环境变量
|
|
442
|
+
|
|
443
|
+
- `KEYSHOT_HEADLESS_EXE`:`keyshot_headless` 或 `keyshot_headless.exe` 的路径。
|
|
444
|
+
- `KEYSHOT_OUTPUT_DIR`:默认渲染输出文件夹。
|
|
445
|
+
- `KEYSHOT_LICENSE_ARGS`:可选的 KeyShot 无界面许可证参数,默认留空。
|
|
446
|
+
- `KEYSHOT_TIMEOUT_MS`:单次操作超时时间,单位毫秒,默认 `600000`。
|
|
447
|
+
- `KEYSHOT_MATERIAL_PRESETS`:材质预设库 JSON 文件路径,默认 `presets/materials.json`。
|
|
448
|
+
|
|
449
|
+
`samples` 和 `maxTimeSeconds` 是两种不同的 KeyShot 渲染模式,请二选一,不要同时传入。
|
|
450
|
+
|
|
451
|
+
## MCP 工具
|
|
452
|
+
|
|
453
|
+
- `keyshot_status`:检查 KeyShot 是否能启动。
|
|
454
|
+
- `keyshot_inspect_scene`:检查场景内容。
|
|
455
|
+
- `keyshot_list_cameras`:列出场景中所有相机名称(批量渲染前很有用)。
|
|
456
|
+
- `keyshot_render`:渲染单张图片。
|
|
457
|
+
- `keyshot_batch_render`:批量渲染多个相机视角。
|
|
458
|
+
- `keyshot_render_queue`:顺序执行多个渲染任务(默认遇错即停,设置 `continueOnError` 可继续)。
|
|
459
|
+
- `keyshot_import_model`:导入模型。
|
|
460
|
+
- `keyshot_apply_material`:替换材质。
|
|
461
|
+
- `keyshot_list_material_presets`:列出材质预设库中的预设。
|
|
462
|
+
- `keyshot_apply_material_preset`:把预设库中的某个命名材质应用到物体上。
|
|
463
|
+
- `keyshot_set_camera`:设置相机。
|
|
464
|
+
- `keyshot_set_environment`:设置环境。
|
|
465
|
+
- `keyshot_save_scene`:保存场景。
|
|
466
|
+
|
|
467
|
+
### 材质预设库
|
|
468
|
+
|
|
469
|
+
`keyshot_apply_material_preset` 会读取一个小的 JSON 注册表,让你用"好记的名字"复用材质,
|
|
470
|
+
而不必记住 KeyShot 里精确的材质名。默认位置:`presets/materials.json`
|
|
471
|
+
(可用环境变量 `KEYSHOT_MATERIAL_PRESETS` 覆盖)。
|
|
472
|
+
|
|
473
|
+
```json
|
|
474
|
+
{
|
|
475
|
+
"拉丝钢": { "materialName": "Steel Brushed", "description": "金属件默认材质" },
|
|
476
|
+
"透明玻璃": { "materialPath": "C:/materials/glass_clear.mtl" }
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
每个预设必须包含 `materialName` 或 `materialPath`。用 `keyshot_list_material_presets` 查看有哪些预设。
|
|
481
|
+
|
|
482
|
+
## MCP 提示词和资源
|
|
483
|
+
|
|
484
|
+
- 提示词:`keyshot_product_render`
|
|
485
|
+
- 资源:`keyshot://workflow`
|
|
486
|
+
|
|
487
|
+
每个工具都会返回 JSON,包含:
|
|
488
|
+
|
|
489
|
+
- `ok`:是否成功。
|
|
490
|
+
- `data`:主要结果。
|
|
491
|
+
- `outputFiles`:生成的文件。
|
|
492
|
+
- `warnings`:警告信息。
|
|
493
|
+
- `keyshotStdoutTail`:KeyShot 输出摘要。
|
|
494
|
+
- `error`:错误信息。
|
|
495
|
+
|
|
496
|
+
## 说明
|
|
497
|
+
|
|
498
|
+
KeyShot 的 Python `lux` API 会随版本变化。这个 MCP 会尽量保持对外工具名称稳定;如果当前 KeyShot 版本不支持某个无界面功能,会返回明确错误,而不是假装成功。
|
|
499
|
+
|
|
500
|
+
## 路线图
|
|
501
|
+
|
|
502
|
+
- [ ] 自动发现并批量渲染场景中的所有相机
|
|
503
|
+
- [x] 材质预设库
|
|
504
|
+
- [ ] 相机预设模板
|
|
505
|
+
- [x] 顺序渲染队列
|
|
506
|
+
- [ ] 更安全的输出目录限制
|
|
507
|
+
- [ ] 测试更多 KeyShot 版本
|
|
508
|
+
- [ ] 验证 macOS 兼容性
|
|
509
|
+
- [x] 补充 Claude Desktop / Cursor / Codex 配置示例
|
|
510
|
+
|
|
511
|
+
## 测试
|
|
512
|
+
|
|
513
|
+
项目带了两套测试,不依赖真实的 KeyShot 也能跑:
|
|
514
|
+
|
|
515
|
+
- **TypeScript 测试(Vitest)**:覆盖配置读取、参数校验(schemas)、结果封装,以及用"假 KeyShot"跑通一次成功路径并验证 `work/tmp` 临时文件会被清理。
|
|
516
|
+
|
|
517
|
+
```bash
|
|
518
|
+
npm install
|
|
519
|
+
npm test
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
- **Python bridge 测试(unittest)**:用假的 `lux` 对象验证 `import_model` 会真正打开基础场景、`set_camera` 在拿不到相机对象时不会崩溃并回退到 `lux` 级 API。
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
python tests/test_bridge.py
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
## 开源协议
|
|
529
|
+
|
|
530
|
+
MIT
|
|
531
|
+
|
|
532
|
+
## Star History / 星标趋势
|
|
533
|
+
|
|
534
|
+

|
|
535
|
+
|
|
536
|
+
This chart is generated from GitHub stargazer data and refreshed by GitHub Actions.
|
|
537
|
+
|
|
538
|
+
这张图由 GitHub star 数据生成,并通过 GitHub Actions 定时刷新。
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Security / 安全说明
|
|
2
|
+
|
|
3
|
+
## English
|
|
4
|
+
|
|
5
|
+
This MCP server runs KeyShot headless on the local machine. It can read scene/model files and write rendered images or saved scenes.
|
|
6
|
+
|
|
7
|
+
### Safe Use
|
|
8
|
+
|
|
9
|
+
- Only connect this server to MCP clients you trust.
|
|
10
|
+
- Only open scene/model/material files from trusted sources.
|
|
11
|
+
- Do not put license keys, account passwords, or private tokens in prompts.
|
|
12
|
+
- Prefer using the local KeyShot license configuration instead of passing license details through environment variables.
|
|
13
|
+
|
|
14
|
+
### Reporting Issues
|
|
15
|
+
|
|
16
|
+
If you find a security issue, open a private advisory or contact the project maintainer directly before posting details publicly.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 中文
|
|
21
|
+
|
|
22
|
+
这个 MCP 服务会在本机运行 KeyShot 无界面程序。它可以读取场景、模型、材质文件,也可以写入渲染图片或保存后的场景文件。
|
|
23
|
+
|
|
24
|
+
### 安全使用建议
|
|
25
|
+
|
|
26
|
+
- 只把这个服务连接到你信任的 MCP 客户端。
|
|
27
|
+
- 只打开来源可信的场景、模型和材质文件。
|
|
28
|
+
- 不要在提示词里输入许可证密钥、账号密码或私人 token。
|
|
29
|
+
- 优先使用本机已经配置好的 KeyShot 授权,不建议通过环境变量传递许可证细节。
|
|
30
|
+
|
|
31
|
+
### 报告安全问题
|
|
32
|
+
|
|
33
|
+
如果发现安全问题,请先通过私密方式联系维护者,不要直接公开细节。
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
const DEFAULT_KEYSHOT_EXE = process.platform === "win32" ? "keyshot_headless.exe" : "keyshot_headless";
|
|
4
|
+
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
5
|
+
export function getConfig() {
|
|
6
|
+
const projectRoot = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
|
|
7
|
+
const keyshotOutputDir = path.resolve(process.env.KEYSHOT_OUTPUT_DIR ?? path.join(projectRoot, "outputs"));
|
|
8
|
+
return {
|
|
9
|
+
projectRoot,
|
|
10
|
+
keyshotHeadlessExe: process.env.KEYSHOT_HEADLESS_EXE ?? DEFAULT_KEYSHOT_EXE,
|
|
11
|
+
keyshotOutputDir,
|
|
12
|
+
keyshotLicenseArgs: splitWindowsArgs(process.env.KEYSHOT_LICENSE_ARGS ?? ""),
|
|
13
|
+
keyshotTimeoutMs: parsePositiveInt(process.env.KEYSHOT_TIMEOUT_MS, DEFAULT_TIMEOUT_MS),
|
|
14
|
+
tmpDir: path.join(projectRoot, "work", "tmp"),
|
|
15
|
+
bridgeScriptPath: path.join(projectRoot, "scripts", "keyshot_bridge.py"),
|
|
16
|
+
materialPresetsPath: path.resolve(process.env.KEYSHOT_MATERIAL_PRESETS ?? path.join(projectRoot, "presets", "materials.json")),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function parsePositiveInt(value, fallback) {
|
|
20
|
+
if (!value)
|
|
21
|
+
return fallback;
|
|
22
|
+
const parsed = Number.parseInt(value, 10);
|
|
23
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
24
|
+
}
|
|
25
|
+
function splitWindowsArgs(value) {
|
|
26
|
+
const args = [];
|
|
27
|
+
let current = "";
|
|
28
|
+
let quote = null;
|
|
29
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
30
|
+
const ch = value[i];
|
|
31
|
+
if ((ch === '"' || ch === "'") && quote === null) {
|
|
32
|
+
quote = ch;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (ch === quote) {
|
|
36
|
+
quote = null;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (/\s/.test(ch) && quote === null) {
|
|
40
|
+
if (current) {
|
|
41
|
+
args.push(current);
|
|
42
|
+
current = "";
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
current += ch;
|
|
47
|
+
}
|
|
48
|
+
if (current)
|
|
49
|
+
args.push(current);
|
|
50
|
+
return args;
|
|
51
|
+
}
|