TD_MCP

TD_MCP

A local-first MCP server for TouchDesigner that provides offline documentation retrieval and live control of TouchDesigner sessions, enabling AI-assisted network building and parameter management.

Category
访问服务器

README

TouchDesigner MCP (TD_MCP)

Local-first TouchDesigner MCP (Model Context Protocol) that fuses the best ideas from the TD-MCP ecosystem into one tool:

  • Offline doc/RAG server (td_mcp.server_offline) — parallel multi-RAG: several retrieval backends (global BM25, per-source BM25 for operators/python/glsl/tutorials, optional MiniLM dense + HyDE, title boost) run concurrently and fuse via Reciprocal Rank Fusion, with an optional CrossEncoder reranker. Version-aware, no cloud/keys.
  • Eval harness (td_mcp.rag.eval) — recall@k / MRR / nDCG over labelled queries, so quality is provable and regressions are caught. Includes 1091 chunks (TOP 49 / CHOP 35 / SOP 32 / DAT 24 / Python 22 / COMP 21 / tutorial 19 / POP 8 / GLSL 6 / etc. seed + tdmcp/bottobot corpora): k=5 recall 0.966, zero version-gating violations.
  • Live Bridge MCP Server & CLI Client (td_mcp.server_live) + TD-side Bridge (bridge/td_mcp_bridge.py) — control a running TD session over HTTP using stdio MCP, Streamable HTTP + SSE (multi-session, DNS-rebind guard), or the legacy CLI. Exposes 39 live tools (create/delete/wire/inspect/read/verify/snapshot/recipe/timeline…). Every mutation is wrapped in ui.undo so one Ctrl+Z reverts a whole agent batch. Features spatial context markers (*here and *this) to resolve the currently active network or selected node.
  • Natively Embedded Chat UI Panel (bridge/chat_ui.html) — a zero-dependency glassmorphic chat panel served by the bridge at GET /, with provider selector (Ollama / Gemini / OpenAI), live network sidebar, and a multi-step autonomous agent loop.
  • Autonomous in-TouchDesigner Agent (bridge/td_mcp_agent.py) — a zero-dependency OpenAI-compatible agent script that runs natively inside TD Text DATs. Allows you to chat offline (using local Ollama) or online (Gemini/OpenAI) to build networks autonomously.

Design notes and the full server catalog are located in the repository root:

  • [TouchDesigner_MCP_Servers.md](file:///c:/Users/Z/Downloads/PROJECTS/TOUCHDESIGNER/td-mcp/TouchDesigner_MCP_Servers.md) — catalog of every TD MCP server + brainstorm
  • [TD_MCP_Master_Plan.md](file:///c:/Users/Z/Downloads/PROJECTS/TOUCHDESIGNER/td-mcp/TD_MCP_Master_Plan.md) — the master plan and future roadmap this scaffold implements
  • [TouchDesigner_Links.md](file:///c:/Users/Z/Downloads/PROJECTS/TOUCHDESIGNER/td-mcp/TouchDesigner_Links.md) — official docs / Python API / curriculum

Layout

td-mcp/
├── pyproject.toml
├── HOW_TO_USE.md
├── README.md
├── setup_env.ps1
├── td_mcp/
│   ├── server_offline.py     # doc/RAG MCP server + CLI (24 tools, ParallelRetriever)
│   ├── server_live.py        # Streamable HTTP + SSE + stdio client for the TD bridge (39 tools)
│   ├── streamable_http.py    # Streamable-HTTP transport mixin (SSE, sessions, DNS-rebind guard)
│   ├── generators.py         # artist network generators (feedback / audio-reactive / particle / 3D / GLSL / LED / DMX)
│   ├── recipe_vault.py       # recipe blueprint storage
│   ├── eval.py               # offline build eval gate
│   ├── rag/
│   │   ├── retriever.py      # Index (BM25 + dense + version resolver)
│   │   ├── strategies.py     # per-source + dense + HyDE strategies, RRF fusion
│   │   ├── rerank.py         # optional CrossEncoder reranker
│   │   ├── knowledge_graph.py # Graph-RAG related-operator walk
│   │   └── eval.py           # recall@k / MRR / nDCG harness
│   ├── tdn/                  # Diffable YAML (TDN) importer/exporter
│   ├── showcontrol/          # Show-control network builders (Art-Net / sACN / OSC / MIDI / timecode)
│   ├── led_mapping/          # LED pixel layout matrices and DMX mapping
│   ├── tools/risk.py         # risk-tier classification (READ_ONLY / WRITE_ADDITIVE / DESTRUCTIVE)
│   └── kb/
│       ├── chunks.jsonl      # 1091 built chunks (real TD facts, source+min_version+aliases)
│       ├── corpus.py         # operator / Python / GLSL / version corpus records
│       ├── build_kb.py       # regenerates chunks.jsonl from authored records
│       ├── import_corpus.py  # import authored JSON corpus records
│       ├── embeddings.jsonl  # MiniLM vectors (after TD_MCP_DENSE=1)
│       ├── scrape.py         # crawl docs.derivative.ca
│       └── build_index.py    # validate / dense-embed
├── bridge/
│   ├── td_mcp_bridge.py      # paste into a Text DAT in TD (bridge server: JSON-RPC, WS, SSE, chat UI)
│   ├── td_mcp_agent.py       # paste into a Text DAT in TD (autonomous builder agent, ~48 schemas)
│   ├── chat_ui.html          # glassmorphic chat UI panel served at GET /
│   └── bootstrap.py          # one-click bootstrap helper
└── skills/td-building/       # Claude Code skill

Quick start (no deps)

uv is enough — the retriever is pure standard library.

uv run python td_mcp/rag/retriever.py "blur top parameters"
uv run python -m td_mcp.server_offline "movie file in top param file"
uv run python -m td_mcp.server_offline --family TOP        # list all TOPs
uv run python -m td_mcp.server_offline --parameter "movie"  # param spec by nickname
uv run python -m td_mcp.server_offline --glossary          # full KB index

Run as MCP Servers

Register in your AI client (Claude Desktop: %APPDATA%\Claude\claude_desktop_config.json; Cursor: %USERPROFILE%\.cursor\mcp.json):

{
  "mcpServers": {
    "td-mcp-offline": {
      "command": "uv",
      "args": ["run", "--project", "C:/Users/Z/Downloads/PROJECTS/TOUCHDESIGNER/td-mcp", "td-mcp-offline", "--mcp"]
    },
    "td-mcp-live": {
      "command": "uv",
      "args": ["run", "--project", "C:/Users/Z/Downloads/PROJECTS/TOUCHDESIGNER/td-mcp", "td-mcp-live", "--mcp"],
      "env": {
        "TD_MCP_AUTH_TOKEN": "YOUR_AUTO_GENERATED_TOKEN"
      }
    }
  }
}

Exposed Offline Tools (24): td_docs_search, td_docs_operator, td_docs_python, td_docs_glsl, td_docs_template, td_docs_version, td_docs_family, td_docs_parameter, td_docs_compare, td_docs_connections, td_docs_workflow, td_docs_version_info, td_docs_related, td_docs_glossary, td_build_network, td_showcontrol_plan, td_led_map, td_build_feedback, td_build_audio_reactive, td_build_particle, td_build_3d_scene, td_build_glsl_shader, td_build_led_wall, td_build_dmx_fixture.

Exposed Live Tools (39): create_node, delete_node, set_parameters, get_parameters, get_errors, execute_python, list_nodes, project_info, capture_viewport, get_resource, describe_td_tools, batch, read_chop, read_top, read_dat, scan_network, build_and_verify, connect_nodes, rename_node, copy_node, auto_layout, get_node, set_node_color, set_node_comment, map_network, disconnect_nodes, get_connections, exec_node_method, snapshot_network, restore_network, get_performance, validate_network, set_flags, find_nodes, set_node_position, timeline, export_recipe, import_recipe, save_tox.

Control a live TouchDesigner

  1. In TD, create a Text DAT, paste bridge/td_mcp_bridge.py, and run: op('text1').module.start() — it listens on 127.0.0.1:9980 and prints the authorization token.
  2. From the shell (CLI mode):
$env:TD_MCP_AUTH_TOKEN="YOUR_AUTO_GENERATED_TOKEN"
uv run td-mcp-live status
uv run td-mcp-live create /project1 CircleTOP --name my_circle
uv run td-mcp-live set /project1/my_circle '{"radius": 0.5}'
uv run td-mcp-live exec "print([c.name for c in op('/project1').children])"

Streamable HTTP mode

td-mcp-live can also run as a Streamable-HTTP MCP server (POST / JSON-RPC + GET / SSE, multi-session via Mcp-Session-Id, DNS-rebind guard). Point an HTTP-capable MCP client at http://127.0.0.1:8765:

uv run td-mcp-live --http

Grow the knowledge base

chunks.jsonl is generated by td_mcp/kb/build_kb.py from a curated set of authored records (operators across every family, Python classes, GLSL, and recipes). Edit the records there and regenerate — never hand-edit chunks.jsonl.

uv run python -m td_mcp.kb.build_kb          # author -> chunks.jsonl (216 chunks)
uv run python -m td_mcp.rag.eval             # re-check recall/MRR/nDCG
uv add --optional scrape
uv run python -m td_mcp.kb.scrape
uv run python -m td_mcp.kb.build_index
TD_MCP_DENSE=1 uv run python -m td_mcp.kb.build_index   # all-MiniLM upgrade

Upgrade retrieval quality (opt-in, no forced download)

uv pip install -e ".[rag]"                       # sentence_transformers
TD_MCP_DENSE=1 uv run python -m td_mcp.kb.build_index   # encode + write embeddings.jsonl
TD_MCP_DENSE=1 uv run td-mcp-offline "blur top parameters"   # dense + HyDE strategies now active
TD_MCP_RERANK=1 uv run td-mcp-offline "..."   # late-stage CrossEncoder rerank

The dense/HyDE/rerank paths are lazy: without .[rag] and TD_MCP_DENSE=1 the server still runs (TF-IDF + BM25 + title + per-source RRF fusion).

Evaluate (catch regressions)

uv run python -m td_mcp.rag.eval                 # zero-dep: k=5 recall 1.0
TD_MCP_DENSE=1 uv run python -m td_mcp.rag.eval --k 5

Fuse an EXTERNAL RAG server (multi-process, in parallel)

Beyond per-source local backends, the ParallelRetriever can fold in a separate RAG process — e.g. cacheflowe/td-docs-mcp or bottobot running as its own MCP server. Both run concurrently and are merged by RRF into one answer. This is the "combine multiple RAGs in parallel" design: two independent systems, one fused result, the slow stdio round-trip hidden behind the lexical threads.

TD_MCP_REMOTE_MCP="uv run td-docs-mcp" uv run td-mcp-offline "blur top"
# optional: TD_MCP_REMOTE_TOOL / TD_MCP_REMOTE_ARG to match its tool name

The external hits appear in results with source: "remote:...".

Tests

uv run python -m tests.test_rag          # recall/version/per-source + local+remote fusion
uv run python -m tests.test_mcp_server   # server wiring: 6 tools, search returns KB

tests/fake_remote_mcp.py is a tiny stdio MCP server the fusion test uses to exercise the multi-process path without a real external install. (Note: the mcp 1.28 stdio transport has an internal pydantic quirk on some builds, so the server test calls handlers in-process rather than over the wire.)

Anchor live mutations to docs ("shots")

uv run td-mcp-live --anchor create /project1 "Blur TOP" TOP

Each OK response gets a shots field: the most relevant KB chunk(s), so the LLM sees doc-truth next to what it just did in TD.

Port map (avoid clashes)

td-mcp bridge = 9980 (same as Pantani tdmcp & benoitliard touch-mcp — run only one, or change TD_MCP_PORT). Others in the ecosystem: Embody 9870, johnsabath 9988, twozero 40404, superdwayne 8053.

License

MIT. Note: TrueFiasco/TD_Builder_alpha (a source of the hybrid-RAG idea) is AGPL-3.0 — the techniques here are reimplemented, not copied, so MIT stays clean.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选