keyshot-mcp 0.6.0 → 0.8.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
@@ -1,705 +1,599 @@
1
1
  # KeyShot MCP
2
2
 
3
- [![MCP Badge](https://lobehub.com/badge/mcp/truman-t3-keyshot-mcp)](https://lobehub.com/mcp/truman-t3-keyshot-mcp)
4
- [![GitHub Release](https://img.shields.io/github/v/release/truman-t3/keyshot-mcp)](https://github.com/truman-t3/keyshot-mcp/releases)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
3
+ [![npm version](https://img.shields.io/npm/v/keyshot-mcp.svg)](https://www.npmjs.com/package/keyshot-mcp)
4
+ [![CI](https://github.com/truman-t3/keyshot-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/truman-t3/keyshot-mcp/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
6
 
7
- English | [中文](#中文说明)
7
+ [English](#english) | [中文](#中文)
8
8
 
9
- A local MCP server for controlling KeyShot Studio through KeyShot headless scripting.
9
+ KeyShot MCP is a local [Model Context Protocol](https://modelcontextprotocol.io/)
10
+ server for inspecting, editing, and rendering KeyShot scenes through KeyShot
11
+ headless scripting. It lets an MCP-compatible AI agent perform repeatable product
12
+ visualization tasks while scenes, models, licenses, and rendered files remain on
13
+ the local computer.
10
14
 
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.
15
+ ![KeyShot MCP workflow](assets/workflow.svg)
12
16
 
13
- Optimized for Windows-based KeyShot Studio product visualization workflows.
17
+ ## English
14
18
 
15
- Unlike GUI-only automation scripts, this project targets KeyShot headless workflows and keeps a stable MCP interface for AI agents.
19
+ ### What it can do
16
20
 
17
- ## Who This Is For
21
+ - Inspect scene objects, materials, cameras, model sets, and external references.
22
+ - Import models and optionally center them, place them on the ground, update the
23
+ camera target, and adjust the environment.
24
+ - Render one camera, selected cameras, every camera in a scene, or a sequential
25
+ render queue.
26
+ - Create and update cameras by position, look-at point, distance, field of view,
27
+ focal length, or reusable presets.
28
+ - Apply materials directly or through a local material preset library.
29
+ - Select environments, change brightness, and rotate the active environment.
30
+ - Save edited scenes to a controlled output directory.
31
+ - Prepare and render a product from a model or existing scene in one tool call.
18
32
 
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.
33
+ ### Requirements and compatibility
22
34
 
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
- - Automatically discover and render every camera in one scene.
32
- - Import a model into a scene.
33
- - Apply a material to an object.
34
- - Create or update a camera.
35
- - Apply reusable standard or custom camera presets.
36
- - Set an environment when the installed KeyShot version exposes that function.
37
- - Save a scene to a new file.
38
-
39
- ## Example Workflows
40
-
41
- - Batch render multiple camera views from one KeyShot scene.
42
- - Test several material options on the same product model.
43
- - Generate product hero images with consistent resolution and output naming.
44
- - Import a model, apply a material preset, set a camera, and render in one AI instruction.
45
-
46
- ## Workflow
47
-
48
- ![KeyShot MCP Workflow](assets/workflow.svg)
49
-
50
- ## Requirements
51
-
52
- - KeyShot Studio with `keyshot_headless` support.
53
35
  - Node.js 20 or newer.
54
- - A valid KeyShot license already configured on the computer.
55
-
56
- ## Compatibility
57
-
58
- | Platform | KeyShot Version | Node Version | Status |
59
- | --- | --- | --- | --- |
60
- | Windows 11 | KeyShot Studio 2025 / 14.1 | Node 22 | Tested |
61
- | macOS | Not tested | - | Need contributors |
62
- | Linux | Not tested | - | Need contributors |
63
-
64
- ## Install
65
-
66
- ### Install the published npm package
67
-
68
- ```bash
69
- npm install -g keyshot-mcp
70
- ```
71
-
72
- The current release line is `0.6.0`. The published package is the easiest option
73
- when you only want to use the MCP server. You still need KeyShot Studio and a
74
- local KeyShot license.
75
-
76
- ### Install from source
77
-
78
- ```bash
79
- npm install
80
- npm run build
81
- ```
82
-
83
- ### Three MCP configuration options
84
-
85
- Use exactly one of these approaches:
36
+ - A locally installed and licensed KeyShot version with headless scripting.
37
+ - Windows 11 with KeyShot Studio 2025 / KeyShot 14.1 is tested.
38
+ - Other KeyShot versions may work when they expose the same official scripting
39
+ APIs, but they are not currently verified by this project.
40
+ - KeyShot and its license are not included.
86
41
 
87
- **Global npm installation** (`npm install -g keyshot-mcp`):
88
-
89
- ```json
90
- {"mcpServers":{"keyshot":{"command":"keyshot-mcp","env":{"KEYSHOT_HEADLESS_EXE":"/absolute/path/to/keyshot_headless"}}}}
91
- ```
42
+ ### Install
92
43
 
93
- **No installation, run with npx**:
44
+ The current release is `0.8.0`.
94
45
 
95
- ```json
96
- {"mcpServers":{"keyshot":{"command":"npx","args":["-y","keyshot-mcp@0.6.0"],"env":{"KEYSHOT_HEADLESS_EXE":"/absolute/path/to/keyshot_headless"}}}}
97
- ```
46
+ #### Option 1: run with npx
98
47
 
99
- **Run from a cloned source directory** (after `npm install && npm run build`):
48
+ This requires no global npm installation:
100
49
 
101
50
  ```json
102
- {"mcpServers":{"keyshot":{"command":"node","args":["/absolute/path/to/keyshot-mcp/dist/index.js"],"env":{"KEYSHOT_HEADLESS_EXE":"/absolute/path/to/keyshot_headless"}}}}
103
- ```
104
-
105
- ## Copy-Paste Setup Prompt for an Agent
106
-
107
- If you use Codex or another coding agent, you can copy this prompt and let the agent install the MCP server for you:
108
-
109
- ```text
110
- Install KeyShot MCP 0.6.0 from npm and configure it in my MCP client.
111
-
112
- Please:
113
- 1. Find my KeyShot headless executable path.
114
- 2. Add a keyshot MCP server using npx -y keyshot-mcp@0.6.0.
115
- 3. Set KEYSHOT_HEADLESS_EXE to the detected keyshot_headless path.
116
- 4. Test the setup by running the keyshot_status tool.
117
- 5. Tell me the exact config that was added and whether the status check passed.
118
-
119
- Do not store license keys or account passwords. Use my existing local KeyShot license configuration.
120
- ```
121
-
122
- ## Configure
123
-
124
- Set the path to your KeyShot headless executable.
125
-
126
- Windows PowerShell example:
127
-
128
- ```powershell
129
- $env:KEYSHOT_HEADLESS_EXE="C:\Program Files\KeyShot Studio\bin\keyshot_headless.exe"
130
- ```
131
-
132
- macOS/Linux shell example:
133
-
134
- ```bash
135
- export KEYSHOT_HEADLESS_EXE="/Applications/KeyShot Studio.app/Contents/MacOS/keyshot_headless"
51
+ {
52
+ "mcpServers": {
53
+ "keyshot": {
54
+ "command": "npx",
55
+ "args": ["-y", "keyshot-mcp@0.8.0"],
56
+ "env": {
57
+ "KEYSHOT_HEADLESS_EXE": "C:/Program Files/KeyShot Studio/bin/keyshot_headless.exe"
58
+ }
59
+ }
60
+ }
61
+ }
136
62
  ```
137
63
 
138
- Then test startup:
64
+ #### Option 2: install globally
139
65
 
140
66
  ```bash
141
- npm run status
67
+ npm install -g keyshot-mcp@0.8.0
142
68
  ```
143
69
 
144
- ## MCP Client Example
145
-
146
- Add a server like this to your MCP client config:
147
-
148
70
  ```json
149
71
  {
150
72
  "mcpServers": {
151
73
  "keyshot": {
152
- "command": "node",
153
- "args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
74
+ "command": "keyshot-mcp",
154
75
  "env": {
155
- "KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
76
+ "KEYSHOT_HEADLESS_EXE": "C:/Program Files/KeyShot Studio/bin/keyshot_headless.exe"
156
77
  }
157
78
  }
158
79
  }
159
80
  }
160
81
  ```
161
82
 
162
- A generic Codex configuration template is in:
83
+ #### Option 3: run from source
163
84
 
164
- ```text
165
- examples/codex.example.json
85
+ ```bash
86
+ git clone https://github.com/truman-t3/keyshot-mcp.git
87
+ cd keyshot-mcp
88
+ pnpm install
89
+ pnpm build
166
90
  ```
167
91
 
168
- ## Codex Configuration
169
-
170
- For Codex, add a `keyshot` MCP server entry to your Codex MCP configuration and point it to the built server file:
92
+ Configure the MCP client to run the absolute path to `dist/index.js`:
171
93
 
172
94
  ```json
173
95
  {
174
96
  "mcpServers": {
175
97
  "keyshot": {
176
98
  "command": "node",
177
- "args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
99
+ "args": ["C:/absolute/path/to/keyshot-mcp/dist/index.js"],
178
100
  "env": {
179
- "KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
101
+ "KEYSHOT_HEADLESS_EXE": "C:/Program Files/KeyShot Studio/bin/keyshot_headless.exe"
180
102
  }
181
103
  }
182
104
  }
183
105
  }
184
106
  ```
185
107
 
186
- Use `examples/codex.example.json` as a starting point and replace all paths with paths on your own computer.
108
+ Restart the MCP client after changing its configuration.
187
109
 
188
- ## Prompt Examples
110
+ ### Agent installation prompt
189
111
 
190
- ```text
191
- 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.
192
- ```
193
-
194
- ```text
195
- 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.
196
- ```
112
+ The following prompt can be pasted into a coding agent that is allowed to edit
113
+ the MCP client configuration:
197
114
 
198
115
  ```text
199
- Inspect this KeyShot scene and summarize the available objects, cameras, materials, and renderable outputs.
200
- ```
116
+ Install KeyShot MCP 0.8.0 and configure it in my MCP client.
117
+
118
+ 1. Find the local KeyShot headless executable.
119
+ 2. Add an MCP server named "keyshot" that runs:
120
+ npx -y keyshot-mcp@0.8.0
121
+ 3. Set KEYSHOT_HEADLESS_EXE to the executable path.
122
+ 4. Keep KEYSHOT_ALLOW_EXTERNAL_OUTPUTS disabled.
123
+ 5. Restart or reload the MCP client, call keyshot_status, then use keyshot_product_render for a one-click product render.
124
+ 6. Do not upload or publish any KeyShot scenes, models, renders, or license data.
125
+ ```
126
+
127
+ ### Configuration
128
+
129
+ | Variable | Default | Purpose |
130
+ | --- | --- | --- |
131
+ | `KEYSHOT_HEADLESS_EXE` | `keyshot_headless.exe` on Windows | Absolute executable path or a command available on `PATH`. |
132
+ | `KEYSHOT_OUTPUT_DIR` | Package-local `outputs` | Root directory for rendered images and saved scenes. |
133
+ | `KEYSHOT_ALLOW_EXTERNAL_OUTPUTS` | `false` | Allows output paths outside `KEYSHOT_OUTPUT_DIR` when explicitly set to `true`. |
134
+ | `KEYSHOT_TIMEOUT_MS` | `600000` | Timeout for one KeyShot headless process. |
135
+ | `KEYSHOT_LICENSE_ARGS` | empty | Optional additional KeyShot launch arguments. |
136
+ | `KEYSHOT_MATERIAL_PRESETS` | Built-in `presets/materials.json` | Path to a user-managed material preset file. |
137
+ | `KEYSHOT_CAMERA_PRESETS` | Built-in `presets/cameras.json` | Path to a user-managed camera preset file. |
138
+
139
+ Relative output paths are resolved inside `KEYSHOT_OUTPUT_DIR`. Parent traversal,
140
+ adjacent-prefix paths, and symbolic-link escapes are rejected by default. Input
141
+ scene, model, material, and environment paths may be located elsewhere.
142
+
143
+ ### Tools
144
+
145
+ | Tool | Purpose |
146
+ | --- | --- |
147
+ | `keyshot_status` | Verify that KeyShot headless can start and report its version. |
148
+ | `keyshot_product_render` | Prepare, save, and render a model or existing scene in one headless process. |
149
+ | `keyshot_inspect_scene` | Inspect objects, cameras, materials, model sets, and references. |
150
+ | `keyshot_list_cameras` | List available camera names. |
151
+ | `keyshot_render` | Render one image. |
152
+ | `keyshot_render_queue` | Run independent render jobs sequentially. |
153
+ | `keyshot_batch_render` | Render a supplied list of named cameras from one scene. |
154
+ | `keyshot_render_all_cameras` | Discover and render every camera in one scene. |
155
+ | `keyshot_import_model` | Import a model with optional composition adjustments. |
156
+ | `keyshot_apply_material` | Apply a library material or material file. |
157
+ | `keyshot_list_material_presets` | List local material presets. |
158
+ | `keyshot_apply_material_preset` | Apply a named material preset. |
159
+ | `keyshot_set_camera` | Create or update camera transform, distance, FOV, or focal length. |
160
+ | `keyshot_list_camera_presets` | List standard and custom camera presets. |
161
+ | `keyshot_apply_camera_preset` | Apply a standard or absolute-coordinate camera preset. |
162
+ | `keyshot_set_environment` | Select or adjust an environment, brightness, or rotation. |
163
+ | `keyshot_save_scene` | Save a scene to a new output path. |
164
+
165
+ The server exposes 17 tools, a `keyshot_product_render` MCP prompt, and a
166
+ `keyshot://workflow` resource.
167
+
168
+ ### One-click product render
169
+
170
+ In an MCP client, a designer can use a natural-language request:
201
171
 
202
172
  ```text
203
- List the cameras in this KeyShot scene, create or update a camera named "Hero",
204
- save the scene to a new file, and render one preview from that camera.
173
+ Turn C:\models\speaker.obj into a product render. Center it, place it on the
174
+ ground, use the Isometric camera preset, save the KeyShot scene, and render a
175
+ 1600 x 1200 PNG with 128 samples.
205
176
  ```
206
177
 
207
- ```text
208
- Find every camera in this KeyShot scene and render all views to the all-cameras
209
- output folder. Continue if one camera fails and report the result for each view.
210
- ```
211
-
212
- ```text
213
- List the available camera presets, apply the Isometric preset as a camera named
214
- "Catalog Isometric", save a new scene, and render a preview from that camera.
215
- ```
216
-
217
- ## Environment Variables
218
-
219
- - `KEYSHOT_HEADLESS_EXE`: path to `keyshot_headless` or `keyshot_headless.exe`.
220
- - `KEYSHOT_OUTPUT_DIR`: default output folder for renders.
221
- - `KEYSHOT_LICENSE_ARGS`: optional KeyShot headless license arguments. Empty by default.
222
- - `KEYSHOT_TIMEOUT_MS`: operation timeout in milliseconds. Default: `600000`.
223
- - `KEYSHOT_ALLOW_EXTERNAL_OUTPUTS`: allow output paths outside `KEYSHOT_OUTPUT_DIR`. Default: `false`.
224
- - `KEYSHOT_CAMERA_PRESETS`: camera preset JSON file. Default: `presets/cameras.json`.
225
-
226
- By default every output file must stay inside `KEYSHOT_OUTPUT_DIR`. Relative paths
227
- are placed there automatically. Set the compatibility switch to `true` only when
228
- an external output location is intentional; input scenes and models are unrestricted.
229
-
230
- `samples` and `maxTimeSeconds` select different KeyShot render modes. Provide one
231
- or the other, not both.
232
-
233
- ## MCP Tools
234
-
235
- - `keyshot_status`
236
- - `keyshot_inspect_scene`
237
- - `keyshot_list_cameras`: list available camera names in a scene (handy before batch rendering)
238
- - `keyshot_render`: render a single image
239
- - `keyshot_batch_render`
240
- - `keyshot_render_all_cameras`: discover and render every camera in a scene; continues after individual failures by default
241
- - `keyshot_render_queue`: run several render jobs sequentially (stops at first failure unless `continueOnError`)
242
- - `keyshot_import_model`
243
- - `keyshot_apply_material`
244
- - `keyshot_list_material_presets`: list presets from the material preset library
245
- - `keyshot_apply_material_preset`: apply a named preset from the library to an object
246
- - `keyshot_set_camera`
247
- - `keyshot_list_camera_presets`: list standard and custom camera presets
248
- - `keyshot_apply_camera_preset`: create or update a named camera from a preset
249
- - `keyshot_set_environment`
250
- - `keyshot_save_scene`
251
-
252
- ### Render every camera automatically
253
-
254
- `keyshot_render_all_cameras` discovers camera names from the open scene and renders
255
- them in one KeyShot headless session. `continueOnError` defaults to `true`, so a
256
- failed camera is reported without blocking the remaining views. Safe duplicate
257
- filenames receive `-2`, `-3`, and later suffixes. Existing files are preserved
258
- unless `overwrite` is set to `true`. KeyShot's internal, non-activatable
259
- `last_active` placeholder is reported and skipped.
260
-
261
- ### Material preset library
262
-
263
- `keyshot_apply_material_preset` reads a small JSON registry so you can reuse named
264
- looks instead of remembering exact KeyShot material names. Default location:
265
- `presets/materials.json` (override with the `KEYSHOT_MATERIAL_PRESETS` env var).
178
+ The `keyshot_product_render` tool accepts either `modelPath` or `scenePath`. New
179
+ models default to centered and grounded geometry with a `Product Hero`
180
+ isometric camera. Existing scenes keep their current camera, materials, and
181
+ environment unless explicit changes are requested.
266
182
 
267
183
  ```json
268
184
  {
269
- "Brushed Steel": { "materialName": "Steel Brushed", "description": "metal parts" },
270
- "Clear Glass": { "materialPath": "C:/materials/glass_clear.mtl" }
185
+ "modelPath": "C:/models/speaker.obj",
186
+ "outputScenePath": "speaker-product.bip",
187
+ "outputPath": "speaker-product.png",
188
+ "materialAssignments": [
189
+ { "objectName": "Body", "presetName": "Brushed Steel" }
190
+ ],
191
+ "cameraPresetName": "Isometric",
192
+ "focalLength": 55,
193
+ "brightness": 1.2,
194
+ "rotation": 45,
195
+ "width": 1600,
196
+ "height": 1200,
197
+ "samples": 128
271
198
  }
272
199
  ```
273
200
 
274
- Each preset must have a `materialName` or a `materialPath`. Use
275
- `keyshot_list_material_presets` to see what is available.
201
+ Use `renderMode: "allCameras"` with `outputDir` to render every named camera.
202
+ Generated names are derived from the source filename when output paths are
203
+ omitted. Existing files are protected by default; set `overwrite: true` only
204
+ when replacement is intentional. Material assignments always require an
205
+ explicit object and never overwrite the entire model implicitly.
206
+
207
+ ### Product composition examples
276
208
 
277
- ### Camera preset library
209
+ Import a model and prepare its initial composition:
278
210
 
279
- The built-in `presets/cameras.json` provides Front, Back, Left, Right, Top,
280
- Bottom, and Isometric standard views. Use `keyshot_list_camera_presets` to list
281
- them and `keyshot_apply_camera_preset` to create or update a named camera.
211
+ ```text
212
+ Import C:\models\speaker.obj into KeyShot. Center the geometry, place it on the
213
+ ground, update the camera look-at point and environment, then save the scene as
214
+ speaker-prepared.bip.
215
+ ```
282
216
 
283
- Set `KEYSHOT_CAMERA_PRESETS` to a user-managed JSON file for custom presets:
217
+ The corresponding `keyshot_import_model` options are:
284
218
 
285
219
  ```json
286
220
  {
287
- "Front": { "standardView": "front" },
288
- "Hero": {
289
- "position": [4.5, 3.5, 4.5],
290
- "lookAt": [0, 0, 0],
291
- "up": [0, 1, 0],
292
- "description": "Custom absolute product camera"
293
- }
221
+ "centerGeometry": true,
222
+ "snapToGround": true,
223
+ "adjustCameraLookAt": true,
224
+ "adjustEnvironment": true
294
225
  }
295
226
  ```
296
227
 
297
- A preset file may use the object format shown above or an array whose entries
298
- include a `name`. Each preset must contain either one supported `standardView`,
299
- or both `position` and `lookAt`. Preset files are read-only to this MCP server.
228
+ Create a product camera with one lens control:
300
229
 
301
- ## MCP Prompts and Resources
230
+ ```text
231
+ Set the Product Hero camera to a 55 mm focal length and distance 6, save a new
232
+ scene, then render a PNG preview.
233
+ ```
302
234
 
303
- - Prompt: `keyshot_product_render`
304
- - Resource: `keyshot://workflow`
235
+ `fieldOfView` must be greater than `0` and less than `180`. `focalLength` accepts
236
+ `5` to `200` mm. The two controls are mutually exclusive. `position` and
237
+ `lookAt` are optional, but must be supplied together when changing the transform.
305
238
 
306
- Each tool returns JSON with:
239
+ Rotate the active HDRI or environment:
307
240
 
308
- - `ok`
309
- - `data`
310
- - `outputFiles`
311
- - `warnings`
312
- - `keyshotStdoutTail`
313
- - `error`
241
+ ```text
242
+ Rotate the current KeyShot environment to 45 degrees, save the edited scene,
243
+ and render all cameras.
244
+ ```
314
245
 
315
- ## Notes
246
+ `rotation` accepts values from `0` inclusive to `360` exclusive.
316
247
 
317
- 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.
248
+ For rendering, `samples` and `maxTimeSeconds` select different KeyShot render
249
+ modes and cannot be supplied together.
318
250
 
319
- ## Roadmap
251
+ ### Camera and material presets
320
252
 
321
- - [x] Auto-discover and batch render all cameras in a scene
322
- - [x] Material preset library
323
- - [x] Camera preset templates
324
- - [x] Sequential render queue
325
- - [x] Safer output directory restrictions
326
- - [ ] More tested KeyShot versions
327
- - [ ] macOS compatibility verification
328
- - [x] Claude Desktop / Cursor / Codex config examples
253
+ The built-in camera library includes Front, Back, Left, Right, Top, Bottom, and
254
+ Isometric views. A custom `KEYSHOT_CAMERA_PRESETS` JSON file may contain standard
255
+ views or absolute `position`, `lookAt`, and optional `up` vectors.
329
256
 
330
- ## Real KeyShot demo
257
+ Material presets are stored in JSON and reference KeyShot library material names
258
+ or local material files. The MCP server reads preset files but does not modify
259
+ them.
331
260
 
332
- ![KeyShot MCP generated cube demo](assets/demo/keyshot-mcp-demo.png)
261
+ ### Reproducible KeyShot smoke test
333
262
 
334
- The demo uses only the generated geometry in `examples/demo`. To reproduce the
335
- status, import, inspect, two-camera creation, save, discovery, and PNG-render workflow locally:
263
+ The repository includes a smoke test built from generated cube geometry in
264
+ `examples/demo`. It verifies startup, import composition, scene inspection,
265
+ camera presets, focal length, field of view, camera distance, environment
266
+ rotation, scene saving, camera discovery, one-click model rendering, one-click
267
+ existing-scene rendering, and real PNG output:
336
268
 
337
269
  ```bash
338
270
  npm run smoke:keyshot
339
271
  ```
340
272
 
341
- ## License
342
-
343
- MIT
344
-
345
- ---
346
-
347
- # 中文说明
348
-
349
- [English](#keyshot-mcp) | 中文
350
-
351
- 这是一个本地 KeyShot MCP 服务,可以让支持 MCP 的 AI 工具通过 KeyShot 的无界面脚本能力控制 KeyShot Studio。
352
-
353
- 简单说:你可以让 AI 帮你检查 KeyShot 场景、渲染图片、导入模型、替换材质、调整相机、设置环境并保存场景。
354
-
355
- 本项目优先面向 Windows 环境下的 KeyShot Studio 产品渲染自动化流程。
356
-
357
- 与仅面向界面操作的自动化脚本不同,本项目优先面向 KeyShot 无界面工作流,并为 AI Agent 提供稳定的 MCP 工具接口。
358
-
359
- ## 适合谁使用
360
-
361
- - 希望用 AI 辅助 KeyShot 渲染的设计师。
362
- - 想要 KeyShot MCP 桥接工具的开发者。
363
- - 已经在电脑上配置好 KeyShot 授权的团队。
364
-
365
- 这个项目不包含 KeyShot,不绕过 KeyShot 授权,也不会保存许可证密钥。
366
-
367
- ## 能做什么
368
-
369
- - 检查 KeyShot 无界面程序是否能启动。
370
- - 检查 `.bip` 或 KeyShot 支持的场景文件。
371
- - 把场景渲染成图片。
372
- - 从同一个场景批量渲染多个指定相机。
373
- - 自动发现并渲染场景中的全部相机。
374
- - 把模型导入场景。
375
- - 给对象替换材质。
376
- - 创建或更新相机。
377
- - 应用可复用的标准或自定义相机预设。
378
- - 在当前 KeyShot 版本支持时设置环境。
379
- - 把场景保存为新文件。
380
-
381
- ## 典型使用场景
382
-
383
- - 批量渲染同一个 KeyShot 场景的多个相机视角。
384
- - 对同一个产品模型快速测试多组材质方案。
385
- - 统一输出产品首图、封面图、详情页渲染图。
386
- - 用一句自然语言完成导入模型、替换材质、设置相机、渲染出图。
387
-
388
- ## 工作流程
389
-
390
- ![KeyShot MCP Workflow](assets/workflow.svg)
273
+ Generated `.bip` files and test renders remain in the configured local output
274
+ directory. The repository includes one representative result:
391
275
 
392
- ## 使用要求
276
+ ![KeyShot smoke test render](assets/demo/keyshot-mcp-demo.png)
393
277
 
394
- - 已安装支持 `keyshot_headless` 的 KeyShot Studio。
395
- - Node.js 20 或更新版本。
396
- - 电脑上已经配置好有效的 KeyShot 授权。
397
-
398
- ## 版本兼容表
399
-
400
- | 平台 | KeyShot 版本 | Node 版本 | 状态 |
401
- | --- | --- | --- | --- |
402
- | Windows 11 | KeyShot Studio 2025 / 14.1 | Node 22 | 已测试 |
403
- | macOS | 未测试 | - | 需要贡献者 |
404
- | Linux | 未测试 | - | 需要贡献者 |
405
-
406
- ## 安装
407
-
408
- ### 安装已发布的 npm 包
278
+ ### Development and tests
409
279
 
410
280
  ```bash
411
- npm install -g keyshot-mcp
281
+ pnpm install
282
+ pnpm check
283
+ pnpm test
284
+ python -m unittest discover -s tests -p "test_*.py"
285
+ npm pack --dry-run
412
286
  ```
413
287
 
414
- 当前发布版本为 `0.6.0`。如果你只是想使用 MCP 服务,直接安装 npm 包最简单。
415
- 电脑仍需要安装 KeyShot Studio,并且已经配置好本地 KeyShot 授权。
288
+ CI runs on Windows and Ubuntu with Node.js 20 and 24. Linux CI validates the MCP
289
+ server, bridge logic, and package; it does not claim that KeyShot itself runs on
290
+ Linux.
416
291
 
417
- ### 从源码安装
292
+ ### Roadmap
418
293
 
419
- ```bash
420
- npm install
421
- npm run build
422
- ```
294
+ - Verify additional KeyShot releases on real installations.
295
+ - Verify macOS installation and headless behavior.
296
+ - Add depth-of-field and additional lens controls when stable headless APIs are
297
+ available.
423
298
 
424
- ### 三种独立配置方式
299
+ ### License and security
425
300
 
426
- 下面三种方式选择一种即可:
301
+ Released under the [MIT License](LICENSE). See [SECURITY.md](SECURITY.md) for
302
+ security guidance and [CONTRIBUTING.md](CONTRIBUTING.md) for development notes.
303
+ Do not commit KeyShot licenses, private scenes, customer assets, or unpublished
304
+ renders.
427
305
 
428
- **全局 npm 安装**(先运行 `npm install -g keyshot-mcp`):
306
+ ### Trademark and project status
429
307
 
430
- ```json
431
- {"mcpServers":{"keyshot":{"command":"keyshot-mcp","env":{"KEYSHOT_HEADLESS_EXE":"C:/KeyShot/bin/keyshot_headless.exe"}}}}
432
- ```
308
+ KeyShot is a trademark of KeyShot ApS and/or KeyShot Inc. This is an independent,
309
+ open-source community project and is not affiliated with, endorsed by, or
310
+ sponsored by KeyShot.
433
311
 
434
- **免安装,直接使用 npx**:
312
+ This project provides only an MCP integration. It does not include KeyShot
313
+ Studio, KeyShot assets, or a KeyShot license. Users must install and license
314
+ KeyShot Studio separately and comply with the applicable KeyShot terms. Do not
315
+ use this project to bypass licensing, share credentials, or redistribute KeyShot
316
+ software or proprietary resources.
435
317
 
436
- ```json
437
- {"mcpServers":{"keyshot":{"command":"npx","args":["-y","keyshot-mcp@0.6.0"],"env":{"KEYSHOT_HEADLESS_EXE":"C:/KeyShot/bin/keyshot_headless.exe"}}}}
438
- ```
318
+ ---
439
319
 
440
- **使用本地源码**(先运行 `npm install && npm run build`):
320
+ ## 中文
441
321
 
442
- ```json
443
- {"mcpServers":{"keyshot":{"command":"node","args":["C:/path/to/keyshot-mcp/dist/index.js"],"env":{"KEYSHOT_HEADLESS_EXE":"C:/KeyShot/bin/keyshot_headless.exe"}}}}
444
- ```
322
+ KeyShot MCP 是一个本地运行的
323
+ [Model Context Protocol](https://modelcontextprotocol.io/) 服务,通过 KeyShot
324
+ headless 脚本让兼容 MCP 的 AI Agent 检查、编辑和渲染 KeyShot 场景。场景、模型、
325
+ 许可证和渲染文件均保留在本机。
445
326
 
446
- ## 复制给 Agent 的安装提示词
327
+ ### 主要功能
447
328
 
448
- 如果你使用 Codex 或其他编程 Agent,可以复制下面这段话,让 Agent 帮你安装和配置 MCP:
329
+ - 检查场景对象、材质、相机、模型集和外部引用。
330
+ - 导入模型,并可选择自动居中、贴地、调整相机观察点和环境。
331
+ - 渲染单个相机、指定相机、场景中的全部相机或顺序渲染队列。
332
+ - 通过位置、观察点、距离、视野角、焦距或预设创建和更新相机。
333
+ - 直接应用材质,或使用本地材质预设库。
334
+ - 选择环境、调整亮度并旋转当前环境。
335
+ - 将修改后的场景保存到受控输出目录。
336
+ - 通过一次工具调用完成模型或现有场景的产品构图与渲染。
449
337
 
450
- ```text
451
- 请帮我安装 KeyShot MCP 0.6.0,并添加到我的 MCP 客户端。
338
+ ### 运行要求与兼容性
452
339
 
453
- 请你:
454
- 1. 查找我电脑上的 KeyShot headless 可执行文件路径。
455
- 2. 使用 npx -y keyshot-mcp@0.6.0 添加 keyshot MCP server
456
- 3. KEYSHOT_HEADLESS_EXE 设置为检测到的 keyshot_headless 路径。
457
- 4. keyshot_status 工具测试是否配置成功。
458
- 5. 最后告诉我实际添加的配置,以及状态检查是否通过。
340
+ - Node.js 20 或更高版本。
341
+ - 本机已安装并获得许可、且支持 headless 脚本的 KeyShot。
342
+ - 已实测:Windows 11、KeyShot Studio 2025 / KeyShot 14.1
343
+ - 其他 KeyShot 版本在提供相同官方脚本 API 时可能兼容,但本项目尚未完成实机验证。
344
+ - 本项目不包含 KeyShot 软件或许可证。
459
345
 
460
- 不要保存许可证密钥、账号密码或授权信息。直接使用我电脑上已有的 KeyShot 本地授权配置。
461
- ```
346
+ ### 安装
462
347
 
463
- ## 配置
348
+ 当前版本为 `0.8.0`。
464
349
 
465
- 需要告诉 MCP 服务 KeyShot 无界面程序在哪里。
350
+ #### 方式一:使用 npx
466
351
 
467
- Windows PowerShell 示例:
352
+ 无需全局安装 npm 包:
468
353
 
469
- ```powershell
470
- $env:KEYSHOT_HEADLESS_EXE="C:\Program Files\KeyShot Studio\bin\keyshot_headless.exe"
471
- ```
472
-
473
- macOS/Linux 示例:
474
-
475
- ```bash
476
- export KEYSHOT_HEADLESS_EXE="/Applications/KeyShot Studio.app/Contents/MacOS/keyshot_headless"
354
+ ```json
355
+ {
356
+ "mcpServers": {
357
+ "keyshot": {
358
+ "command": "npx",
359
+ "args": ["-y", "keyshot-mcp@0.8.0"],
360
+ "env": {
361
+ "KEYSHOT_HEADLESS_EXE": "C:/Program Files/KeyShot Studio/bin/keyshot_headless.exe"
362
+ }
363
+ }
364
+ }
365
+ }
477
366
  ```
478
367
 
479
- 然后测试能否启动:
368
+ #### 方式二:全局安装
480
369
 
481
370
  ```bash
482
- npm run status
371
+ npm install -g keyshot-mcp@0.8.0
483
372
  ```
484
373
 
485
- ## MCP 客户端配置示例
486
-
487
- 把类似下面的配置加到你的 MCP 客户端里:
488
-
489
374
  ```json
490
375
  {
491
376
  "mcpServers": {
492
377
  "keyshot": {
493
- "command": "node",
494
- "args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
378
+ "command": "keyshot-mcp",
495
379
  "env": {
496
- "KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
380
+ "KEYSHOT_HEADLESS_EXE": "C:/Program Files/KeyShot Studio/bin/keyshot_headless.exe"
497
381
  }
498
382
  }
499
383
  }
500
384
  }
501
385
  ```
502
386
 
503
- 通用 Codex 配置模板在:
387
+ #### 方式三:从源码运行
504
388
 
505
- ```text
506
- examples/codex.example.json
389
+ ```bash
390
+ git clone https://github.com/truman-t3/keyshot-mcp.git
391
+ cd keyshot-mcp
392
+ pnpm install
393
+ pnpm build
507
394
  ```
508
395
 
509
- ## Codex 配置
510
-
511
- 如果你使用 Codex,请在 Codex 的 MCP 配置里添加一个 `keyshot` 服务,并指向构建后的服务文件:
396
+ MCP 客户端配置为运行 `dist/index.js` 的绝对路径:
512
397
 
513
398
  ```json
514
399
  {
515
400
  "mcpServers": {
516
401
  "keyshot": {
517
402
  "command": "node",
518
- "args": ["/absolute/path/to/keyshot-mcp/dist/index.js"],
403
+ "args": ["C:/absolute/path/to/keyshot-mcp/dist/index.js"],
519
404
  "env": {
520
- "KEYSHOT_HEADLESS_EXE": "/absolute/path/to/keyshot_headless"
405
+ "KEYSHOT_HEADLESS_EXE": "C:/Program Files/KeyShot Studio/bin/keyshot_headless.exe"
521
406
  }
522
407
  }
523
408
  }
524
409
  }
525
410
  ```
526
411
 
527
- `examples/codex.example.json` 是通用配置模板。使用时请把里面的路径换成自己电脑上的路径。
412
+ 修改配置后请重启或重新加载 MCP 客户端。
528
413
 
529
- ## 提示词示例
414
+ ### 复制给 Agent 的安装提示词
530
415
 
531
- ```text
532
- 把当前 KeyShot 场景渲染成三个视角:正视图、45 度透视图和俯视图。分辨率为 1920x1080,并保存到默认输出文件夹。
533
- ```
416
+ 下面的提示词适用于有权限修改 MCP 客户端配置的编程 Agent:
534
417
 
535
418
  ```text
536
- 导入 /path/to/model.step,给主体外壳应用拉丝金属材质,设置 45 度相机,并渲染一张产品主视觉图。
537
- ```
419
+ 请帮我安装 KeyShot MCP 0.8.0,并添加到我的 MCP 客户端。
420
+
421
+ 1. 查找本机 KeyShot headless 可执行文件。
422
+ 2. 添加名为 keyshot 的 MCP server,运行:
423
+ npx -y keyshot-mcp@0.8.0
424
+ 3. 将 KEYSHOT_HEADLESS_EXE 设置为可执行文件路径。
425
+ 4. 保持 KEYSHOT_ALLOW_EXTERNAL_OUTPUTS 关闭。
426
+ 5. 重启或重新加载 MCP 客户端,调用 keyshot_status,然后使用 keyshot_product_render 一键完成产品出图。
427
+ 6. 不要上传或发布任何 KeyShot 场景、模型、渲染图或许可证数据。
428
+ ```
429
+
430
+ ### 配置项
431
+
432
+ | 环境变量 | 默认值 | 用途 |
433
+ | --- | --- | --- |
434
+ | `KEYSHOT_HEADLESS_EXE` | Windows 上为 `keyshot_headless.exe` | KeyShot headless 绝对路径,或系统 `PATH` 中的命令。 |
435
+ | `KEYSHOT_OUTPUT_DIR` | 包内 `outputs` | 渲染图和已保存场景的根目录。 |
436
+ | `KEYSHOT_ALLOW_EXTERNAL_OUTPUTS` | `false` | 明确设为 `true` 时允许写入输出根目录之外。 |
437
+ | `KEYSHOT_TIMEOUT_MS` | `600000` | 单个 KeyShot headless 进程的超时时间。 |
438
+ | `KEYSHOT_LICENSE_ARGS` | 空 | 可选的 KeyShot 启动参数。 |
439
+ | `KEYSHOT_MATERIAL_PRESETS` | 内置 `presets/materials.json` | 自定义材质预设 JSON 路径。 |
440
+ | `KEYSHOT_CAMERA_PRESETS` | 内置 `presets/cameras.json` | 自定义相机预设 JSON 路径。 |
441
+
442
+ 相对输出路径会自动放入 `KEYSHOT_OUTPUT_DIR`。默认拒绝 `..`、相邻同名前缀目录和
443
+ 软链接逃逸。输入场景、模型、材质和环境文件可位于其他目录。
444
+
445
+ ### MCP 工具
446
+
447
+ | 工具 | 用途 |
448
+ | --- | --- |
449
+ | `keyshot_status` | 检查 KeyShot headless 是否可启动并读取版本。 |
450
+ | `keyshot_product_render` | 在一个 headless 进程中完成模型或场景准备、保存和渲染。 |
451
+ | `keyshot_inspect_scene` | 检查对象、相机、材质、模型集和外部引用。 |
452
+ | `keyshot_list_cameras` | 列出场景中的相机名称。 |
453
+ | `keyshot_render` | 渲染一张图片。 |
454
+ | `keyshot_render_queue` | 顺序执行多个独立渲染任务。 |
455
+ | `keyshot_batch_render` | 渲染用户指定的一组相机。 |
456
+ | `keyshot_render_all_cameras` | 自动发现并渲染场景中的全部相机。 |
457
+ | `keyshot_import_model` | 导入模型并可选择自动构图。 |
458
+ | `keyshot_apply_material` | 应用材质库名称或材质文件。 |
459
+ | `keyshot_list_material_presets` | 列出本地材质预设。 |
460
+ | `keyshot_apply_material_preset` | 应用指定材质预设。 |
461
+ | `keyshot_set_camera` | 创建或更新相机变换、距离、视野角或焦距。 |
462
+ | `keyshot_list_camera_presets` | 列出标准和自定义相机预设。 |
463
+ | `keyshot_apply_camera_preset` | 应用标准视角或绝对坐标相机预设。 |
464
+ | `keyshot_set_environment` | 选择环境并调整亮度或旋转角度。 |
465
+ | `keyshot_save_scene` | 将场景保存到新的输出路径。 |
466
+
467
+ 服务共提供 17 个工具,并提供 `keyshot_product_render` MCP 提示词和
468
+ `keyshot://workflow` 资源。
469
+
470
+ ### 一键产品出图
471
+
472
+ 设计师可以直接在支持 MCP 的 Agent 中描述需求:
538
473
 
539
474
  ```text
540
- 检查当前 KeyShot 场景,并总结场景中的对象、相机、材质和可渲染输出。
475
+ C:\models\speaker.obj 做成产品渲染图。自动居中、贴地,使用 Isometric
476
+ 相机预设,保存 KeyShot 场景,并用 128 采样渲染一张 1600 x 1200 PNG。
541
477
  ```
542
478
 
543
- ```text
544
- 列出当前 KeyShot 场景中的相机,创建或更新一个名为“Hero”的相机,
545
- 把场景保存为新文件,并用这个相机渲染一张预览图。
546
- ```
547
-
548
- ```text
549
- 自动找出这个 KeyShot 场景里的全部相机,把所有视角渲染到 all-cameras 文件夹。
550
- 某个相机失败时继续处理其他相机,最后告诉我每个视角的结果。
551
- ```
552
-
553
- ```text
554
- 列出可用的相机预设,把 Isometric 等距预设应用为名为“目录等距视图”的相机,
555
- 保存一份新场景,并用这个相机渲染预览图。
556
- ```
557
-
558
- ## 环境变量
559
-
560
- - `KEYSHOT_HEADLESS_EXE`:`keyshot_headless` 或 `keyshot_headless.exe` 的路径。
561
- - `KEYSHOT_OUTPUT_DIR`:默认渲染输出文件夹。
562
- - `KEYSHOT_LICENSE_ARGS`:可选的 KeyShot 无界面许可证参数,默认留空。
563
- - `KEYSHOT_TIMEOUT_MS`:单次操作超时时间,单位毫秒,默认 `600000`。
564
- - `KEYSHOT_MATERIAL_PRESETS`:材质预设库 JSON 文件路径,默认 `presets/materials.json`。
565
- - `KEYSHOT_ALLOW_EXTERNAL_OUTPUTS`:是否允许写到默认输出目录之外,默认 `false`。
566
- - `KEYSHOT_CAMERA_PRESETS`:相机预设 JSON 文件路径,默认 `presets/cameras.json`。
567
-
568
- 默认情况下,所有输出图片和场景都必须写入 `KEYSHOT_OUTPUT_DIR`,相对路径会自动放入该目录。
569
- 只有确实需要写到外部目录时才设置为 `true`;输入场景和模型路径不受此限制。
570
-
571
- `samples` 和 `maxTimeSeconds` 是两种不同的 KeyShot 渲染模式,请二选一,不要同时传入。
572
-
573
- ## MCP 工具
574
-
575
- - `keyshot_status`:检查 KeyShot 是否能启动。
576
- - `keyshot_inspect_scene`:检查场景内容。
577
- - `keyshot_list_cameras`:列出场景中所有相机名称(批量渲染前很有用)。
578
- - `keyshot_render`:渲染单张图片。
579
- - `keyshot_batch_render`:批量渲染多个相机视角。
580
- - `keyshot_render_all_cameras`:自动发现并渲染场景中的全部相机,默认单个视角失败后继续。
581
- - `keyshot_render_queue`:顺序执行多个渲染任务(默认遇错即停,设置 `continueOnError` 可继续)。
582
- - `keyshot_import_model`:导入模型。
583
- - `keyshot_apply_material`:替换材质。
584
- - `keyshot_list_material_presets`:列出材质预设库中的预设。
585
- - `keyshot_apply_material_preset`:把预设库中的某个命名材质应用到物体上。
586
- - `keyshot_set_camera`:设置相机。
587
- - `keyshot_list_camera_presets`:列出标准和自定义相机预设。
588
- - `keyshot_apply_camera_preset`:用预设创建或更新命名相机。
589
- - `keyshot_set_environment`:设置环境。
590
- - `keyshot_save_scene`:保存场景。
591
-
592
- ### 自动渲染全部相机
593
-
594
- `keyshot_render_all_cameras` 会在同一次 KeyShot 无界面运行中自动读取场景相机并逐个渲染。
595
- `continueOnError` 默认是 `true`,因此单个相机失败不会阻止其他视角;同名安全文件会自动添加
596
- `-2`、`-3` 等编号。除非设置 `overwrite: true`,否则不会覆盖已有图片。KeyShot 内部不能激活的
597
- `last_active` 占位项会被列出并跳过。
598
-
599
- ### 材质预设库
600
-
601
- `keyshot_apply_material_preset` 会读取一个小的 JSON 注册表,让你用"好记的名字"复用材质,
602
- 而不必记住 KeyShot 里精确的材质名。默认位置:`presets/materials.json`
603
- (可用环境变量 `KEYSHOT_MATERIAL_PRESETS` 覆盖)。
479
+ `keyshot_product_render` 可以接收 `modelPath` 或 `scenePath`。新模型默认自动居中、
480
+ 贴地并创建名为 `Product Hero` 的等轴测相机;已有场景默认保留当前相机、材质和环境,
481
+ 只有明确提供参数时才修改。
604
482
 
605
483
  ```json
606
484
  {
607
- "拉丝钢": { "materialName": "Steel Brushed", "description": "金属件默认材质" },
608
- "透明玻璃": { "materialPath": "C:/materials/glass_clear.mtl" }
485
+ "modelPath": "C:/models/speaker.obj",
486
+ "outputScenePath": "speaker-product.bip",
487
+ "outputPath": "speaker-product.png",
488
+ "materialAssignments": [
489
+ { "objectName": "Body", "presetName": "Brushed Steel" }
490
+ ],
491
+ "cameraPresetName": "Isometric",
492
+ "focalLength": 55,
493
+ "brightness": 1.2,
494
+ "rotation": 45,
495
+ "width": 1600,
496
+ "height": 1200,
497
+ "samples": 128
609
498
  }
610
499
  ```
611
500
 
612
- 每个预设必须包含 `materialName` `materialPath`。用 `keyshot_list_material_presets` 查看有哪些预设。
501
+ `renderMode` 设为 `allCameras` 并提供 `outputDir`,即可渲染场景中的全部命名相机。
502
+ 省略输出路径时会根据源文件名自动生成。默认不会覆盖已有文件,只有明确设置
503
+ `overwrite: true` 才会替换。材质指定必须包含明确的对象,不会隐式覆盖整个模型。
504
+
505
+ ### 产品构图示例
613
506
 
614
- ### 相机预设库
507
+ 导入模型并完成初始构图:
615
508
 
616
- 内置的 `presets/cameras.json` 包含 Front、Back、Left、Right、Top、Bottom 和
617
- Isometric 七个 KeyShot 标准视角。使用 `keyshot_list_camera_presets` 查看预设,
618
- 使用 `keyshot_apply_camera_preset` 创建或更新命名相机。
509
+ ```text
510
+ C:\models\speaker.obj 导入 KeyShot,自动居中、贴地、调整相机观察点和环境,
511
+ 然后保存为 speaker-prepared.bip。
512
+ ```
619
513
 
620
- `KEYSHOT_CAMERA_PRESETS` 指向用户自己的 JSON 文件即可添加自定义预设:
514
+ 对应的 `keyshot_import_model` 参数:
621
515
 
622
516
  ```json
623
517
  {
624
- "正视图": { "standardView": "front" },
625
- "产品主视角": {
626
- "position": [4.5, 3.5, 4.5],
627
- "lookAt": [0, 0, 0],
628
- "up": [0, 1, 0],
629
- "description": "自定义绝对坐标相机"
630
- }
518
+ "centerGeometry": true,
519
+ "snapToGround": true,
520
+ "adjustCameraLookAt": true,
521
+ "adjustEnvironment": true
631
522
  }
632
523
  ```
633
524
 
634
- 预设文件既可以使用上面的对象格式,也可以使用每项包含 `name` 的数组格式。
635
- 每个预设只能选择一种形式:填写一个受支持的 `standardView`,或者同时填写
636
- `position` 与 `lookAt`。MCP 只读取预设文件,不会自动修改它。
525
+ 设置产品相机:
637
526
 
638
- ## MCP 提示词和资源
527
+ ```text
528
+ 把 Product Hero 相机设为 55 mm 焦距、距离 6,保存新场景并渲染 PNG 预览图。
529
+ ```
639
530
 
640
- - 提示词:`keyshot_product_render`
641
- - 资源:`keyshot://workflow`
531
+ `fieldOfView` 必须大于 `0` 且小于 `180`;`focalLength` 支持 `5–200 mm`,
532
+ 两者不能同时使用。`position` `lookAt` 可不填写,但修改相机位置时必须成对提供。
642
533
 
643
- 每个工具都会返回 JSON,包含:
534
+ 旋转当前 HDRI 或环境:
644
535
 
645
- - `ok`:是否成功。
646
- - `data`:主要结果。
647
- - `outputFiles`:生成的文件。
648
- - `warnings`:警告信息。
649
- - `keyshotStdoutTail`:KeyShot 输出摘要。
650
- - `error`:错误信息。
536
+ ```text
537
+ 把当前 KeyShot 环境旋转到 45 度,保存场景,然后渲染全部相机。
538
+ ```
651
539
 
652
- ## 说明
540
+ `rotation` 支持大于等于 `0` 且小于 `360` 的数值。
653
541
 
654
- KeyShot Python `lux` API 会随版本变化。这个 MCP 会尽量保持对外工具名称稳定;如果当前 KeyShot 版本不支持某个无界面功能,会返回明确错误,而不是假装成功。
542
+ 渲染参数 `samples` `maxTimeSeconds` 对应不同的 KeyShot 渲染模式,不能同时使用。
655
543
 
656
- ## 路线图
544
+ ### 相机与材质预设
657
545
 
658
- - [x] 自动发现并批量渲染场景中的所有相机
659
- - [x] 材质预设库
660
- - [x] 相机预设模板
661
- - [x] 顺序渲染队列
662
- - [x] 更安全的输出目录限制
663
- - [ ] 测试更多 KeyShot 版本
664
- - [ ] 验证 macOS 兼容性
665
- - [x] 补充 Claude Desktop / Cursor / Codex 配置示例
546
+ 内置相机库包含 Front、Back、Left、Right、Top、Bottom 和 Isometric 七个标准视角。
547
+ 自定义 `KEYSHOT_CAMERA_PRESETS` JSON 可使用标准视角,也可提供绝对 `position`、
548
+ `lookAt` 和可选 `up` 向量。
666
549
 
667
- ## 真实 KeyShot Demo
550
+ 材质预设通过 JSON 引用 KeyShot 材质库名称或本地材质文件。MCP 只读取预设文件,
551
+ 不会自动修改它们。
668
552
 
669
- ![KeyShot MCP 自动生成的立方体 Demo](assets/demo/keyshot-mcp-demo.png)
553
+ ### 可复现的 KeyShot smoke test
670
554
 
671
- Demo 只使用 `examples/demo` 中项目自己生成的几何体,不包含客户模型或第三方素材。
672
- 设置好 `KEYSHOT_HEADLESS_EXE` 后可复现状态检查、导入、检查场景、创建两个相机、自动发现、保存和真实 PNG 渲染:
555
+ 仓库提供基于 `examples/demo` 生成立方体几何体的 smoke test,用于验证 KeyShot
556
+ 启动、导入构图、场景检查、相机预设、焦距、视野角、相机距离、环境旋转、场景保存、
557
+ 相机发现、模型一键出图、现有场景一键渲染全部相机和真实 PNG 输出:
673
558
 
674
559
  ```bash
675
560
  npm run smoke:keyshot
676
561
  ```
677
562
 
678
- ## 测试
563
+ 生成的 `.bip` 和测试渲染图只保留在配置的本地输出目录。仓库中包含一张代表性结果:
679
564
 
680
- 项目带了两套测试,不依赖真实的 KeyShot 也能跑:
565
+ ![KeyShot smoke test 渲染图](assets/demo/keyshot-mcp-demo.png)
681
566
 
682
- - **TypeScript 测试(Vitest)**:覆盖配置读取、参数校验(schemas)、结果封装,以及用"假 KeyShot"跑通一次成功路径并验证 `work/tmp` 临时文件会被清理。
567
+ ### 开发与测试
683
568
 
684
- ```bash
685
- npm install
686
- npm test
687
- ```
569
+ ```bash
570
+ pnpm install
571
+ pnpm check
572
+ pnpm test
573
+ python -m unittest discover -s tests -p "test_*.py"
574
+ npm pack --dry-run
575
+ ```
688
576
 
689
- - **Python bridge 测试(unittest)**:用假的 `lux` 对象验证 `import_model` 会真正打开基础场景、`set_camera` 在拿不到相机对象时不会崩溃并回退到 `lux` API。
577
+ CI Windows Ubuntu 上使用 Node.js 20、24 运行。Linux CI 验证 MCP 服务、
578
+ 桥接逻辑和 npm 包,不代表 KeyShot 软件已在 Linux 上通过实机测试。
690
579
 
691
- ```bash
692
- python tests/test_bridge.py
693
- ```
580
+ ### 路线图
694
581
 
695
- ## 开源协议
582
+ - 在更多 KeyShot 正式版本上完成实机验证。
583
+ - 验证 macOS 安装和 headless 行为。
584
+ - 在 headless API 稳定支持后增加景深和更多镜头控制。
696
585
 
697
- MIT
586
+ ### 许可证与安全
698
587
 
699
- ## Star History / 星标趋势
588
+ 项目采用 [MIT License](LICENSE)。安全说明见 [SECURITY.md](SECURITY.md),开发说明
589
+ 见 [CONTRIBUTING.md](CONTRIBUTING.md)。请勿提交 KeyShot 许可证、私有场景、客户素材
590
+ 或未公开渲染图。
700
591
 
701
- ![Star History Chart](assets/star-history.svg)
592
+ ### 商标与项目性质
702
593
 
703
- This chart is generated from GitHub stargazer data and refreshed by GitHub Actions.
594
+ KeyShot KeyShot ApS 和/或 KeyShot Inc. 的商标。本项目是独立的开源社区项目,
595
+ 与 KeyShot 官方无隶属、认可、赞助或其他合作关系。
704
596
 
705
- 这张图由 GitHub star 数据生成,并通过 GitHub Actions 定时刷新。
597
+ 本项目仅提供 MCP 集成功能,不包含 KeyShot Studio、KeyShot 官方素材或 KeyShot
598
+ 许可证。用户必须自行安装并合法授权 KeyShot Studio,同时遵守适用的 KeyShot 条款。
599
+ 不得使用本项目绕过许可证、共享账号凭据,或重新分发 KeyShot 软件及其专有资源。