Skip to main content

MCP server for hardware documentation search and management

Project description

hwdocs-mcp

MCP (Model Context Protocol) 服务器,为 Cursor、Claude Desktop 等 AI 编辑器提供文档解析和语义搜索能力。

特性

  • PDF 解析:将 PDF、DOCX 等文档解析为可搜索的 Markdown(通过 LlamaIndex Cloud)
  • 语义搜索:使用本地 embeddings 进行语义关键词搜索(免费)
  • Workspace 缓存:缓存 embeddings 加速重复搜索
  • 配额管理:追踪和管理文档解析配额
  • AI 编辑器集成:支持 Cursor、Claude Desktop 等 MCP 兼容编辑器

安装

pip install hwdocs-mcp

同时需要安装 semtools CLI:

npm install -g @llamaindex/semtools

快速开始

1. 配置编辑器

Cursor (~/.cursor/mcp.json):

{
  "mcpServers": {
    "hwdocs": {
      "command": "hwdocs-mcp"
    }
  }
}

Claude Desktop (~/.claude/claude_desktop_config.json):

{
  "mcpServers": {
    "hwdocs": {
      "command": "hwdocs-mcp"
    }
  }
}

2. 登录(可选,用于配额管理)

hwdocs login --token YOUR_TOKEN

3. 在 AI 编辑器中使用

用户: "解析 docs 文件夹里的 PDF 文件"
AI: → parse_documents(files=["./docs"], pattern="*.pdf")

用户: "搜索 PWM 配置相关的内容"
AI: → search_parsed(query="PWM configuration")

用户: "根据搜索结果写一个定时器初始化函数"
AI: → 生成代码...

可用工具

工具 说明 配额消耗
parse_documents 解析文档为 Markdown,支持目录和通配符 ✅ 是
search_documents 搜索指定文件,支持目录和通配符 ❌ 否(本地)
search_parsed 搜索所有已解析的文件 ❌ 否(本地)
list_parsed 列出所有已解析的文件 ❌ 否
manage_workspace 管理 workspace 缓存 ❌ 否
get_quota 查询剩余配额 ❌ 否

工具参数示例

parse_documents

parse_documents(
    files=["./docs", "*.pdf", "report.docx"],  # 支持目录、通配符、具体文件
    pattern="*.pdf"  # 可选,过滤文件类型
)

search_parsed

search_parsed(
    query="timer interrupt, PWM",  # 关键词搜索效果最好
    filter="MCU",                   # 可选,按文件名过滤
    top_k=5,                        # 返回结果数
    n_lines=30,                     # 上下文行数(建议 30-50)
    ignore_case=True                # 大小写不敏感(推荐)
)

manage_workspace

# 创建/选择 workspace(后续搜索自动使用)
manage_workspace(action="use", name="my_project")

# 查看状态
manage_workspace(action="status")

# 清理过期文件
manage_workspace(action="prune")

使用场景

电机控制软件开发

1. 解析芯片数据手册
   → parse_documents(files=["FU6816_datasheet.pdf"])

2. 搜索寄存器配置
   → search_parsed(query="PWM timer register")

3. AI 根据手册生成代码
   → 生成符合规范的 C 代码

API 文档查询

1. 解析 API 文档
   → parse_documents(files=["./api_docs"], pattern="*.pdf")

2. 搜索接口说明
   → search_parsed(query="authentication, API key")

3. AI 生成调用代码

配置

配置文件位置:~/.hwdocs/config.json

{
  "api_token": "your_token_here",
  "api_base": "https://api.hwdocs.dev"
}

依赖

  • Python 3.10+
  • semtools CLI (npm install -g @llamaindex/semtools)
  • MCP 兼容的 AI 编辑器(Cursor、Claude Desktop 等)

开发

# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
pytest

# 代码格式化
ruff format
ruff check --fix

详细开发文档见 DEVELOPMENT.md

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hwdocs_mcp-0.1.2.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hwdocs_mcp-0.1.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file hwdocs_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: hwdocs_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for hwdocs_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 89030f775c28d73b716893b45ee5b996601c3455d2c9b35986cf8b5ab4eef5a0
MD5 14a4b115f3d069f0ce14578ab204a501
BLAKE2b-256 f28610e0a6aef6d9e9ee7ca3a17e7bbe84d5bcf459b0301ded16e7f029f0422d

See more details on using hashes here.

File details

Details for the file hwdocs_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hwdocs_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for hwdocs_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 35c5650aa443b562207b844b49f9ef02764641e0fa74aefa882de412e241cee2
MD5 0c58fa984111a947e68fdb9a7ce134f5
BLAKE2b-256 ee7eceba2e508d64d3408fc85c43d0cec6674856aa0bee6d20dd7f78044ac604

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page