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.
@@ -0,0 +1,21 @@
1
+ """Tool modules for MCP Blender server."""
2
+
3
+ from .animation import register_animation_tools
4
+ from .export import register_export_tools
5
+ from .external import register_external_tools
6
+ from .materials import register_material_tools
7
+ from .modifiers import register_modifier_tools
8
+ from .objects import register_object_tools
9
+ from .render import register_render_tools
10
+ from .scene import register_scene_tools
11
+
12
+ __all__ = [
13
+ "register_scene_tools",
14
+ "register_object_tools",
15
+ "register_material_tools",
16
+ "register_modifier_tools",
17
+ "register_animation_tools",
18
+ "register_render_tools",
19
+ "register_export_tools",
20
+ "register_external_tools",
21
+ ]
@@ -0,0 +1,75 @@
1
+ """Animation and keyframe 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_animation_tools(server: "Server", get_client: "callable") -> None:
12
+ """Register animation tools with the MCP server."""
13
+
14
+ @server.call_tool()
15
+ async def blender_keyframe_insert(arguments: dict) -> list:
16
+ """Insert a keyframe for an object property."""
17
+ client: BlenderClient = await get_client()
18
+ result = await client.send_command(
19
+ "keyframe_insert",
20
+ {
21
+ "object_name": arguments["object_name"],
22
+ "data_path": arguments["data_path"], # e.g., "location", "rotation_euler"
23
+ "frame": arguments.get("frame"), # None = current frame
24
+ "index": arguments.get("index", -1), # -1 = all, 0/1/2 = specific axis
25
+ },
26
+ )
27
+ return [{"type": "text", "text": str(result)}]
28
+
29
+ @server.call_tool()
30
+ async def blender_keyframe_delete(arguments: dict) -> list:
31
+ """Delete a keyframe from an object property."""
32
+ client: BlenderClient = await get_client()
33
+ result = await client.send_command(
34
+ "keyframe_delete",
35
+ {
36
+ "object_name": arguments["object_name"],
37
+ "data_path": arguments["data_path"],
38
+ "frame": arguments.get("frame"),
39
+ "index": arguments.get("index", -1),
40
+ },
41
+ )
42
+ return [{"type": "text", "text": str(result)}]
43
+
44
+ @server.call_tool()
45
+ async def blender_action_create(arguments: dict) -> list:
46
+ """Create a new action (animation data container)."""
47
+ client: BlenderClient = await get_client()
48
+ result = await client.send_command(
49
+ "action_create",
50
+ {
51
+ "name": arguments.get("name", "Action"),
52
+ "object_name": arguments.get("object_name"), # Assign to object if provided
53
+ },
54
+ )
55
+ return [{"type": "text", "text": str(result)}]
56
+
57
+ @server.call_tool()
58
+ async def blender_animation_play(arguments: dict) -> list:
59
+ """Play or pause the animation."""
60
+ client: BlenderClient = await get_client()
61
+ result = await client.send_command(
62
+ "animation_play",
63
+ {"play": arguments.get("play", True)},
64
+ )
65
+ return [{"type": "text", "text": str(result)}]
66
+
67
+ @server.call_tool()
68
+ async def blender_animation_goto_frame(arguments: dict) -> list:
69
+ """Jump to a specific frame."""
70
+ client: BlenderClient = await get_client()
71
+ result = await client.send_command(
72
+ "animation_goto_frame",
73
+ {"frame": arguments["frame"]},
74
+ )
75
+ return [{"type": "text", "text": str(result)}]
@@ -0,0 +1,80 @@
1
+ """Import/export 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_export_tools(server: "Server", get_client: "callable") -> None:
12
+ """Register export/import tools with the MCP server."""
13
+
14
+ @server.call_tool()
15
+ async def blender_export_gltf(arguments: dict) -> list:
16
+ """Export scene or selected objects to glTF/GLB format."""
17
+ client: BlenderClient = await get_client()
18
+ result = await client.send_command(
19
+ "export_gltf",
20
+ {
21
+ "filepath": arguments["filepath"],
22
+ "export_format": arguments.get("export_format", "GLB"),
23
+ "selected_only": arguments.get("selected_only", False),
24
+ "export_animations": arguments.get("export_animations", True),
25
+ "export_materials": arguments.get("export_materials", True),
26
+ },
27
+ )
28
+ return [{"type": "text", "text": str(result)}]
29
+
30
+ @server.call_tool()
31
+ async def blender_export_fbx(arguments: dict) -> list:
32
+ """Export scene or selected objects to FBX format."""
33
+ client: BlenderClient = await get_client()
34
+ result = await client.send_command(
35
+ "export_fbx",
36
+ {
37
+ "filepath": arguments["filepath"],
38
+ "selected_only": arguments.get("selected_only", False),
39
+ "apply_modifiers": arguments.get("apply_modifiers", True),
40
+ },
41
+ )
42
+ return [{"type": "text", "text": str(result)}]
43
+
44
+ @server.call_tool()
45
+ async def blender_export_obj(arguments: dict) -> list:
46
+ """Export scene or selected objects to OBJ format."""
47
+ client: BlenderClient = await get_client()
48
+ result = await client.send_command(
49
+ "export_obj",
50
+ {
51
+ "filepath": arguments["filepath"],
52
+ "selected_only": arguments.get("selected_only", False),
53
+ "apply_modifiers": arguments.get("apply_modifiers", True),
54
+ },
55
+ )
56
+ return [{"type": "text", "text": str(result)}]
57
+
58
+ @server.call_tool()
59
+ async def blender_export_stl(arguments: dict) -> list:
60
+ """Export scene or selected objects to STL format."""
61
+ client: BlenderClient = await get_client()
62
+ result = await client.send_command(
63
+ "export_stl",
64
+ {
65
+ "filepath": arguments["filepath"],
66
+ "selected_only": arguments.get("selected_only", False),
67
+ "apply_modifiers": arguments.get("apply_modifiers", True),
68
+ },
69
+ )
70
+ return [{"type": "text", "text": str(result)}]
71
+
72
+ @server.call_tool()
73
+ async def blender_import_file(arguments: dict) -> list:
74
+ """Import a file (auto-detects format by extension)."""
75
+ client: BlenderClient = await get_client()
76
+ result = await client.send_command(
77
+ "import_file",
78
+ {"filepath": arguments["filepath"]},
79
+ )
80
+ return [{"type": "text", "text": str(result)}]