meshwire 0.5.0__py3-none-any.whl
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.
- mcp_blender/__init__.py +3 -0
- mcp_blender/blender_client.py +685 -0
- mcp_blender/py.typed +0 -0
- mcp_blender/server.py +6528 -0
- mcp_blender/tools/__init__.py +21 -0
- mcp_blender/tools/animation.py +75 -0
- mcp_blender/tools/export.py +80 -0
- mcp_blender/tools/external.py +553 -0
- mcp_blender/tools/materials.py +96 -0
- mcp_blender/tools/modifiers.py +66 -0
- mcp_blender/tools/objects.py +136 -0
- mcp_blender/tools/render.py +74 -0
- mcp_blender/tools/scene.py +56 -0
- mcp_blender/types.py +106 -0
- mcp_blender/wire.py +478 -0
- meshwire-0.5.0.dist-info/METADATA +476 -0
- meshwire-0.5.0.dist-info/RECORD +20 -0
- meshwire-0.5.0.dist-info/WHEEL +4 -0
- meshwire-0.5.0.dist-info/entry_points.txt +3 -0
- meshwire-0.5.0.dist-info/licenses/LICENSE +661 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"""External integration tools (Poly Haven, AI model generation)."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from mcp.server import Server
|
|
7
|
+
|
|
8
|
+
from ..blender_client import BlenderClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def register_external_tools(server: "Server", get_client: "callable") -> None:
|
|
12
|
+
"""Register external integration tools with the MCP server."""
|
|
13
|
+
|
|
14
|
+
# =========================================================================
|
|
15
|
+
# Poly Haven Tools
|
|
16
|
+
# =========================================================================
|
|
17
|
+
|
|
18
|
+
@server.call_tool()
|
|
19
|
+
async def blender_polyhaven_search(arguments: dict) -> list:
|
|
20
|
+
"""Search Poly Haven for HDRIs, textures, or models."""
|
|
21
|
+
client: BlenderClient = await get_client()
|
|
22
|
+
result = await client.send_command(
|
|
23
|
+
"polyhaven_search",
|
|
24
|
+
{
|
|
25
|
+
"query": arguments.get("query", ""),
|
|
26
|
+
"asset_type": arguments.get("asset_type"), # hdris, textures, models
|
|
27
|
+
"categories": arguments.get("categories"),
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
return [{"type": "text", "text": str(result)}]
|
|
31
|
+
|
|
32
|
+
@server.call_tool()
|
|
33
|
+
async def blender_polyhaven_download(arguments: dict) -> list:
|
|
34
|
+
"""Download and apply a Poly Haven asset."""
|
|
35
|
+
client: BlenderClient = await get_client()
|
|
36
|
+
result = await client.send_command(
|
|
37
|
+
"polyhaven_download",
|
|
38
|
+
{
|
|
39
|
+
"asset_id": arguments["asset_id"],
|
|
40
|
+
"resolution": arguments.get("resolution", "2k"),
|
|
41
|
+
"apply_to": arguments.get("apply_to"), # For textures: material name
|
|
42
|
+
},
|
|
43
|
+
)
|
|
44
|
+
return [{"type": "text", "text": str(result)}]
|
|
45
|
+
|
|
46
|
+
# =========================================================================
|
|
47
|
+
# AI Model Generation Tools
|
|
48
|
+
# =========================================================================
|
|
49
|
+
|
|
50
|
+
@server.call_tool()
|
|
51
|
+
async def blender_ai_generate_model(arguments: dict) -> list:
|
|
52
|
+
"""Generate a 3D model using AI (text-to-3D or image-to-3D).
|
|
53
|
+
|
|
54
|
+
Supports multiple backends including Rodin (cloud), Meshy (cloud),
|
|
55
|
+
TripoSR (local), and Hunyuan3D (local). Use blender_ai_list_backends
|
|
56
|
+
to see available backends.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
prompt: Text description of the desired 3D model
|
|
60
|
+
image_path: Optional path to input image for image-to-3D
|
|
61
|
+
style: Style modifier (realistic, cartoon, low_poly, sculpture, anime)
|
|
62
|
+
quality: Generation quality (draft, medium, high)
|
|
63
|
+
output_format: Output format (glb, gltf, fbx, obj)
|
|
64
|
+
backend: Specific backend to use (or omit for auto-selection)
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Job ID for tracking generation progress
|
|
68
|
+
"""
|
|
69
|
+
client: BlenderClient = await get_client()
|
|
70
|
+
result = await client.send_command(
|
|
71
|
+
"ai_generate_model",
|
|
72
|
+
{
|
|
73
|
+
"prompt": arguments.get("prompt", ""),
|
|
74
|
+
"image_path": arguments.get("image_path"),
|
|
75
|
+
"style": arguments.get("style"),
|
|
76
|
+
"quality": arguments.get("quality", "medium"),
|
|
77
|
+
"output_format": arguments.get("output_format", "glb"),
|
|
78
|
+
"backend": arguments.get("backend"),
|
|
79
|
+
},
|
|
80
|
+
)
|
|
81
|
+
return [{"type": "text", "text": str(result)}]
|
|
82
|
+
|
|
83
|
+
@server.call_tool()
|
|
84
|
+
async def blender_ai_model_status(arguments: dict) -> list:
|
|
85
|
+
"""Check the status of an AI model generation job.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
job_id: The job ID from blender_ai_generate_model
|
|
89
|
+
auto_import: If True, automatically import completed models (default: True)
|
|
90
|
+
backend: Optional backend hint for faster lookup
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Status, progress, and import info if completed
|
|
94
|
+
"""
|
|
95
|
+
client: BlenderClient = await get_client()
|
|
96
|
+
result = await client.send_command(
|
|
97
|
+
"ai_model_status",
|
|
98
|
+
{
|
|
99
|
+
"job_id": arguments["job_id"],
|
|
100
|
+
"auto_import": arguments.get("auto_import", True),
|
|
101
|
+
"backend": arguments.get("backend"),
|
|
102
|
+
},
|
|
103
|
+
)
|
|
104
|
+
return [{"type": "text", "text": str(result)}]
|
|
105
|
+
|
|
106
|
+
# =========================================================================
|
|
107
|
+
# AI Backend Management Tools
|
|
108
|
+
# =========================================================================
|
|
109
|
+
|
|
110
|
+
@server.call_tool()
|
|
111
|
+
async def blender_ai_list_backends(arguments: dict) -> list:
|
|
112
|
+
"""List all available AI generation backends.
|
|
113
|
+
|
|
114
|
+
Returns information about each backend including:
|
|
115
|
+
- Name and capabilities (text-to-3D, image-to-3D, local/cloud)
|
|
116
|
+
- Availability status
|
|
117
|
+
- Requirements (API key, local installation)
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
available_only: If True, only show backends ready to use (default: True)
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
List of backends with their capabilities and status
|
|
124
|
+
"""
|
|
125
|
+
client: BlenderClient = await get_client()
|
|
126
|
+
result = await client.send_command(
|
|
127
|
+
"ai_list_backends",
|
|
128
|
+
{"available_only": arguments.get("available_only", True)},
|
|
129
|
+
)
|
|
130
|
+
return [{"type": "text", "text": str(result)}]
|
|
131
|
+
|
|
132
|
+
@server.call_tool()
|
|
133
|
+
async def blender_ai_set_backend(arguments: dict) -> list:
|
|
134
|
+
"""Set the preferred AI backend for generation.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
backend: Backend name to use, or None/empty for auto-selection
|
|
138
|
+
prefer_local: If True, prefer local backends over cloud when auto-selecting
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
Confirmation with available backends list
|
|
142
|
+
"""
|
|
143
|
+
client: BlenderClient = await get_client()
|
|
144
|
+
result = await client.send_command(
|
|
145
|
+
"ai_set_backend",
|
|
146
|
+
{
|
|
147
|
+
"backend": arguments.get("backend"),
|
|
148
|
+
"prefer_local": arguments.get("prefer_local"),
|
|
149
|
+
},
|
|
150
|
+
)
|
|
151
|
+
return [{"type": "text", "text": str(result)}]
|
|
152
|
+
|
|
153
|
+
@server.call_tool()
|
|
154
|
+
async def blender_ai_get_backend_info(arguments: dict) -> list:
|
|
155
|
+
"""Get detailed information about a specific AI backend.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
backend: Name of the backend to query
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
Detailed info including capabilities, requirements, supported options
|
|
162
|
+
"""
|
|
163
|
+
client: BlenderClient = await get_client()
|
|
164
|
+
result = await client.send_command(
|
|
165
|
+
"ai_get_backend_info",
|
|
166
|
+
{"backend": arguments["backend"]},
|
|
167
|
+
)
|
|
168
|
+
return [{"type": "text", "text": str(result)}]
|
|
169
|
+
|
|
170
|
+
@server.call_tool()
|
|
171
|
+
async def blender_ai_configure_backend(arguments: dict) -> list:
|
|
172
|
+
"""Configure a specific AI backend.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
backend: Name of the backend to configure
|
|
176
|
+
config: Configuration dict. Allowed keys only:
|
|
177
|
+
- api_key: API key for cloud backends
|
|
178
|
+
- host: http or https URL of the backend server
|
|
179
|
+
- device: Device to use (auto, cuda, cpu, mps)
|
|
180
|
+
- timeout: Request timeout in seconds
|
|
181
|
+
- model: Ollama model name
|
|
182
|
+
- enabled: Whether backend is enabled
|
|
183
|
+
Paths and local model locations are set in Blender's Preferences.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
Confirmation of configuration
|
|
187
|
+
"""
|
|
188
|
+
client: BlenderClient = await get_client()
|
|
189
|
+
result = await client.send_command(
|
|
190
|
+
"ai_configure_backend",
|
|
191
|
+
{
|
|
192
|
+
"backend": arguments["backend"],
|
|
193
|
+
"config": arguments.get("config", {}),
|
|
194
|
+
},
|
|
195
|
+
)
|
|
196
|
+
return [{"type": "text", "text": str(result)}]
|
|
197
|
+
|
|
198
|
+
# =========================================================================
|
|
199
|
+
# AI Generation Enhancement Tools
|
|
200
|
+
# =========================================================================
|
|
201
|
+
|
|
202
|
+
@server.call_tool()
|
|
203
|
+
async def blender_ai_generate_variations(arguments: dict) -> list:
|
|
204
|
+
"""Generate multiple variations of a prompt.
|
|
205
|
+
|
|
206
|
+
Useful for exploring different interpretations of a concept.
|
|
207
|
+
|
|
208
|
+
Args:
|
|
209
|
+
prompt: Text description of the desired model
|
|
210
|
+
num_variations: Number of variations to generate (default: 3)
|
|
211
|
+
style: Style modifier
|
|
212
|
+
quality: Generation quality
|
|
213
|
+
output_format: Output format
|
|
214
|
+
backend: Specific backend to use
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
List of job IDs for each variation
|
|
218
|
+
"""
|
|
219
|
+
client: BlenderClient = await get_client()
|
|
220
|
+
result = await client.send_command(
|
|
221
|
+
"ai_generate_variations",
|
|
222
|
+
{
|
|
223
|
+
"prompt": arguments["prompt"],
|
|
224
|
+
"num_variations": arguments.get("num_variations", 3),
|
|
225
|
+
"style": arguments.get("style"),
|
|
226
|
+
"quality": arguments.get("quality", "medium"),
|
|
227
|
+
"output_format": arguments.get("output_format", "glb"),
|
|
228
|
+
"backend": arguments.get("backend"),
|
|
229
|
+
},
|
|
230
|
+
)
|
|
231
|
+
return [{"type": "text", "text": str(result)}]
|
|
232
|
+
|
|
233
|
+
@server.call_tool()
|
|
234
|
+
async def blender_ai_cancel_generation(arguments: dict) -> list:
|
|
235
|
+
"""Cancel an in-progress generation job.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
job_id: The job ID to cancel
|
|
239
|
+
backend: Optional backend hint
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
Cancellation status
|
|
243
|
+
"""
|
|
244
|
+
client: BlenderClient = await get_client()
|
|
245
|
+
result = await client.send_command(
|
|
246
|
+
"ai_cancel_generation",
|
|
247
|
+
{
|
|
248
|
+
"job_id": arguments["job_id"],
|
|
249
|
+
"backend": arguments.get("backend"),
|
|
250
|
+
},
|
|
251
|
+
)
|
|
252
|
+
return [{"type": "text", "text": str(result)}]
|
|
253
|
+
|
|
254
|
+
@server.call_tool()
|
|
255
|
+
async def blender_ai_redo_generation(arguments: dict) -> list:
|
|
256
|
+
"""Redo the last generation with optional modifications.
|
|
257
|
+
|
|
258
|
+
Args:
|
|
259
|
+
prompt: New prompt (optional, uses last prompt if not provided)
|
|
260
|
+
style: New style (optional)
|
|
261
|
+
quality: New quality (optional)
|
|
262
|
+
output_format: New format (optional)
|
|
263
|
+
backend: Specific backend (optional)
|
|
264
|
+
|
|
265
|
+
Returns:
|
|
266
|
+
New job ID for the regeneration
|
|
267
|
+
"""
|
|
268
|
+
client: BlenderClient = await get_client()
|
|
269
|
+
result = await client.send_command(
|
|
270
|
+
"ai_redo_generation",
|
|
271
|
+
{
|
|
272
|
+
"prompt": arguments.get("prompt"),
|
|
273
|
+
"style": arguments.get("style"),
|
|
274
|
+
"quality": arguments.get("quality"),
|
|
275
|
+
"output_format": arguments.get("output_format"),
|
|
276
|
+
"backend": arguments.get("backend"),
|
|
277
|
+
},
|
|
278
|
+
)
|
|
279
|
+
return [{"type": "text", "text": str(result)}]
|
|
280
|
+
|
|
281
|
+
# =========================================================================
|
|
282
|
+
# Mesh Processing Tools
|
|
283
|
+
# =========================================================================
|
|
284
|
+
|
|
285
|
+
@server.call_tool()
|
|
286
|
+
async def blender_ai_mesh_cleanup(arguments: dict) -> list:
|
|
287
|
+
"""Clean up a generated mesh by removing doubles, fixing normals, etc.
|
|
288
|
+
|
|
289
|
+
Args:
|
|
290
|
+
object_name: Name of the mesh object to clean
|
|
291
|
+
remove_doubles: Remove duplicate vertices (default: True)
|
|
292
|
+
merge_distance: Distance threshold for merging (default: 0.0001)
|
|
293
|
+
fix_normals: Recalculate normals to face outward (default: True)
|
|
294
|
+
remove_loose: Remove loose vertices/edges (default: True)
|
|
295
|
+
remove_degenerate: Remove degenerate geometry (default: True)
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
Cleanup statistics (vertices removed, etc.)
|
|
299
|
+
"""
|
|
300
|
+
client: BlenderClient = await get_client()
|
|
301
|
+
result = await client.send_command(
|
|
302
|
+
"ai_mesh_cleanup",
|
|
303
|
+
{
|
|
304
|
+
"object_name": arguments["object_name"],
|
|
305
|
+
"remove_doubles": arguments.get("remove_doubles", True),
|
|
306
|
+
"merge_distance": arguments.get("merge_distance", 0.0001),
|
|
307
|
+
"fix_normals": arguments.get("fix_normals", True),
|
|
308
|
+
"remove_loose": arguments.get("remove_loose", True),
|
|
309
|
+
"remove_degenerate": arguments.get("remove_degenerate", True),
|
|
310
|
+
},
|
|
311
|
+
)
|
|
312
|
+
return [{"type": "text", "text": str(result)}]
|
|
313
|
+
|
|
314
|
+
@server.call_tool()
|
|
315
|
+
async def blender_ai_mesh_decimate(arguments: dict) -> list:
|
|
316
|
+
"""Reduce polygon count of a mesh intelligently.
|
|
317
|
+
|
|
318
|
+
Args:
|
|
319
|
+
object_name: Name of the mesh object
|
|
320
|
+
ratio: Target ratio of faces to keep (0.0-1.0, default: 0.5)
|
|
321
|
+
method: Decimation method (COLLAPSE, UNSUBDIV, DISSOLVE)
|
|
322
|
+
triangulate: Triangulate before decimating (default: False)
|
|
323
|
+
preserve_uvs: Try to preserve UV seams (default: True)
|
|
324
|
+
vertex_group: Optional vertex group to influence decimation
|
|
325
|
+
invert_vertex_group: Invert vertex group influence
|
|
326
|
+
|
|
327
|
+
Returns:
|
|
328
|
+
Decimation statistics (before/after face counts)
|
|
329
|
+
"""
|
|
330
|
+
client: BlenderClient = await get_client()
|
|
331
|
+
result = await client.send_command(
|
|
332
|
+
"ai_mesh_decimate",
|
|
333
|
+
{
|
|
334
|
+
"object_name": arguments["object_name"],
|
|
335
|
+
"ratio": arguments.get("ratio", 0.5),
|
|
336
|
+
"method": arguments.get("method", "COLLAPSE"),
|
|
337
|
+
"triangulate": arguments.get("triangulate", False),
|
|
338
|
+
"preserve_uvs": arguments.get("preserve_uvs", True),
|
|
339
|
+
"vertex_group": arguments.get("vertex_group"),
|
|
340
|
+
"invert_vertex_group": arguments.get("invert_vertex_group", False),
|
|
341
|
+
},
|
|
342
|
+
)
|
|
343
|
+
return [{"type": "text", "text": str(result)}]
|
|
344
|
+
|
|
345
|
+
@server.call_tool()
|
|
346
|
+
async def blender_ai_mesh_remesh(arguments: dict) -> list:
|
|
347
|
+
"""Retopologize a mesh for better geometry flow.
|
|
348
|
+
|
|
349
|
+
Args:
|
|
350
|
+
object_name: Name of the mesh object
|
|
351
|
+
method: Remesh method (VOXEL, QUAD, SHARP, SMOOTH, BLOCKS)
|
|
352
|
+
voxel_size: Voxel size for VOXEL method (default: 0.05)
|
|
353
|
+
octree_depth: Octree depth for other methods (default: 5)
|
|
354
|
+
smooth_normals: Smooth normals after remeshing (default: True)
|
|
355
|
+
apply_smooth: Apply smoothing pass (default: True)
|
|
356
|
+
smooth_factor: Smoothing factor (default: 0.5)
|
|
357
|
+
smooth_iterations: Smoothing iterations (default: 2)
|
|
358
|
+
|
|
359
|
+
Returns:
|
|
360
|
+
Remesh statistics
|
|
361
|
+
"""
|
|
362
|
+
client: BlenderClient = await get_client()
|
|
363
|
+
result = await client.send_command(
|
|
364
|
+
"ai_mesh_remesh",
|
|
365
|
+
{
|
|
366
|
+
"object_name": arguments["object_name"],
|
|
367
|
+
"method": arguments.get("method", "VOXEL"),
|
|
368
|
+
"voxel_size": arguments.get("voxel_size", 0.05),
|
|
369
|
+
"octree_depth": arguments.get("octree_depth", 5),
|
|
370
|
+
"smooth_normals": arguments.get("smooth_normals", True),
|
|
371
|
+
"apply_smooth": arguments.get("apply_smooth", True),
|
|
372
|
+
"smooth_factor": arguments.get("smooth_factor", 0.5),
|
|
373
|
+
"smooth_iterations": arguments.get("smooth_iterations", 2),
|
|
374
|
+
},
|
|
375
|
+
)
|
|
376
|
+
return [{"type": "text", "text": str(result)}]
|
|
377
|
+
|
|
378
|
+
@server.call_tool()
|
|
379
|
+
async def blender_ai_mesh_optimize(arguments: dict) -> list:
|
|
380
|
+
"""Run full optimization pipeline on a mesh.
|
|
381
|
+
|
|
382
|
+
Combines cleanup, decimation, UV unwrapping, and normal smoothing.
|
|
383
|
+
|
|
384
|
+
Args:
|
|
385
|
+
object_name: Name of the mesh object
|
|
386
|
+
cleanup: Run cleanup pass (default: True)
|
|
387
|
+
decimate: Run decimation (default: True)
|
|
388
|
+
decimate_ratio: Target face ratio for decimation (default: 0.5)
|
|
389
|
+
auto_uv: Generate UVs (default: True)
|
|
390
|
+
smooth_normals: Smooth shade the result (default: True)
|
|
391
|
+
|
|
392
|
+
Returns:
|
|
393
|
+
Full optimization results for each step
|
|
394
|
+
"""
|
|
395
|
+
client: BlenderClient = await get_client()
|
|
396
|
+
result = await client.send_command(
|
|
397
|
+
"ai_mesh_optimize",
|
|
398
|
+
{
|
|
399
|
+
"object_name": arguments["object_name"],
|
|
400
|
+
"cleanup": arguments.get("cleanup", True),
|
|
401
|
+
"decimate": arguments.get("decimate", True),
|
|
402
|
+
"decimate_ratio": arguments.get("decimate_ratio", 0.5),
|
|
403
|
+
"auto_uv": arguments.get("auto_uv", True),
|
|
404
|
+
"smooth_normals": arguments.get("smooth_normals", True),
|
|
405
|
+
},
|
|
406
|
+
)
|
|
407
|
+
return [{"type": "text", "text": str(result)}]
|
|
408
|
+
|
|
409
|
+
@server.call_tool()
|
|
410
|
+
async def blender_ai_auto_uv(arguments: dict) -> list:
|
|
411
|
+
"""Generate UV maps for a mesh.
|
|
412
|
+
|
|
413
|
+
Args:
|
|
414
|
+
object_name: Name of the mesh object
|
|
415
|
+
method: UV projection method (SMART, LIGHTMAP, CUBE, CYLINDER, SPHERE)
|
|
416
|
+
angle_limit: Angle limit for smart project in degrees (default: 66)
|
|
417
|
+
island_margin: Margin between UV islands (default: 0.02)
|
|
418
|
+
area_weight: Area weight for smart project (default: 0.0)
|
|
419
|
+
correct_aspect: Correct for non-square textures (default: True)
|
|
420
|
+
scale_to_bounds: Scale UVs to fit 0-1 space (default: True)
|
|
421
|
+
uv_layer_name: Name for the new UV layer (optional)
|
|
422
|
+
|
|
423
|
+
Returns:
|
|
424
|
+
UV generation results including layer name
|
|
425
|
+
"""
|
|
426
|
+
client: BlenderClient = await get_client()
|
|
427
|
+
result = await client.send_command(
|
|
428
|
+
"ai_auto_uv",
|
|
429
|
+
{
|
|
430
|
+
"object_name": arguments["object_name"],
|
|
431
|
+
"method": arguments.get("method", "SMART"),
|
|
432
|
+
"angle_limit": arguments.get("angle_limit", 66.0),
|
|
433
|
+
"island_margin": arguments.get("island_margin", 0.02),
|
|
434
|
+
"area_weight": arguments.get("area_weight", 0.0),
|
|
435
|
+
"correct_aspect": arguments.get("correct_aspect", True),
|
|
436
|
+
"scale_to_bounds": arguments.get("scale_to_bounds", True),
|
|
437
|
+
"uv_layer_name": arguments.get("uv_layer_name"),
|
|
438
|
+
},
|
|
439
|
+
)
|
|
440
|
+
return [{"type": "text", "text": str(result)}]
|
|
441
|
+
|
|
442
|
+
@server.call_tool()
|
|
443
|
+
async def blender_ai_fix_mesh_issues(arguments: dict) -> list:
|
|
444
|
+
"""Fix common mesh problems automatically.
|
|
445
|
+
|
|
446
|
+
Args:
|
|
447
|
+
object_name: Name of the mesh object
|
|
448
|
+
fix_non_manifold: Fix non-manifold geometry (default: True)
|
|
449
|
+
fill_holes: Fill small holes (default: True)
|
|
450
|
+
max_hole_edges: Maximum edges in holes to fill (default: 12)
|
|
451
|
+
fix_normals: Recalculate normals (default: True)
|
|
452
|
+
remove_interior_faces: Remove hidden interior faces (default: True)
|
|
453
|
+
|
|
454
|
+
Returns:
|
|
455
|
+
List of fixes applied
|
|
456
|
+
"""
|
|
457
|
+
client: BlenderClient = await get_client()
|
|
458
|
+
result = await client.send_command(
|
|
459
|
+
"ai_fix_mesh_issues",
|
|
460
|
+
{
|
|
461
|
+
"object_name": arguments["object_name"],
|
|
462
|
+
"fix_non_manifold": arguments.get("fix_non_manifold", True),
|
|
463
|
+
"fill_holes": arguments.get("fill_holes", True),
|
|
464
|
+
"max_hole_edges": arguments.get("max_hole_edges", 12),
|
|
465
|
+
"fix_normals": arguments.get("fix_normals", True),
|
|
466
|
+
"remove_interior_faces": arguments.get("remove_interior_faces", True),
|
|
467
|
+
},
|
|
468
|
+
)
|
|
469
|
+
return [{"type": "text", "text": str(result)}]
|
|
470
|
+
|
|
471
|
+
@server.call_tool()
|
|
472
|
+
async def blender_ai_mesh_stats(arguments: dict) -> list:
|
|
473
|
+
"""Get detailed statistics about a mesh.
|
|
474
|
+
|
|
475
|
+
Args:
|
|
476
|
+
object_name: Name of the mesh object
|
|
477
|
+
|
|
478
|
+
Returns:
|
|
479
|
+
Mesh statistics including vertex/face counts, UV info, materials, issues
|
|
480
|
+
"""
|
|
481
|
+
client: BlenderClient = await get_client()
|
|
482
|
+
result = await client.send_command(
|
|
483
|
+
"ai_mesh_stats",
|
|
484
|
+
{"object_name": arguments["object_name"]},
|
|
485
|
+
)
|
|
486
|
+
return [{"type": "text", "text": str(result)}]
|
|
487
|
+
|
|
488
|
+
# =========================================================================
|
|
489
|
+
# Queue Management Tools
|
|
490
|
+
# =========================================================================
|
|
491
|
+
|
|
492
|
+
@server.call_tool()
|
|
493
|
+
async def blender_ai_queue_list(arguments: dict) -> list:
|
|
494
|
+
"""List all generation jobs in the queue.
|
|
495
|
+
|
|
496
|
+
Args:
|
|
497
|
+
status: Filter by status (pending, processing, completed, failed)
|
|
498
|
+
backend: Filter by backend name
|
|
499
|
+
limit: Maximum number of jobs to return
|
|
500
|
+
include_completed: Include completed jobs (default: True)
|
|
501
|
+
|
|
502
|
+
Returns:
|
|
503
|
+
List of jobs with their status and details
|
|
504
|
+
"""
|
|
505
|
+
client: BlenderClient = await get_client()
|
|
506
|
+
result = await client.send_command(
|
|
507
|
+
"ai_queue_list",
|
|
508
|
+
{
|
|
509
|
+
"status": arguments.get("status"),
|
|
510
|
+
"backend": arguments.get("backend"),
|
|
511
|
+
"limit": arguments.get("limit"),
|
|
512
|
+
"include_completed": arguments.get("include_completed", True),
|
|
513
|
+
},
|
|
514
|
+
)
|
|
515
|
+
return [{"type": "text", "text": str(result)}]
|
|
516
|
+
|
|
517
|
+
@server.call_tool()
|
|
518
|
+
async def blender_ai_queue_clear(arguments: dict) -> list:
|
|
519
|
+
"""Clear completed or failed jobs from the queue.
|
|
520
|
+
|
|
521
|
+
Args:
|
|
522
|
+
older_than_hours: Only clear jobs older than this (optional)
|
|
523
|
+
clear_failed: If True, clear only failed jobs (default: False)
|
|
524
|
+
|
|
525
|
+
Returns:
|
|
526
|
+
Number of jobs cleared
|
|
527
|
+
"""
|
|
528
|
+
client: BlenderClient = await get_client()
|
|
529
|
+
result = await client.send_command(
|
|
530
|
+
"ai_queue_clear",
|
|
531
|
+
{
|
|
532
|
+
"older_than_hours": arguments.get("older_than_hours"),
|
|
533
|
+
"clear_failed": arguments.get("clear_failed", False),
|
|
534
|
+
},
|
|
535
|
+
)
|
|
536
|
+
return [{"type": "text", "text": str(result)}]
|
|
537
|
+
|
|
538
|
+
@server.call_tool()
|
|
539
|
+
async def blender_ai_get_history(arguments: dict) -> list:
|
|
540
|
+
"""Get generation history with metadata.
|
|
541
|
+
|
|
542
|
+
Args:
|
|
543
|
+
limit: Maximum number of entries to return (default: 50)
|
|
544
|
+
|
|
545
|
+
Returns:
|
|
546
|
+
History entries with prompts, status, and result info
|
|
547
|
+
"""
|
|
548
|
+
client: BlenderClient = await get_client()
|
|
549
|
+
result = await client.send_command(
|
|
550
|
+
"ai_get_history",
|
|
551
|
+
{"limit": arguments.get("limit", 50)},
|
|
552
|
+
)
|
|
553
|
+
return [{"type": "text", "text": str(result)}]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Material and shader tools."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from mcp.server import Server
|
|
7
|
+
|
|
8
|
+
from ..blender_client import BlenderClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def register_material_tools(server: "Server", get_client: "callable") -> None:
|
|
12
|
+
"""Register material tools with the MCP server."""
|
|
13
|
+
|
|
14
|
+
@server.call_tool()
|
|
15
|
+
async def blender_material_create(arguments: dict) -> list:
|
|
16
|
+
"""Create a new material."""
|
|
17
|
+
client: BlenderClient = await get_client()
|
|
18
|
+
result = await client.send_command(
|
|
19
|
+
"material_create",
|
|
20
|
+
{
|
|
21
|
+
"name": arguments.get("name", "Material"),
|
|
22
|
+
"use_nodes": arguments.get("use_nodes", True),
|
|
23
|
+
},
|
|
24
|
+
)
|
|
25
|
+
return [{"type": "text", "text": str(result)}]
|
|
26
|
+
|
|
27
|
+
@server.call_tool()
|
|
28
|
+
async def blender_material_assign(arguments: dict) -> list:
|
|
29
|
+
"""Assign a material to an object."""
|
|
30
|
+
client: BlenderClient = await get_client()
|
|
31
|
+
result = await client.send_command(
|
|
32
|
+
"material_assign",
|
|
33
|
+
{
|
|
34
|
+
"object_name": arguments["object_name"],
|
|
35
|
+
"material_name": arguments["material_name"],
|
|
36
|
+
"slot_index": arguments.get("slot_index"),
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
return [{"type": "text", "text": str(result)}]
|
|
40
|
+
|
|
41
|
+
@server.call_tool()
|
|
42
|
+
async def blender_material_set_color(arguments: dict) -> list:
|
|
43
|
+
"""Set the base color of a material (RGBA, values 0-1)."""
|
|
44
|
+
client: BlenderClient = await get_client()
|
|
45
|
+
result = await client.send_command(
|
|
46
|
+
"material_set_color",
|
|
47
|
+
{
|
|
48
|
+
"material_name": arguments["material_name"],
|
|
49
|
+
"color": arguments["color"], # [r, g, b, a]
|
|
50
|
+
},
|
|
51
|
+
)
|
|
52
|
+
return [{"type": "text", "text": str(result)}]
|
|
53
|
+
|
|
54
|
+
@server.call_tool()
|
|
55
|
+
async def blender_material_set_principled(arguments: dict) -> list:
|
|
56
|
+
"""Configure Principled BSDF parameters (metallic, roughness, etc.)."""
|
|
57
|
+
client: BlenderClient = await get_client()
|
|
58
|
+
params = {"material_name": arguments["material_name"]}
|
|
59
|
+
for key in [
|
|
60
|
+
"base_color",
|
|
61
|
+
"metallic",
|
|
62
|
+
"roughness",
|
|
63
|
+
"specular_ior_level",
|
|
64
|
+
"specular_tint",
|
|
65
|
+
"anisotropic",
|
|
66
|
+
"sheen_weight",
|
|
67
|
+
"coat_weight",
|
|
68
|
+
"emission_color",
|
|
69
|
+
"emission_strength",
|
|
70
|
+
"alpha",
|
|
71
|
+
]:
|
|
72
|
+
if key in arguments:
|
|
73
|
+
params[key] = arguments[key]
|
|
74
|
+
result = await client.send_command("material_set_principled", params)
|
|
75
|
+
return [{"type": "text", "text": str(result)}]
|
|
76
|
+
|
|
77
|
+
@server.call_tool()
|
|
78
|
+
async def blender_material_add_texture(arguments: dict) -> list:
|
|
79
|
+
"""Add an image texture node to a material."""
|
|
80
|
+
client: BlenderClient = await get_client()
|
|
81
|
+
result = await client.send_command(
|
|
82
|
+
"material_add_texture",
|
|
83
|
+
{
|
|
84
|
+
"material_name": arguments["material_name"],
|
|
85
|
+
"image_path": arguments["image_path"],
|
|
86
|
+
"connect_to": arguments.get("connect_to", "Base Color"),
|
|
87
|
+
},
|
|
88
|
+
)
|
|
89
|
+
return [{"type": "text", "text": str(result)}]
|
|
90
|
+
|
|
91
|
+
@server.call_tool()
|
|
92
|
+
async def blender_material_list(arguments: dict) -> list:
|
|
93
|
+
"""List all materials in the file."""
|
|
94
|
+
client: BlenderClient = await get_client()
|
|
95
|
+
result = await client.send_command("material_list", {})
|
|
96
|
+
return [{"type": "text", "text": str(result)}]
|