Codex Tldraw Mcp

io.github.jananadiw由 GitHub 账号 jananadiw 发布v0.5.0更新于 Oct 27, 2026

A Codex stdio MCP server that generates repo-local tldraw diagrams and detects code graph drift.

已验证STDIO仅桌面开发者工具媒体与设计

概览

AI 生成的概览

本地 stdio MCP 服务器,可在仓库内生成可编辑的 tldraw 图表与 SVG 预览,并生成可追踪的 JS/TS 代码图与漂移检测。

可以做什么
  • 从仓库生成图表:扫描仓库并追加产品流程图,或绘制包含主流程与支撑组件的简要架构视图。
  • 按提示绘图:无需扫描源码,把工作流、状态机、架构草图或计划追加到画板。
  • 构建与比对代码图:生成可追踪的 JavaScript/TypeScript 导入图,然后预览漂移或标记变更与失效元素。
  • 查看画板:列出仓库 boards 目录下的画板,并汇总图表内容、图形数量与产物路径。
适用场景
适合希望图表与所描述的代码放在一起的场景,也适合在代码修改后查看哪些模块发生变化或消失。同样适用于状态机等无需扫描仓库的纯提示绘图。
运行要求
通过 npx 以本地进程运行(npm 包 codex-tldraw-mcp);Codex 插件需要 Node.js 20.11 或更高版本以及 PATH 中的 npm,首次回退启动需要访问软件源。仓库类工具需传入绝对路径 repoPath,远程仓库须先克隆到本地。可选环境变量 TLDRAW_MCP_ALLOWED_ROOTS 可限制可读写的根目录。
安装前请注意
这是本地文件系统工具:会读取 repoPath 下的源码文件,并在 repoPath/boards 下写入 .tldr 与 .svg 文件,且会追加到已有画板。未设置 TLDRAW_MCP_ALLOWED_ROOTS 时不会限定在特定目录,建议设置该白名单以限制访问范围。画板资源链接会包含编码后的仓库绝对路径。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Codex Tldraw Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

codex-tldraw-mcp

[npm version] [CI] [License: MIT]

A stdio MCP server that generates editable repo-local tldraw diagrams, portable SVG previews, and trackable code graphs with drift detection.

[codex-tldraw-mcp demo]

Quick Start

Add the server to Codex:

bash
codex mcp add codex-tldraw -- npx -y codex-tldraw-mcp

Then ask Codex to diagram the current repo:

text
Use codex-tldraw to diagram this repo.

Reverse-engineer its runtime architecture:

text
Use codex-tldraw to show how this repo works across its main components.Show the main flow first, keep short errors inside components, and label each interaction once.

Or ask for a diagram directly:

text
Use codex-tldraw to draw a password reset state machine.

Create a trackable JavaScript or TypeScript module graph:

text
Use codex-tldraw to create a code graph for this repo.

After the code changes, compare it with the saved graph:

text
Use codex-tldraw to preview code graph drift, then mark stale elements.

The default outputs are:

text
<repo>/boards/main.tldr<repo>/boards/main.svg

Open the .tldr board in a tldraw-compatible viewer to edit it. Any MCP host, browser, documentation system, or code review can display the .svg preview directly.

See the v0.7.1 release notes for plugin fixes and verification details.

Codex Plugin

This repository also packages the server as a Codex plugin. The existing MCP tools still write .tldr and .svg files; the plugin adds a .tldr file handler that opens the editable board in an embedded React/tldraw app.

Two paths open the same editor:

Diagram tool panel — After draw_canvas, diagram_repo, or similar tools run, the inline MCP App loads the board from the repository-scoped server resource tldraw://repos/<encoded-repo-path>/boards/<name>/file and saves through the app-only save_board tool.

.tldr file entrypoint — When Codex opens a repo file directly, the app uses the host file resource API (open_tldraw_file). Writable files save with ETag conflict protection.

Build the server and its single-file app:

bash
bun installbun run build

Install the published plugin from npm (recommended):

bash
npm install -g codex-tldraw-mcpcodex plugin marketplace add "$(npm root -g)/codex-tldraw-mcp"codex plugin add codex-tldraw@codex-tldraw-mcp

Or install from GitHub:

bash
codex plugin marketplace add jananadiw/codex-tldraw-mcpcodex plugin add codex-tldraw@codex-tldraw-mcp

The plugin requires Node.js 20.11 or later and npm on PATH. A GitHub plugin download does not build source or install dependencies. The launcher uses a built local copy when available; otherwise it runs the matching published npm version through npx. The first fallback launch needs registry access. No Bun installation is needed to use the plugin.

For development from this checkout:

bash
bun run buildcodex plugin marketplace add .codex plugin add codex-tldraw@codex-tldraw-mcp

The marketplace descriptor is .agents/plugins/marketplace.json, the plugin manifest is .codex-plugin/plugin.json, its MCP configuration is .mcp.json, and the bundled app is dist/app.html. MCP hosts without app support continue to use the existing text results, .tldr resources, and SVG previews.

What You Get

  • A repo-local .tldr board that stays with the project it explains, plus a portable .svg preview.
  • A user-facing product workflow inferred from package metadata and source text.
  • A prompt-driven offline canvas API for drawing workflows, state machines, plans, and architecture sketches that are not tied to repo scanning.
  • Simple architecture diagrams showing the main flow first, with supporting services below it.
  • A trackable JavaScript and TypeScript module/import graph with drift detection.
  • Red markers for stale nodes and edges, orange markers for changed modules, and a report of new elements.
  • tldraw steps and arrows laid out left to right.
  • Non-destructive updates: existing boards get the next diagram appended to the right.
  • MCP resources for listing boards and reading board summaries.

For a handwriting font app, the workflow may be inferred as:

text
User writes alphabet on paper -> User takes a photo of the paper -> User uploads the image -> AI generates a font -> User downloads a .ttf file

Manual Configuration

If you prefer editing Codex MCP config directly:

toml
[mcp_servers.codex-tldraw]command = "npx"args = ["-y", "codex-tldraw-mcp"]

Tools

  • diagram_repo: scans a repo and appends a product workflow diagram to <repo>/boards/<boardName>.tldr.
  • draw_canvas: appends a prompt-provided workflow, state machine, architecture sketch, or plan to <repo>/boards/<boardName>.tldr.
  • draw_architecture: appends a simple codebase architecture view with a main flow, supporting components, actions, calls, and errors.
  • diagram_code_graph: scans repository-local JavaScript and TypeScript modules and appends a trackable import graph.
  • compare_code_graph: previews drift or marks changed and stale elements on an existing trackable code graph.
  • list_boards: lists boards under a repo's boards/ directory.
  • read_board_summary: summarizes generated diagrams and shape counts and returns both artifact paths.

When using the plugin, pass the absolute path of the repository as repoPath on every repository tool call. The plugin runs from its installation directory, not the chat workspace. Missing or relative paths are rejected to prevent diagrams being written to the plugin cache. For a remote repository URL, clone it locally first, then use the checkout path.

Standalone MCP tools accept an optional repoPath. Relative paths resolve from the MCP server working directory.

Every diagram-writing tool saves both artifacts and returns boardPath and svgPath in structured output. Tool content also includes MCP resource links for the editable board and SVG preview. The SVG renderer covers the text, rectangle, and arrow shapes generated by this server and needs no browser runtime.

New board resource links carry the encoded absolute repository path. They keep working after a server restart or a tool call for another repository, including when both repositories use the same board name. Resource reads still enforce TLDRAW_MCP_ALLOWED_ROOTS.

Legacy tldraw://boards/<name>/... resources remain available for older standalone clients and use the last selected repository. Re-run a diagram tool to replace older editor links with repository-scoped links.

The editor checks the loaded board's ETag before saving, blocks stale saves, and offers Discard and reload after a conflict. Invalid board data is rejected before replacing files. Diagram writes use a per-board filesystem lock so simultaneous calls from different server processes preserve both appends.

Code Graph Drift

diagram_code_graph stores stable repository-relative identities and fingerprints in MCP-owned shape metadata. Each source module becomes a node. Static imports, dynamic imports, re-exports, and CommonJS require calls between repository modules become edges.

Run compare_code_graph after the repository changes. Preview mode is the default and does not write the board:

text
Compare the current code with the newest code graph on boards/main.tldr.

To update the board, ask Codex to apply the drift markers or pass applyMarkers: true. The comparison uses four states:

  • unchanged: the stored identity and fingerprint still match.
  • changed: the module still exists, but its exports or local import relationships changed.
  • stale: the board contains an element that no longer exists in the current code graph.
  • new: the current graph contains an element that is absent from the board.

Stale elements become red and dashed. Changed modules become orange and dashed. New elements appear in the tool result; v0.4.0 does not insert or rearrange them. Re-running the comparison restores the original generated style when code matches again.

The comparison changes only MCP-generated graph styling and metadata. It preserves positions, sizes, labels, manual shapes, and other diagrams on the board, and it restores each element's prior color when drift clears. Boards created by diagram_repo, draw_canvas, or an older release do not contain trackable code-graph metadata; create a graph with diagram_code_graph before comparing drift.

The v0.4.0 scanner supports .js, .jsx, .mjs, .cjs, .ts, .tsx, .mts, and .cts modules. It reports unresolved relative imports and counts external imports without drawing external packages. It models module/import relationships, not runtime call graphs.

Prompt-Driven Diagrams

draw_canvas does not scan source files. The current repository is only the storage location for the generated board.

Example prompts:

text
Use codex-tldraw to draw the auth flow:Visitor opens login -> chooses email or SSO -> completes MFA -> lands in dashboard.
text
Use codex-tldraw to make a state machine for password reset:Idle -> Reset requested -> Email sent -> Token verified -> Password updated.
text
Use codex-tldraw to append an architecture diagram for this plan:Web app calls API gateway, API gateway calls worker queue, worker writes generated files to object storage.

Simple Architecture

draw_architecture helps a new reader understand how work moves across a codebase. Codex inspects the code first, then sends the renderer a small model:

  • The main user flow becomes a straight row of boxes.
  • Supporting services sit below the component that calls them.
  • Each component shows at most three important actions and two short errors.
  • Each interaction gets one concise arrow; request and response share that arrow.
  • Source evidence is optional metadata and does not clutter the diagram.

Keep libraries and helper modules inside component actions. For example, "validate the response with Zod" belongs inside the API component rather than becoming a separate Zod component. Meaningful arrows have bindings to both endpoint shapes.

See Architecture Diagrams for the analysis contract and input model.

Feedback

This project is early and feedback is useful. Please open an issue if:

  • The generated workflow misses the real product flow.
  • A board does not open in your tldraw-compatible viewer.
  • Code graph drift reports an incorrect module or import relationship.
  • You have a messy repo where a PM and engineer need a clearer shared map.

Use the GitHub issue templates for bugs, feature requests, and real-world examples.

Why This Exists

This project is snapshot-only. It does not control a live browser canvas or provide live collaboration. It writes board files to the repository being diagrammed so a tldraw-compatible viewer can open them later.

The official tldraw MCP App is designed for hosts that can render an interactive tldraw canvas inside the chat context. In Codex Desktop, tool discovery worked in testing, and the tldraw search tool returned Editor API details, shape types, and helpers. The live exec path did not work: every call timed out after 30 seconds, including a read-only call to count the current page shapes.

That failure mode motivated the original file-based fallback. The v0.7.0 plugin now includes its own embedded MCP App editor, while generated SVG previews remain usable in hosts without app support.

This server started as a Codex-first fallback. Instead of trying to drive a live canvas, it generates .tldr snapshots on disk through a normal stdio MCP tool call. Its stdio transport and SVG previews now make the same output usable in any MCP-compatible host, while Codex remains the primary documented setup.

Security

This is a local filesystem tool. It reads source files from repoPath and writes .tldr and .svg files under repoPath/boards.

To restrict access to specific directories, set TLDRAW_MCP_ALLOWED_ROOTS to a path-delimited allowlist:

toml
[mcp_servers.codex-tldraw]command = "npx"args = ["-y", "codex-tldraw-mcp"]env = { TLDRAW_MCP_ALLOWED_ROOTS = "/Users/me/dev:/Users/me/work" }

When the allowlist is set, repoPath must resolve inside one of those roots.

Generated .tldr files do not store absolute local repository paths in shape metadata. Trackable code graphs store repository-relative source paths.

Local Development

This repo uses Bun for development:

bash
bun installbun run buildbun run smoke

Run the server from source:

bash
bun run dev

Use a local build in Codex:

toml
[mcp_servers.codex-tldraw]command = "node"args = ["/absolute/path/to/codex-tldraw-mcp/dist/index.js"]

Publish

Build, test, and inspect the package contents:

bash
bun install --frozen-lockfilebun run buildbun run smokebun run check:packagebun run check:plugin

Publishing is handled by .github/workflows/publish-npm.yml when a GitHub Release is published. The npm trusted publisher must allow jananadiw/codex-tldraw-mcp, workflow publish-npm.yml, with no GitHub environment and the publish action enabled. The workflow uses GitHub OIDC and does not require an npm token.

Use the workflow's dry_run dispatch option to validate a release without publishing it.

The package includes MCP Registry metadata:

  • package.json declares mcpName.
  • server.json describes the npm stdio package.

After the workflow publishes and the npm package version is available, authenticate and publish the registry metadata:

bash
mcp-publisher login githubmcp-publisher publish

Verify the registry entry:

bash
curl "https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.jananadiw/codex-tldraw-mcp"

来源:README.md,提交 deeec10

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.5.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分