Open9
mcp-use 使ってみた

以下のBlenderのものを試してみる

まずは、Blenderをインストール
brew install --cask blender

macのblenderぬるぬる動く!!すごい!!

venvで仮想環境構築
python3 -m venv .venv
source .vnev/bin/activate

必要なものをインストール
pip install langchain_openai

.envにapikeyをセット
Blenderのところをコピペして、openaiへ修正
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from mcp_use import MCPAgent, MCPClient
async def run_blender_example():
# Load environment variables
load_dotenv()
# Create MCPClient with Blender MCP configuration
config = {"mcpServers": {"blender": {"command": "uvx", "args": ["blender-mcp"]}}}
client = MCPClient.from_dict(config)
# Create LLM
llm = ChatOpenAI(model="gpt4o")
# Create agent with the client
agent = MCPAgent(llm=llm, client=client, max_steps=30)
try:
# Run the query
result = await agent.run(
"Create an inflatable cube with soft material and a plane as ground.",
max_steps=30,
)
print(f"\nResult: {result}")
finally:
# Ensure we clean up resources properly
if client.sessions:
await client.close_all_sessions()
if __name__ == "__main__":
asyncio.run(run_blender_example())

エラーになった?

うまくいかなったので、以下を試す。
git clone https://github.com/pietrozullo/mcp-use.git
cd mcp-use
pip install -e .

chat_example.py
browser_use.py
は試せた!!