本地文档搜索服务

这是一个将本地文档目录索引到 LanceDB 向量存储,并通过 Amazon Bedrock Titan 嵌入模型提供语义搜索功能的 MCP 服务,为 Claude Code 提供文档搜索和统计工具。

  • by mscheren
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 mscheren/local-docs-mcp

使用说明

bedrock-local-docs-mcp

Indexes a documentation directory into a local LanceDB vector store using Amazon Bedrock Titan embeddings, and exposes the index to Claude Code as an MCP server with two tools: docs_search and docs_stats.

Prerequisites

  • uv — dependency and environment management
  • AWS credentials — default profile with Bedrock access in the chosen region

Environment variables

All variables must be set before running the indexer or the MCP server.

Variable Default Description
AWS_REGION — AWS region, must be us-east-1
AWS_PROFILE default AWS CLI profile to use
BEDROCK_EMBED_MODEL_ID amazon.titan-embed-text-v2:0 Bedrock embedding model
BEDROCK_EMBED_DIMS 1024 Embedding dimensions
DOCS_DIR — Root directory to index, e.g. ~/claude_docs
INDEX_DIR — LanceDB storage path, e.g. ~/.local/bedrock_docs_lancedb
TABLE_NAME docs LanceDB table name

Building the index

Makefile targets set all environment variables from their defaults (see table above) and invoke the indexer. Override any variable on the command line as needed.

Full rebuild — drops the existing table and re-indexes all documents:

make index-rebuild

Incremental update — appends documents not yet in the index (faster on subsequent runs):

make index-update

To override a default, pass the variable inline:

make index-rebuild DOCS_DIR=/some/other/path

The indexer prints a summary line on completion, e.g.: Indexed 42 files; added 187 chunks.

TLS configuration

uv.toml sets native-tls = true so that uv uses the OS trust store for all package downloads. This is necessary behind a corporate firewall.

MCP server

The MCP server is registered as a user-scoped server in ~/.claude.json and starts automatically when Claude Code launches. No manual action is required after the initial setup.

To verify the server is running, use /mcp inside a Claude Code session — bedrock-local-docs should appear as connected.

Available tools

Tool Description
docs_search Semantic search; returns top-k chunks with file path and excerpt
docs_stats Returns row count, model name, and embedding dimensions

Packaged Claude skill

The search and listing functionality is also distributed as a Claude skill, local-docs-search, which has superseded the MCP server for day-to-day use. The packaged skill lives in this directory as local-docs-search.skill. It bundles thin wrapper scripts that reuse this repository's uv environment, so the index still needs to be built here (see Building the index).

A .skill file is a zip archive containing a single local-docs-search/ folder. Claude Code discovers user skills under ~/.claude/skills/, so "unpacking" the skill means extracting that folder there.

Unpack / install:

unzip -o local-docs-search.skill -d ~/.claude/skills/

This creates ~/.claude/skills/local-docs-search/. Restart Claude Code (or start a new session) so the skill is picked up; it then appears in the available skills list and triggers on documentation-search requests.

Verify the contents before unpacking (optional):

unzip -l local-docs-search.skill

Update an existing install — the -o flag above overwrites in place, so re-running the unzip after repackaging is sufficient. To remove the skill, delete the ~/.claude/skills/local-docs-search/ directory.