From fbf8fd459cb25fc40ef1dbaa0e4c0a7912cb381b Mon Sep 17 00:00:00 2001 From: ahujasid Date: Mon, 10 Mar 2025 13:22:27 +0530 Subject: [PATCH] changed resource to tool --- README.md | 35 +++++++++++++++++++++++++++- src/blender_mcp/addon.py => addon.py | 0 src/blender_mcp/server.py | 25 ++------------------ 3 files changed, 36 insertions(+), 24 deletions(-) rename src/blender_mcp/addon.py => addon.py (100%) diff --git a/README.md b/README.md index 06afce3..e25b690 100644 --- a/README.md +++ b/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 - **Scene inspection**: Get detailed information about the current Blender scene - **Code execution**: Run arbitrary Python code in Blender from Claude -- **Rendering**: Trigger renders directly from Claude ## Components @@ -26,6 +25,40 @@ The system consists of two main components: - Python 3.7 or newer - 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 1. Open Blender diff --git a/src/blender_mcp/addon.py b/addon.py similarity index 100% rename from src/blender_mcp/addon.py rename to addon.py diff --git a/src/blender_mcp/server.py b/src/blender_mcp/server.py index b2d7d7b..3ccf256 100644 --- a/src/blender_mcp/server.py +++ b/src/blender_mcp/server.py @@ -228,29 +228,8 @@ def get_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") -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") +@mcp.tool("blender://scene") def get_scene_info() -> str: """Get detailed information about the current Blender scene""" try: @@ -261,7 +240,7 @@ def get_scene_info() -> str: logger.error(f"Error getting scene info from Blender: {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: """ Get detailed information about a specific object in the Blender scene.