iflow-mcp_cwahlfeldt_blender-mcp 0.1.0__py3-none-any.whl → 0.1.2__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.
- {iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.dist-info → iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info}/METADATA +1 -1
- {iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.dist-info → iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info}/RECORD +5 -4
- server.py +87 -0
- {iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.dist-info → iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info}/WHEEL +0 -0
- {iflow_mcp_cwahlfeldt_blender_mcp-0.1.0.dist-info → iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info}/entry_points.txt +0 -0
|
@@ -3,11 +3,12 @@ blender/executor.py,sha256=UbrmYIXjNloWEkUMtsgOoeVqvrtnLtztcbWtvUxD9tU,5464
|
|
|
3
3
|
blender/uv_tools.py,sha256=anfOL3hW1fZdPTi1LDA2nMC123hCx95rvQfKer_nBrY,11658
|
|
4
4
|
scripts/__init__.py,sha256=x78bZpSWEjokJ24WqB-bvGAx3PnvixRCZ4xzWgmORBo,32
|
|
5
5
|
scripts/manager.py,sha256=06f5O8rCex-jDBMdxuEHEaq5SHFwPojOYnrIPBItVT0,6122
|
|
6
|
+
server.py,sha256=xRUhK_CfF5ad0Oy0guZOnHLAKe-C0NSthzXCcmNv-kc,2667
|
|
6
7
|
utils/__init__.py,sha256=XkLKwxjypuJhs2A-RPst7CZ1G_tWfvdHwFFFtZTjAQI,30
|
|
7
8
|
utils/helpers.py,sha256=EZkvfxRBFdr5Jm8Niwzikqv5QmR3WkIE2_MFvusRNqk,5452
|
|
8
9
|
utils/uv_integration.py,sha256=FQuhOTPPRxeUPZWYwGwLEQbkj10gKx-sg0ushKfRPt4,8630
|
|
9
10
|
utils/uv_manager.py,sha256=OCj8r3g6SPj-jHh-zti6H6EKubRkF8OLiCBAlzuARuY,1964
|
|
10
|
-
iflow_mcp_cwahlfeldt_blender_mcp-0.1.
|
|
11
|
-
iflow_mcp_cwahlfeldt_blender_mcp-0.1.
|
|
12
|
-
iflow_mcp_cwahlfeldt_blender_mcp-0.1.
|
|
13
|
-
iflow_mcp_cwahlfeldt_blender_mcp-0.1.
|
|
11
|
+
iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info/METADATA,sha256=obc7DBI8vPKns1UUIRnxcQE2dzAj6MWmGomAI53Zb2w,3124
|
|
12
|
+
iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
13
|
+
iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info/entry_points.txt,sha256=QnyWp9XwL2dm3qqSZH1WdCgLZQ0nkmTBgsRJ1wRM3Xc,43
|
|
14
|
+
iflow_mcp_cwahlfeldt_blender_mcp-0.1.2.dist-info/RECORD,,
|
server.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from mcp.server.fastmcp import FastMCP, Context
|
|
2
|
+
import os
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from blender.executor import BlenderExecutor
|
|
7
|
+
from scripts.manager import ScriptManager
|
|
8
|
+
|
|
9
|
+
# Create an MCP server
|
|
10
|
+
mcp = FastMCP("BlenderScriptManager")
|
|
11
|
+
|
|
12
|
+
# Initialize script manager and blender executor
|
|
13
|
+
script_manager = ScriptManager()
|
|
14
|
+
blender_executor = BlenderExecutor()
|
|
15
|
+
|
|
16
|
+
# Scripts resources
|
|
17
|
+
@mcp.resource("scripts://list")
|
|
18
|
+
def list_scripts() -> str:
|
|
19
|
+
"""Get list of available scripts"""
|
|
20
|
+
scripts = script_manager.list_scripts()
|
|
21
|
+
return json.dumps(scripts)
|
|
22
|
+
|
|
23
|
+
@mcp.resource("script://{name}")
|
|
24
|
+
def get_script(name: str) -> str:
|
|
25
|
+
"""Get content of a specific script"""
|
|
26
|
+
return script_manager.get_script(name)
|
|
27
|
+
|
|
28
|
+
@mcp.resource("result://{name}")
|
|
29
|
+
def get_result(name: str) -> str:
|
|
30
|
+
"""Get execution result of a script"""
|
|
31
|
+
return script_manager.get_result(name)
|
|
32
|
+
|
|
33
|
+
# Script management tools
|
|
34
|
+
@mcp.tool()
|
|
35
|
+
def add_script(name: str, content: str) -> str:
|
|
36
|
+
"""Add a new script"""
|
|
37
|
+
try:
|
|
38
|
+
script_manager.add_script(name, content)
|
|
39
|
+
return f"Script '{name}' added successfully"
|
|
40
|
+
except Exception as e:
|
|
41
|
+
return f"Error adding script: {str(e)}"
|
|
42
|
+
|
|
43
|
+
@mcp.tool()
|
|
44
|
+
def edit_script(name: str, content: str) -> str:
|
|
45
|
+
"""Edit an existing script"""
|
|
46
|
+
try:
|
|
47
|
+
script_manager.edit_script(name, content)
|
|
48
|
+
return f"Script '{name}' updated successfully"
|
|
49
|
+
except Exception as e:
|
|
50
|
+
return f"Error updating script: {str(e)}"
|
|
51
|
+
|
|
52
|
+
@mcp.tool()
|
|
53
|
+
def execute_script(name: str, ctx: Context, blend_file: str = None) -> str:
|
|
54
|
+
"""
|
|
55
|
+
Execute a script in Blender
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
name (str): Name of the script to execute
|
|
59
|
+
ctx (Context): MCP context
|
|
60
|
+
blend_file (str, optional): Path to a .blend file to use
|
|
61
|
+
"""
|
|
62
|
+
try:
|
|
63
|
+
ctx.info(f"Executing script '{name}'...")
|
|
64
|
+
if blend_file:
|
|
65
|
+
ctx.info(f"Using blend file: {blend_file}")
|
|
66
|
+
|
|
67
|
+
script_content = script_manager.get_script(name)
|
|
68
|
+
result = blender_executor.execute(name, script_content, blend_file)
|
|
69
|
+
script_manager.save_result(name, result)
|
|
70
|
+
return f"Script '{name}' executed successfully. Use 'result://{name}' to see the output."
|
|
71
|
+
except Exception as e:
|
|
72
|
+
error_msg = f"Error executing script: {str(e)}"
|
|
73
|
+
script_manager.save_result(name, error_msg)
|
|
74
|
+
return error_msg
|
|
75
|
+
|
|
76
|
+
@mcp.tool()
|
|
77
|
+
def remove_script(name: str) -> str:
|
|
78
|
+
"""Remove a script"""
|
|
79
|
+
try:
|
|
80
|
+
script_manager.remove_script(name)
|
|
81
|
+
return f"Script '{name}' removed successfully"
|
|
82
|
+
except Exception as e:
|
|
83
|
+
return f"Error removing script: {str(e)}"
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
# Run the server
|
|
87
|
+
mcp.run()
|
|
File without changes
|