document-mcp

document-mcp

Enables AI agents to efficiently manage and update component documentation with precise partial updates, saving up to 75% tokens compared to full rewrites.

Category
访问服务器

README

Document MCP Server

A Model Context Protocol (MCP) server designed to efficiently manage component documentation with AI-powered updates and token optimization.

Features

  • 🚀 Component Scanning: Automatically scan project components folder and generate structured information
  • 🔐 MD5 Hashing: Generate MD5 hashes for files to track changes
  • 📋 Component Queries: Quickly retrieve specific component details
  • ✏️ Precision Updates: Update only description or props sections, saving significant tokens
  • 🤖 AI-Friendly: Structured updates prevent AI hallucinations and unnecessary modifications
  • 📊 Token Optimization: Save ~75% tokens compared to traditional full-file regeneration

Installation

NPM Package

# Install globally
npm install -g @tianyi-li/document-mcp

# Install as project dependency
npm install @tianyi-li/document-mcp

Development Setup

# Clone and setup
git clone https://github.com/TianyiLi/document-mcp.git
cd document-mcp
pnpm install
pnpm run build

Quick Start

1. Basic Usage

# Run the MCP server
document-mcp

# Or use npx/pnpx
npx @tianyi-li/document-mcp

2. IDE Integration

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "document-mcp": {
      "command": "npx",
      "args": ["@tianyi-li/document-mcp"]
    }
  }
}

Claude Code

Option 1: Through Claude Desktop (Automatic)

Claude Code automatically detects MCP servers configured in Claude Desktop - no additional setup required.

Option 2: Direct CLI Configuration

Configure directly via Claude Code CLI:

# Using npx (recommended)
claude mcp add document-mcp -- npx @tianyi-li/document-mcp

# Using global installation
claude mcp add document-mcp -- document-mcp

# List configured servers
claude mcp list

# Remove if needed
claude mcp remove document-mcp
Project Documentation (CLAUDE.md)

Add to your project's CLAUDE.md for team reference:

# Document MCP Server

This project uses Document MCP Server for efficient component documentation management.

## Setup
```bash
# Quick setup
npm install -g @tianyi-li/document-mcp
claude mcp add document-mcp -- document-mcp

Available Tools

  • init_components - Scan all project components
  • get_component_info - Get specific component details
  • update_component_description - Update description only (saves ~75% tokens)
  • update_component_props - Update props only (saves ~75% tokens)
  • update_component_content - Batch update multiple sections
  • compare_md5 - Verify file changes

Workflow

  1. init_components → Understand project structure
  2. update_component_* → Make targeted updates
  3. compare_md5 → Verify changes

## API Reference

### Reading Tools

#### `init_components`
Scan components folder and generate structured JSON data.

**Parameters:**
- `projectRoot` (optional): Project root path, defaults to current directory

**Returns:**
```json
[
  {
    "name": "Button",
    "path": "components/Button", 
    "description": "A reusable button component",
    "props": "Props information",
    "md5": "a1b2c3d4e5f6..."
  }
]

get_component_info

Get detailed information for a specific component.

Parameters:

  • componentName (required): Component name
  • projectRoot (optional): Project root path

Returns: Single component JSON object

Update Tools ⭐ Core Value

update_component_description

Precisely update component description section - best choice for token saving.

Parameters:

  • componentName (required): Component name
  • description (required): New component description
  • projectRoot (optional): Project root path

Usage: AI agents can update only the description section without regenerating entire files

update_component_props

Precisely update component Props section with Markdown table support.

Parameters:

  • componentName (required): Component name
  • props (required): New Props content (supports Markdown format)
  • projectRoot (optional): Project root path

Example Props Format:

| Property | Type | Required | Default | Description |
|----------|------|----------|---------|-------------|
| variant | "primary" \| "secondary" | No | "primary" | Button style |
| size | "small" \| "medium" \| "large" | No | "medium" | Button size |
| disabled | boolean | No | false | Whether disabled |

update_component_content

Batch update component description and/or Props with partial update support.

Parameters:

  • componentName (required): Component name
  • description (optional): New component description
  • props (optional): New Props content
  • projectRoot (optional): Project root path

Usage: Can update multiple sections simultaneously or individually

Validation Tools

calculate_md5

Calculate MD5 hash for specified file.

Parameters:

  • filePath (required): File path for MD5 calculation

Returns: MD5 hash string

compare_md5

Compare current file MD5 with expected value.

Parameters:

  • filePath (required): File path to check
  • expectedMd5 (required): Expected MD5 hash value

Returns:

{
  "currentMd5": "current file MD5",
  "expectedMd5": "expected MD5", 
  "isMatch": true/false,
  "hasChanged": true/false
}

Use Cases

Reading Phase

  1. Automated Documentation Management: AI agents quickly understand project component structure
  2. Component Information Queries: Avoid scanning entire project structure, saving tokens
  3. File Change Tracking: Ensure document content consistency through MD5 comparison

Update Phase ⭐ Core Value

  1. Precision Document Updates: Update only necessary parts (description or Props), dramatically saving tokens
  2. Prevent AI Hallucinations: Structured updates avoid AI adding/removing unnecessary items
  3. Incremental Maintenance: Modify based on existing content rather than complete rewrites
  4. Consistency Guarantee: Use standard templates and formats for unified document style

Workflow Example

1. init_components          → Understand all components
2. get_component_info       → Get specific component current state
3. update_component_description → Update only description section
4. compare_md5              → Verify update success

Token Savings

  • Traditional Method: AI reads full file + regenerates complete file = ~2000 tokens
  • Using This Tool: Get existing info + precise partial updates = ~500 tokens
  • Savings Rate: ~75% token reduction

Project Structure

This tool assumes your project has the following structure:

project-root/
├── components/
│   ├── Button/
│   │   └── README.md
│   ├── Input/
│   │   └── README.md
│   └── ...
└── ...

Each component folder should contain a README.md file with component description and props information.

Configuration Examples

Using pnpx/npx (Recommended)

{
  "mcpServers": {
    "document-mcp": {
      "command": "pnpx",
      "args": ["@tianyi-li/document-mcp"],
      "cwd": "/path/to/your/project"
    }
  }
}

Direct Binary Execution

{
  "mcpServers": {
    "document-mcp": {
      "command": "/path/to/node_modules/.bin/document-mcp"
    }
  }
}

Global Installation

# Install globally
npm install -g @tianyi-li/document-mcp

# Use in Claude Desktop config
{
  "mcpServers": {
    "document-mcp": {
      "command": "document-mcp"
    }
  }
}

Development

Build from Source

git clone https://github.com/TianyiLi/document-mcp.git
cd document-mcp
pnpm install
pnpm run build

Available Scripts

pnpm run build    # Compile TypeScript
pnpm run dev      # Watch mode compilation
pnpm start        # Run the server

Best Practices

  1. First Use: Run init_components to scan project components
  2. Change Tracking: Use compare_md5 to check for file modifications
  3. Specific Queries: Use get_component_info for individual component details
  4. Regular Sync: Periodically run init_components to keep data current
  5. Token Optimization: Use precise update tools instead of full rewrites

Requirements

  • Node.js >= 18.0.0
  • Components organized in /components folder structure
  • Each component should have a README.md file

License

ISC License

Contributing

Issues and pull requests are welcome on GitHub.

Repository

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选