Markdown资源服务器

一个将Markdown文件作为MCP资源提供的服务器,支持自动发现、内容读取和安全访问,适用于AI助手和开发工具集成。

  • by repr0bated
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 repr0bated/markdown-mcp-server

使用说明

Markdown Resources MCP Server

This MCP server serves markdown files from the /git/agents and /git/commands repositories as MCP resources, making them accessible to AI assistants like Claude and Cursor.

Features

  • Automatic Discovery: Scans and indexes all .md files from agents and commands repositories
  • MCP Resources: Exposes markdown files as resources with URIs like agents://docs/agents.md
  • Content Reading: Allows reading the full content of any markdown file
  • Security: Path traversal protection and restricted directory access

Resource URIs

The server creates resources with the following URI patterns:

  • agents://docs/filename.md - Documentation files in agents/docs/
  • agents://plugins/plugin-name/agents/filename.md - Agent files in plugins
  • agents://plugins/plugin-name/commands/filename.md - Command files in plugins
  • commands://tools/filename.md - Tool files in commands/tools/
  • commands://workflows/filename.md - Workflow files in commands/workflows/

Installation

  1. Ensure Node.js is installed
  2. Copy the server files to your desired location
  3. Configure your MCP client to use this server

Configuration

The server is configured via mcp.json:

{
  "name": "markdown-resources-mcp",
  "version": "1.0.0",
  "description": "MCP server that serves markdown files from agents and commands repositories as resources",
  "server": {
    "command": "node",
    "args": ["/git/markdown-mcp-server/server.js"]
  },
  "capabilities": {
    "resources": {
      "list": true,
      "read": true
    }
  }
}

Usage

Listing Resources

Use the resources/list method to get all available markdown files:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "resources/list",
  "params": {}
}

Reading Resources

Use the resources/read method to get the content of a specific file:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "resources/read",
  "params": {
    "uri": "agents://docs/agents.md"
  }
}

File Discovery

The server automatically scans these directories:

  • /git/agents/ - All markdown files recursively
  • /git/commands/ - All markdown files recursively

It excludes:

  • .git directories
  • node_modules directories
  • Any path starting with .

Security

  • Path traversal attacks are prevented by resolving and validating file paths
  • Access is restricted to the configured base directories
  • Only .md files are served

Statistics

As of the latest scan, the server serves 364 markdown files including:

  • Agent documentation and specifications
  • Command workflows and tools
  • Plugin configurations
  • Architecture guides
  • Usage instructions

Development

To modify or extend the server:

  1. Edit server.js for core functionality
  2. Update mcp.json for configuration changes
  3. Test with the MCP protocol over stdio

Integration

This server integrates with:

  • Claude Desktop
  • Cursor
  • Any MCP-compatible client

Configure your client to launch the server with:

node /git/markdown-mcp-server/server.js