agentleFS
dhakalnirajandhakalnirajan/blender-open-mcp/AGENTS.md

blender-open-mcp

AGENTS.md122 starsChanged 47 days agoMITView on GitHub

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

We split this AGENTS.md into the rules it gives an agent

5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Flat tool signatures: Every @mcp.tool function takes explicit keyword parameters (no params: X wrapper objects).

    line 37
  2. Very specific:

    Do not expose secrets: _redact_state() masks the API key.

    line 78
  3. Very specific:

    Keep legacy aliases (blender_set_ollama_*) working unless intentionally deprecating them in a major release.

    line 80
  4. Very specific:

    Run: .venv/Scripts/python -m pytest tests -q (Windows bash) or python -m pytest tests -q.

    line 84
  5. Very specific:

    When adding an MCP prompt, mirror the pattern in prompts.py and register it there.

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Blender Open MCP — AGENTS.md

Project Overview

blender-open-mcp is a local-first MCP (Model Context Protocol) server for controlling a live Blender session, with a provider-agnostic LLM backend. The same codebase talks to Ollama, LM Studio, llama.cpp server, OpenAI, Azure AI Foundry, and any OpenAI-compatible endpoint. Providers can be set at startup (CLI/env) and switched at runtime through MCP tools.

Repository Layout

  • addon.py — single-file Blender add-on. Registers operators/panel, runs a TCP server (default localhost:9876) that receives newline-delimited JSON commands ({"type": ..., "params": {...}}) and dispatches to handlers in HANDLERS. Handlers cover scene info, object create/modify/delete, materials, rendering, code execution, and PolyHaven download/set-texture.
  • src/blender_open_mcp/
    • server.py — MCP server. Registers all blender_* tools with flat signatures, owns the Blender TCP bridge (_send_blender_command), the runtime LLM state (_llm_state), and the CLI (main()).
    • llm.py — provider layer: PROVIDERS registry + PROVIDER_ALIASES, resolve_provider(), chat(), list_models(), ProviderError. Add new backends here.
    • client/ — canonical async MCP client (BlenderMCPClient) + CLI.
    • prompts.py — MCP Prompts (blender_build_scene, blender_review_scene, blender_configure_llm) registered via register_prompts(mcp).
    • __init__.py — exports main.
  • client/ — compat wrapper so legacy from client import … imports work from source; it bootstraps src/ onto sys.path and re-exports the canonical module.
  • tests/ — pytest suites: test_server.py, test_client.py, test_addon.py (bpy mocked).
  • pyproject.toml — hatchling build, deps, blender-mcp / blender-mcp-client console scripts, pytest config.
  • .venv/ — local virtualenv used for development/testing (gitignored).

Key Design Decisions

  • Flat tool signatures. Every @mcp.tool function takes explicit keyword parameters (no params: X wrapper objects). FastMCP 4 advertises whatever the signature says, so standard MCP clients can call tools with top-level args. Never reintroduce single-wrapper-model signatures for tools.
  • Provider-agnostic routing. _query_llm() in server.py fills missing provider fields from _llm_state and delegates to llm.chat(). Per-call overrides (provider/base_url/model/api_key) are supported on blender_ai_prompt.
  • Runtime provider switching. blender_set_llm_provider mutates _llm_state; blender_get_llm_provider reports it (API key masked); blender_list_llm_models lists models. Ollama-only aliases (blender_set_ollama_model, blender_set_ollama_url, blender_get_ollama_models) are thin wrappers for backward compatibility.
  • Blender bridge protocol. Server sends {"type": "<handler>", "params": {...}}\n over TCP and reads one JSON response line: {"status":"ok","result":...} or {"status":"error","message":...}.

Conventions

  • Python ≥ 3.10, type hints throughout, stdlib typing (Dict, List, Optional) — do not rely on newer 3.11+ syntax unless guarded.
  • Imports for external MCP machinery: from fastmcp import FastMCP (the project runs fastmcp 4 + mcp 2; mcp.server.fastmcp no longer exists).
  • Tool annotations are passed to @mcp.tool(annotations={...}) and use the keys readOnlyHint, destructiveHint, idempotentHint, openWorldHint, title.
  • Provider specs go in llm.py PROVIDERS (style: openai, ollama, azure) plus an alias in PROVIDER_ALIASES; URL/payload/response normalization lives in llm.py, never in server.py tool bodies.
  • Errors returned to agents are friendly strings starting with Error: ... (see _handle_blender_error / _handle_provider_error); exceptions are caught inside tools, not propagated.

Safe Refactoring Rules

  • Changing an MCP tool signature means updating:
    1. the @mcp.tool function in server.py,
    2. any typed wrapper in src/blender_open_mcp/client/client.py,
    3. tests that call it.
  • Adding a Blender-side handler requires: new handler function in addon.py, registration in addon.HANDLERS, and a blender_* tool in server.py that calls _send_blender_command("<handler_name>", ...).
  • Do not expose secrets: _redact_state() masks the API key; keep that mask when adding state-reporting tools.
  • Keep legacy aliases (blender_set_ollama_*) working unless intentionally deprecating them in a major release.

Testing

  • Run: .venv/Scripts/python -m pytest tests -q (Windows bash) or python -m pytest tests -q.
  • Server tests mock httpx and exercise _query_llm for openai / ollama / lmstudio / llamacpp, provider state switching, tool registration/annotations, and PolyHaven pagination — all without Blender.
  • Addon tests mock bpy at import time (see tests/test_addon.py) and test handlers/dispatch plus the timer-driven socket state machine.
  • Client tests mock the MCP HTTP layer.
  • tests/test_integration.py proves the wiring: an in-process fastmcp.Client against the server (tools + prompts), and the timer-driven addon.py TCP loop pumped by the test harness over a socket by the server bridge.
  • Manual end-to-end: start the add-on in Blender, run blender-mcp --transport http, then blender-mcp-client --host http://localhost:8000 tool blender_get_scene_info.
  • When adding an MCP prompt, mirror the pattern in prompts.py and register it there; update tests/test_integration.py expectations if the prompt set is part of a contract.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.