mdsel mcp
用于mdsel markdown选择器CLI的MCP服务器。
安装
npx -y mdsel-mcp先决条件
- Node.js:18.0.0或更高版本
配置
添加到您的Claude Desktop配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mdsel-mcp": {
"command": "npx",
"args": ["-y", "mdsel-mcp"]
}
}
}添加配置后重新启动Claude Desktop。
工具
此MCP服务器提供了一个统一的工具: mdsel
参数:
files(string\[\],必填):markdown文件路径列表selector(string,可选):选择器字符串(逗号分隔为多个)
行为:
- 仅限文件→ 返回索引(具有可用选择器的文档结构)
- 选择器+文件→ 返回所选内容
- 搜索查询+文件→ 当输入看起来不像选择器时的模糊搜索
索引模式(仅文件)
{
"name": "mdsel",
"arguments": {
"files": ["README.md"]
}
}返回文档结构:
h1.0 mdsel-mcp
h2.0 Installation
h2.1 Prerequisites
h2.2 Configuration
---
code:2 para:5 list:3选择模式(选择器+文件)
{
"name": "mdsel",
"arguments": {
"selector": "h2.1",
"files": ["README.md"]
}
}返回所选标题下的内容。
搜索模式(模糊匹配)
当选择器看起来不像选择器语法时,mdsel会执行模糊搜索:
{
"name": "mdsel",
"arguments": {
"selector": "installation",
"files": ["README.md"]
}
}返回具有相关性分数的匹配选择器:
Search results for "installation":
readme::h2.1 (100% match)
Installation使用返回的选择器获取实际内容。
选择器语法
选择器是基于路径的、有序的和0索引的。
[namespace::]type[index][/path]节点类型
| 类型 | 速记 | 描述 |
|---|---|---|
* | * | 整个文档(通配符) |
root | - | 文档根目录 |
heading:h1 ... heading:h6 | h1 ... h6 | 按级别分类的标题 |
block:paragraph | para | 段落 |
block:code | code | 代码块 |
block:list | list | 列表 |
block:table | table | 桌子 |
block:blockquote | quote | 区块链报价 |
索引符号
| 符号 | 示例 | 含义 |
|---|---|---|
| 圆点 | h2.0 | 第一个h2 |
| 支架 | h2[0] | 第一个h2 |
| 范围 | h2.0-2 | h2.0、h2.1、h2.2 |
| 无索引 | h2 | 所有h2标题 |
路径组成
Nest选择器 / 在父级中选择:
h2.1/code.0-第二个h2下的第一个代码块h1.0/h2.0-第一h1下的第一h2
命名空间选择(多个文件)
为多个文件建立索引时,每个文件都有一个命名空间。使用 namespace::selector 针对特定文件:
readme::h2.0-自述文件中的第一个h2h2.0-所有文件中的第一个h2
查询参数
使用查询参数限制输出:
h2.0?head=10-前10行内容h2.0?tail=5-最后5行内容
例子
# Wildcard - entire document
*
# Basic selection
h1.0 # First h1 heading
h2.1 # Second h2 heading
code.0 # First code block
para.2 # Third paragraph
# Ranges
h2.0-2 # First three h2 headings
# Nested paths
h2.1/code.0 # First code block under second h2
h1.0/h2.0 # First h2 under first h1
# Multiple files
readme::h2.0 # First h2 in readme namespace
# Truncation
h2.0?head=10 # First 10 lines发展
npm run build许可证
麻省理工学院
