npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-mdast

v0.1.2

Published

MCP server for manipulating Markdown Abstract Syntax Trees (MDAST) with CSS-style selectors. Provides query, transform, and analyze operations via the Model Context Protocol.

Readme

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エコシステムによる高速処理
  • 🎨 柔軟な変換: カスタム変換ロジックの適用

インストール

npm install
npm run build

使用方法

MCPサーバーとして起動

node dist/index.js

MCP Inspectorでテスト

npm run inspector

Claude 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