markmap-mcp-server
AGENTS.md289 starsChanged 4 months agoMITView on GitHub
This file provides guidance to agents when working with code in this repository. This is an MCP server (Model Context Protocol) that converts Markdown to interactive mind maps using the markmap family of libraries. It runs over stdio transport. The server's returnMode controls what the MCP client receives: The server's open setting controls whether the browser opens:
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 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
1 rule. About 0 are common, 0 are distinctive, and 1 is 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.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 76
Tests: use vitest with describe/it/expect in tests/unit/.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 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.
Files
AGENTS.md
This file provides guidance to agents when working with code in this repository.
Commands
# Build (TypeScript → build/)
npm run build
# Run tests
npm test # vitest run (single pass)
npm run test:watch # vitest in watch mode
# Development
npm run dev # tsc-watch → auto-restart on changes
# Formatting
npm run format # prettier --write (also runs via lint-staged on commit)
# Run the server locally
node build/index.js
# With options:
node build/index.js --output /tmp/markmap --open always --return-mode both --offlineArchitecture
This is an MCP server (Model Context Protocol) that converts Markdown to interactive mind maps using the markmap family of libraries. It runs over stdio transport.
Entry point: src/index.ts
- Parses CLI args (
minimist) and env vars into aMarkmapMcpContext(output dir, open mode, return mode, offline flag) - Creates an
McpServerinstance, registers tools viaregisterMarkmapTools(), and connects toStdioServerTransport
Tool registration: src/mcp/tools/
context.ts— Type definitions forMarkmapMcpContext,OpenMode("always" | "never" | "agent"),ReturnMode("path" | "content" | "both")registry-base.ts— AbstractRegistryBasewithregister()methodtool-registry.ts—ToolRegistry extends RegistryBase, addsregisterTools()wrappermarkmap-tools.ts—MarkmapToolRegistryimplements 4 tools and 1 prompt:markdown_to_mindmap— main conversion tool (html/png/svg/jpg)list_mindmaps— list generated filesget_mindmap— retrieve a single file by path (with path traversal protection)cleanup_mindmaps— delete old/all filesmindmap_from_content— prompt that asks the LLM to structure content before calling the tool
Core markmap logic: src/markmap/
createMarkmap.ts— Usesmarkmap-lib(Transformer) andmarkmap-render(fillTemplate) to convert Markdown → HTML. Injects themarkmap-toolbar, an export toolbar (PNG/JPG/SVG/Copy Markdown viahtml-to-image), and the original markdown source. In--offlinemode, inlines all JS/CSS assets.exportImage.ts— Launches headless Chromium via Playwright to render HTML → PNG/JPG/SVG. Requiresplaywrightoptional dependency.lifecycle.ts— File listing, retrieval (with path traversal check), and cleanup for the output directory.escape.ts— HTML/text escaping for safe embedding.i18n.ts— English toolbar labels used in the generated HTML.
Return mode system
The server's returnMode controls what the MCP client receives:
path—{htmlFilePath, filePath}JSON onlycontent— Inline HTML (text) or base64 image block; falls back to paths if HTML ≥ 200KBboth— Paths JSON + inline content
Open mode system
The server's open setting controls whether the browser opens:
always/never— fixed server-sideagent— theopenparameter is exposed on the tool, letting the LLM decide per call
Key patterns
- Tool registry pattern:
RegistryBase→ToolRegistry→MarkmapToolRegistry. Each tool is registered in its ownregister*()method. - Server config is set at startup (CLI/env), not per-tool-call. The tool description text adapts to the server's configuration.
- File naming: Generated files are prefixed with
markmap-solist_mindmapsandcleanup_mindmapscan discover them. - Tests use vitest with
describe/it/expectintests/unit/. Tests import from../../src/directly (no path aliases). - No eslint config file — the project uses
eslint.config.js(flat config format) with TypeScript ESLint and Prettier integration. - Husky + lint-staged runs prettier and eslint on staged files pre-commit.
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
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.

