MCP MDAST Server
Parses Markdown into MDAST and provides tools to query, insert, update, remove, replace, transform, and analyze document nodes using CSS-like selectors, with input from inline text, files, URLs, or MDAST resources and output to text, files, or reusable MDAST resources.
1. Click on "Deploy Server".
2. Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
3. In the chat, type `@` followed by the MCP server name and your instructions, e.g., "\@MCP MDAST Server select all h2 headings from this markdown\: \# Title
## Section"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a [step-by-step guide with screenshots](https://glama.ai/blog/2025-07-08-how-to-install-and-use-mcp-servers).MCP MDAST Server
Markdown抽象構文木(MDAST)を操作するためのModel Context Protocol (MCP) サーバー。 DOMのようなマニピュレーションAPIと、CSS風セレクタによる直感的なノード選択を提供します。
特徴
🎯 CSS風セレクタ:
heading[depth="1"]、paragraph > strongのような直感的な選択🔧 統合操作: select、insert、update、remove、replaceを1つのツールで
📊 分析機能: 文書構造、統計、目次生成など
💾 柔軟なI/O: ファイル、URL、MDASTリソースからの入出力に対応
🔄 リソース管理: MDASTツリーをリソースとして保存・再利用可能
⚡ 高性能: unified/remarkエコシステムによる高速処理
🎨 柔軟な変換: カスタム変換ロジックの適用
Related MCP server: Markdown Editor MCP Server
インストール
npm install
npm run build使用方法
MCPサーバーとして起動
node dist/index.jsMCP Inspectorでテスト
npm run inspectorClaude Desktopでの設定
claude_desktop_config.jsonに以下を追加:
{
"mcpServers": {
"mdast": {
"command": "node",
"args": ["/path/to/mcp-mdast/dist/index.js"]
}
}
}ツール
1. mdast-query
Markdownを解析し、CSS風セレクタでクエリ・操作を行う統合ツール。
入力オプション:
インラインMarkdown:
markdown: "# Title"ファイル:
markdown: {"source": "file", "path": "/path/to/file.md"}URL:
markdown: {"source": "url", "url": "https://example.com/doc.md"}MDASTリソース:
markdown: {"source": "mdast", "uri": "mdast://..."}
出力オプション:
テキスト(デフォルト):
output: {"type": "text"}ファイル:
output: {"type": "file", "path": "/path/to/output.md"}MDASTリソース:
output: {"type": "mdast", "ttl": 3600}
操作例:
// 見出しの選択
{
markdown: "# Title\n## Section",
operation: "select",
selector: "heading[depth=\"2\"]"
}
// コンテンツの挿入
{
markdown: "# Title\nContent",
operation: "insert",
selector: "heading[depth=\"1\"]",
content: "## New Section\n\nNew content.",
position: "after"
}
// ノードの更新
{
markdown: "Old text",
operation: "update",
selector: "paragraph",
content: "New text"
}
// ノードの削除
{
markdown: "# Title\n- item1\n- item2",
operation: "remove",
selector: "list"
}2. mdast-transform
カスタム変換ロジックを適用。
変換タイプ:
wrap: ノードをラッパーで囲むunwrap: ラッパーを削除rename: ノードタイプを変更(headingのdepth変更にも対応)clone: ノードを複製
// 見出しレベルの変更
{
markdown: "## Level 2",
transforms: [{
type: "rename",
selector: "heading[depth=\"2\"]",
newType: "heading",
depth: 3
}]
}
// ノードをblockquoteで囲む
{
markdown: "# Title\n\nParagraph",
transforms: [{
type: "wrap",
selector: "paragraph",
wrapper: "blockquote"
}]
}3. mdast-analyze
文書構造の分析と統計情報の取得。
{
markdown: "# Title\n\n## Section 1\n\n[Link](url)",
analysis: ["stats", "headings", "links", "toc"]
}CSS風セレクタ
基本セレクタ
heading- すべてのheading要素paragraph- すべてのparagraph要素link,image,code,list, etc.
属性セレクタ
heading[depth="1"]- h1見出しのみlink[url^="https"]- httpsで始まるリンクcode[lang="javascript"]- JavaScript言語のコードブロック
構造セレクタ
paragraph > strong- 段落の直下の太字list listItem- リスト内のアイテムblockquote paragraph- 引用内の段落
疑似セレクタ
:first-child- 最初の子要素:last-child- 最後の子要素:nth-child(n)- n番目の子要素
アーキテクチャ
詳細な設計についてはDESIGN.mdを参照してください。
ライセンス
MIT
Available Tools
3 toolsmdast-analyzeB
Analyze document structure and retrieve statistics. Supports structure/stats/links/headings/toc analysis. Input: text/file/url/mdast
Inputs: analysis, markdown.
mdast-queryB
Parse Markdown to MDAST and perform query/manipulation operations with CSS-style selectors. Supports select/insert/update/remove/replace operations. Input: text/file/url/mdast, Output: text/file/mdast
Inputs: operation (required), index, output, content, +3 more.
mdast-transformC
Apply custom transformation logic. Supports wrap/unwrap/rename/clone operations. Input: text/file/url/mdast, Output: text/file/mdast
Inputs: transforms (required), output, markdown.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
mdast-analyze is clearly distinct (read-only inspection), but mdast-query and mdast-transform overlap: query supports update/remove/replace while transform supports rename/clone/wrap/unwrap, which can look like alternative ways to accomplish similar edits. The CSS-selector vs. custom-logic framing helps, but agents may still hesitate between the two manipulation tools.
All three tools follow a single predictable pattern: shared mdast- prefix plus a concise action verb (analyze/query/transform). Kebab-case is used uniformly with no mixing of conventions.
Three tools is on the low end but each is a broad, multi-operation entry point covering a distinct phase of the workflow (inspect, query/edit, transform). The consolidation is reasonable, though slightly finer segmentation might reduce overlap between query and transform.
The surface covers analysis, selection-based querying/manipulation, and structural transformations, with flexible text/file/url/mdast inputs and text/file/mdast outputs. Coverage is solid for an MDAST toolset; only niche operations like validation or specialized serialization are not explicitly represented.
Maintenance
Related MCP Connectors
Strips 85-97% of HTML/DOM bloat into clean Markdown or JSON with cryptographic ROI proof.
Generate PDF, Word (.docx) and PowerPoint (.pptx) documents from Markdown over MCP.
Convert Markdown to PDF, DOCX, HTML or EPUB with formatting and display options.
Markdown workspace for AI agents: read, write, organize, and share markdown documents.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides powerful Markdown document editing capabilities with thread-safe operations, atomic transactions, and comprehensive validation.104MIT
- AlicenseCqualityNot gradedmaintenanceProvides semantic editing tools for Markdown files, allowing structured manipulation of document elements through hierarchical paths rather than raw text operations. Supports navigation, search, content replacement, element insertion/deletion, undo functionality, and YAML frontmatter management.152MIT
- AlicenseAqualityCmaintenanceEnables AI agents to read, write, append, and delete content in Markdown files using structural selectors, without regex or string hacking.723 npm5MIT
- FlicenseNot gradedqualityCmaintenanceEnables querying and modifying Markdown documentation as a relational database using SQL, with automatic write-back of changes to the original .md files.-