changed resource to tool
This commit is contained in:
parent
320461d2fe
commit
fbf8fd459c
35
README.md
35
README.md
@ -9,7 +9,6 @@ BlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP
|
|||||||
- **Material control**: Apply and modify materials and colors
|
- **Material control**: Apply and modify materials and colors
|
||||||
- **Scene inspection**: Get detailed information about the current Blender scene
|
- **Scene inspection**: Get detailed information about the current Blender scene
|
||||||
- **Code execution**: Run arbitrary Python code in Blender from Claude
|
- **Code execution**: Run arbitrary Python code in Blender from Claude
|
||||||
- **Rendering**: Trigger renders directly from Claude
|
|
||||||
|
|
||||||
## Components
|
## Components
|
||||||
|
|
||||||
@ -26,6 +25,40 @@ The system consists of two main components:
|
|||||||
- Python 3.7 or newer
|
- Python 3.7 or newer
|
||||||
- MCP library (`pip install mcp`)
|
- MCP library (`pip install mcp`)
|
||||||
|
|
||||||
|
### Quick Start
|
||||||
|
|
||||||
|
Run blender-mcp without installing it permanently (pipx will automatically download and run the package):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pipx run blender-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't have pipx installed, you can install it with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -m pip install pipx
|
||||||
|
```
|
||||||
|
|
||||||
|
### Claude for Desktop Integration
|
||||||
|
|
||||||
|
Update your `claude_desktop_config.json` (located in `~/Library/Application\ Support/Claude/claude_desktop_config.json` on macOS and `%APPDATA%/Claude/claude_desktop_config.json` on Windows) to include the following:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"blender": {
|
||||||
|
"command": "pipx",
|
||||||
|
"args": [
|
||||||
|
"run",
|
||||||
|
"blender-mcp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This configuration allows Claude for Desktop to automatically start the Blender MCP server when needed. The pipx command will handle both downloading and running the package in one step.
|
||||||
|
|
||||||
### Installing the Blender Addon
|
### Installing the Blender Addon
|
||||||
|
|
||||||
1. Open Blender
|
1. Open Blender
|
||||||
|
|||||||
@ -228,29 +228,8 @@ def get_blender_connection():
|
|||||||
|
|
||||||
return _blender_connection
|
return _blender_connection
|
||||||
|
|
||||||
@mcp.resource("blender://ping")
|
|
||||||
def ping_blender() -> str:
|
|
||||||
"""Ping the Blender server to check connectivity"""
|
|
||||||
try:
|
|
||||||
blender = get_blender_connection()
|
|
||||||
result = blender.send_command("ping")
|
|
||||||
return json.dumps({"status": "success", "result": result})
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error pinging Blender: {str(e)}")
|
|
||||||
return json.dumps({"status": "error", "message": str(e)})
|
|
||||||
|
|
||||||
@mcp.resource("blender://simple")
|
@mcp.tool("blender://scene")
|
||||||
def get_simple_info() -> str:
|
|
||||||
"""Get basic information about the Blender instance"""
|
|
||||||
try:
|
|
||||||
blender = get_blender_connection()
|
|
||||||
result = blender.send_command("get_simple_info")
|
|
||||||
return json.dumps({"status": "success", "result": result})
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error getting simple info from Blender: {str(e)}")
|
|
||||||
return json.dumps({"status": "error", "message": str(e)})
|
|
||||||
|
|
||||||
@mcp.resource("blender://scene")
|
|
||||||
def get_scene_info() -> str:
|
def get_scene_info() -> str:
|
||||||
"""Get detailed information about the current Blender scene"""
|
"""Get detailed information about the current Blender scene"""
|
||||||
try:
|
try:
|
||||||
@ -261,7 +240,7 @@ def get_scene_info() -> str:
|
|||||||
logger.error(f"Error getting scene info from Blender: {str(e)}")
|
logger.error(f"Error getting scene info from Blender: {str(e)}")
|
||||||
return json.dumps({"status": "error", "message": str(e)})
|
return json.dumps({"status": "error", "message": str(e)})
|
||||||
|
|
||||||
@mcp.resource("blender://object/{object_name}")
|
@mcp.tool("blender://object/{object_name}")
|
||||||
def get_object_info(object_name: str) -> str:
|
def get_object_info(object_name: str) -> str:
|
||||||
"""
|
"""
|
||||||
Get detailed information about a specific object in the Blender scene.
|
Get detailed information about a specific object in the Blender scene.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user