Skip to main content
Glama

mdgraph

将仓库的 markdown 扫描成图,在浏览器中可视化,并作为导航索引暴露给 Claude(或任何 MCP 主机)。

一个数据模型 — { nodes, edges } — 对应三个消费方:

              scan  (the only hard part)
                 │  emits { nodes, edges }
      ┌──────────┼───────────┐
      ▼          ▼           ▼
   graph.json  browser     MCP server
   (a file)   (viewer)   (agents read it)

洞察、可达性和孤立文档都是在读取时从模型派生的。节点和边保持简单。

The model

node = { id, label, path, type, cluster, content }   // type: root | ai | doc
edge = { source, target, sourceLine, context }        // context = the line the link lives on

type 由文件名约定分配(README.md → root,CLAUDE.md/AGENTS.md/*.mdc → ai,其余为 doc)。边来自文本中的实际链接——标准 [x](./y.md)[[wikilinks]]——而不是文件夹归属,因此 docs/ 中一个跨树链接的文件仍然能跨树连接。文件夹只驱动 cluster(着色/分组)。

Related MCP server: mcp-server-markdown

安装与运行

无需安装——直接用 npx 运行:

npx @emmd474/mdgraph scan .            # print the graph as JSON
npx @emmd474/mdgraph view .            # open the interactive graph in a browser
npx @emmd474/mdgraph scan . --out graph.json

或者全局安装,获得一个简单的 mdgraph 命令:

npm install -g @emmd474/mdgraph
mdgraph view ./my-repo
mdgraph scan ./my-repo --out graph.json

dir 默认为当前目录。view 接受 --port(默认 4173)。

命令

Command

What it does

mdgraph scan [dir]

构建图,将 JSON 打印到 stdout(或使用 --out 写入文件)。

mdgraph view [dir]

localhost:4173 提供交互式图;刷新时重新扫描。

mdgraph mcp [dir]

通过 stdio 运行 MCP 服务器,供 Claude 和其他智能体使用。

暴露给 Claude(MCP)

Claude Desktop — 添加到 claude_desktop_config.json

{
  "mcpServers": {
    "mdgraph": {
      "command": "npx",
      "args": ["-y", "@emmd474/mdgraph", "mcp", "/abs/path/to/your/repo"]
    }
  }
}

Claude Code:

claude mcp add mdgraph -- npx -y @emmd474/mdgraph mcp /abs/path/to/your/repo

重启主机后,Claude 会获得四个工具:

Tool

Purpose

get_project_map

无内容概览:类型、集群、链接数、孤立/可达标志、边。这是了解全局的低成本方式。

read_doc

按路径返回单个文档的原始 markdown。

get_context

从入口文档可达的所有内容,按阅读顺序排列——正是理解它所需加载的精确集合。includeContent: true 会附带 markdown 内容。

find_orphans

没有任何链接指向的文档。

关键在于:智能体先调用 get_project_map 定位,再调用 get_context("README.md") 只拉取任务所需的文档——而不是把每个 .md 都倒进上下文。

发布(面向维护者)

mdgraph 这个名字在 npm 上已被占用,因此本包以作用域包的形式发布到你的账户下:

# 1. set the scope to YOUR npm username (edit "name" in package.json if not @emmd474)
npm whoami          # confirm you're logged in; else: npm login
npm publish --access public

作用域包默认是私有的,因此第一次需要 --access public。要发布更新,请升级版本号并重新发布:

npm version patch   # 0.1.0 -> 0.1.1, also creates a git tag
npm publish

npm pack --dry-run 会精确显示发布内容(目前 7 个文件,约 16 kB——没有 node_modules,没有测试仓库,这要归功于 files 允许列表)。

在示例上试试

git clone <this repo> && cd mdgraph && npm install
node cli.mjs view testrepo
node cli.mjs scan testrepo

已实现与下一步

已测试并可用:扫描器(md + wikilink 提取、代码围栏跳过、约定类型识别、孤立文档检测)、浏览器查看器,以及通过实时 stdio 握手运行的全部四个 MCP 工具。

接下来,大致按顺序:

  • 强化链接解析 — 扫描器基于行并跳过围栏代码块,但行内代码跨度(`[x](y)`)仍可能产生虚假链接。当你需要精确性时,换用真正的 markdown AST(remark + unist-util-visit);输出的结构保持不变。

  • 手动边 — 让查看器将 related: 写入文件的 frontmatter,作为第三种边来源读取。

  • Frontmatter 标签 与文件夹一起作为集群来源。

  • view 上增加 --watch,通过服务器发送事件推送图更新。

MIT 许可。

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Markdown utilities MCP.

  • MCP server for AgentDocs (agentdocs.eu): read, search, write, comment on & share Markdown docs.

  • Turn a GitHub repo or docs site into agent-ready context: pack it or search it, over MCP.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/EMMD474/mdgraph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server