Sign inSign up

edgaras0x4e/drawio-mcp-http

By edgaras0x4e

•Updated 3 days ago

HTTP proxy for the draw.io MCP server with temporary shortened diagram links

Image
Integration & delivery
Machine learning & AI
Data science
0

277

edgaras0x4e/drawio-mcp-http repository overview

⁠drawio-mcp-http

Runs the official @drawio/mcp⁠ server behind an HTTP proxy so that chat clients such as OpenWebUI⁠ can connect to it. The proxy also shortens the diagram links, because chat models damage long URLs when they write them into replies.

⁠The problem

@drawio/mcp communicates only over stdio. Its tools (open_drawio_xml, open_drawio_mermaid, open_drawio_csv) return an app.diagrams.net editor URL with the entire diagram encoded in the URL fragment. These URLs are usually 1000 to 1800 characters long.

This causes two problems in a chat client:

  1. Clients that connect to MCP servers over HTTP cannot use a stdio server directly.
  2. The model damages the link. The tool returns a correct URL, but the model does not paste it into its reply. It generates the text again, and with strings this long it loses characters. The damaged link makes draw.io fail. Telling the model to copy the URL exactly makes this less frequent but does not remove it.

What this service does:

  1. supergateway⁠ translates between HTTP and the stdio server.
  2. A front server rewrites every tool response: the long URL is stored and replaced with a short link (about 30 characters) that points back at this service. Opening the short link returns a redirect to the full editor URL. The model only handles the short string, which it copies without errors.

No diagram content is sent to any external server. The diagram stays in the URL fragment, and the full URL travels only between this service and the user's browser.

⁠Architecture

Architecture

⁠Endpoints

MethodPathPurposeAuth
POST/GET/mcpMCP Streamable HTTP endpointoptional bearer token
GET/d/<id>Redirect (302) to the full draw.io editor URL for that short idnone
GET/healthzLiveness check, returns oknone

/d/<id> and /healthz are intentionally unauthenticated: browsers cannot attach an Authorization header when following a link, and the ids are unguessable random values.

⁠Quick start

From Docker Hub⁠:

docker run -d --name drawio-mcp -p 8000:8000 \
  -e DRAWIO_MCP_PUBLIC_BASE_URL=http://localhost:8000 \
  edgaras0x4e/drawio-mcp-http

Or build from source:

docker build -t drawio-mcp-http .
docker run -d --name drawio-mcp -p 8000:8000 \
  -e DRAWIO_MCP_PUBLIC_BASE_URL=http://localhost:8000 \
  drawio-mcp-http

Then point an MCP client at http://localhost:8000/mcp.

Minimal docker-compose.yml:

services:
  drawio-mcp:
    image: edgaras0x4e/drawio-mcp-http
    ports:
      - "8000:8000"
    environment:
      DRAWIO_MCP_PUBLIC_BASE_URL: http://localhost:8000

The docker-compose.yml in this repository additionally joins an external Docker network (docker_tools_default) so it can be reached by name from a co-located client container. Remove that networks: block, or replace it with your own, for a standalone setup.

⁠Configuration

All configuration is via environment variables. None are required except in the situations noted.

VariableDefaultDescription
DRAWIO_MCP_PUBLIC_BASE_URLhttp://localhost:8000Base of the short links. Must be reachable from the user's browser, not from the MCP client. Set this to the public/base URL the browser uses to reach /d/<id>.
DRAWIO_MCP_BEARER_TOKENempty (auth disabled)If set, /mcp requires Authorization: Bearer <token>. Compared in constant time. Recommended when the endpoint is publicly reachable.
DRAWIO_MCP_PREFERRED_DIAGRAM_TYPEmermaidmermaid, xml, or csv. A line is appended to every open_drawio_* tool description steering the model toward that type. Set to an empty string to disable the steering.
DRAWIO_MCP_INSTRUCTION_TEMPLATEsee belowText that replaces a successful diagram tool result. {url} expands to the short link (every occurrence).
DRAWIO_MCP_SHORTLINK_TTL_DAYS7Age after which unused short links are deleted by an hourly sweep.
DRAWIO_MCP_LINKS_DB/tmp/links.dbPath to the sqlite file that stores short links.

Default DRAWIO_MCP_INSTRUCTION_TEMPLATE:

Draw.io Editor URL:
{url}

Assistant instruction: your visible reply must contain exactly this markdown line, with the URL copied character-for-character. Never decode, re-encode, shorten, split, or retype any part of the URL:
[Temporary Draw.io Link]({url})

⁠Connecting from an MCP client

Example for OpenWebUI (Admin Panel, Integrations, Add Connection):

  • Type: MCP Streamable HTTP
  • URL: <DRAWIO_MCP_PUBLIC_BASE_URL>/mcp (for example http://localhost:8000/mcp)
  • Auth: None, or Bearer with the token if DRAWIO_MCP_BEARER_TOKEN is set

Ask the model for a diagram. It calls one of the drawio tools, and its reply contains the short Temporary Draw.io Link. Clicking it opens the diagram in the draw.io editor.

Short links are stored in a sqlite database at DRAWIO_MCP_LINKS_DB. Identical diagrams reuse the same id (deduplication). Entries older than DRAWIO_MCP_SHORTLINK_TTL_DAYS are swept hourly.

The database is container-internal and not intended to be mounted: links are temporary by design. They survive an in-place container restart, but are lost when the container is recreated (image update, replica reschedule).

⁠Security notes

  • Set DRAWIO_MCP_BEARER_TOKEN whenever /mcp is reachable from an untrusted network.
  • DRAWIO_MCP_PUBLIC_BASE_URL must resolve for end users' browsers. If the service sits behind a reverse proxy or gateway, set it to the externally visible base URL and route /d/* through to this service.

⁠Limitations

  • Short links are temporary (see storage section).
  • Single replica, due to the local sqlite store.

⁠Build and run without Docker

You need Node.js 22 or newer. Install the two packages globally, then start the server:

npm install -g @drawio/[email protected] [email protected]
node server.js

⁠Credits

⁠Source code

⁠License

MIT

Tag summary

Content type

Image

Digest

sha256:f850724c9…

Size

72.1 MB

Last updated

3 days ago

docker pull edgaras0x4e/drawio-mcp-http