MCP Local Context
A simple MCP server for local documentation with RAG capabilities, enabling AI assistants to access and search local documents.
README
MCP Local Context
A simple MCP server for local documentation with RAG capabilities. This package provides a simple command to install and use the MCP server for Cursor and Claude that can take a list of folders as sources.
This MCP (Model-Context-Protocol) server provides access to local documents stored in source folders, making it easy for AI assistants to access your library documents.
Features
- Local Document Access: Serves document files from your local source folders
- Multiple Source Folders: Configure multiple source directories for your documents
- Document Type Classification: Automatically categorizes documents as documentation, guides, or conventions
- Type-Based Filtering: Search and retrieve documents by specific type
- Semantic Search: Find documents based on meaning, not just keywords
- RAG Implementation: Uses vector embeddings for document similarity and relevance ranking
- Directory Listing: List all available document files
- Works Offline: No external API calls - everything is served locally
Installation
Requirements
- Python 3.10+
- An MCP-compatible client (Cursor, Claude Desktop, etc.)
Using pip (recommended)
# Install from PyPI
pip install mcp-local-context
# Run the server
mcp-local-context
To install with RAG capabilities (recommended for semantic search):
pip install "mcp-local-context[rag]"
Or install directly from GitHub:
pip install git+https://github.com/steedmonteiro/mcp-local-context.git
Document Organization
Prepare your document files (Markdown, MDX, and text files are supported) and organize them by type:
- Documentation: Technical reference material (API docs, class references, etc.)
- Guides: How-to content and tutorials
- Conventions: Standards, rules, and best practices
Running the Server
After installing the package, you can run the server with the mcp-local-context command:
# Run with default 'sources' directory
mcp-local-context
# Run with multiple source directories
mcp-local-context docs api-docs specs
# Run with custom host and port
mcp-local-context --host 0.0.0.0 --port 9000
# Run in development mode with the MCP Inspector
mcp-local-context --dev
# Install the server in Claude Desktop
mcp-local-context --install
This will:
- Create the specified source directories if they don't exist
- Classify your documents by type (documentation, guides, conventions)
- Build the search index from your document files (if RAG is installed)
- Start the MCP server (default: http://127.0.0.1:8000/mcp)
Testing
You can run the tests using the test runner script:
# Run all tests
python run_tests.py
# Run a specific test
python run_tests.py --test doc_types
python run_tests.py --test client
python run_tests.py --test mcp_sdk
# Start the server before running tests
python run_tests.py --server
Configuration
Configure for MCP clients
Add to your MCP client configuration file:
<details> <summary>Cursor Configuration</summary>
Add the following to your Cursor ~/.cursor/mcp.json file:
"mcpServers": {
"local-docs": {
"url": "http://127.0.0.1:8000/mcp"
}
}
Or use the command-based configuration with pip installation:
"mcpServers": {
"local-docs": {
"command": "mcp-local-context"
}
}
Or use the command-based configuration with manual installation:
"mcpServers": {
"local-docs": {
"command": "./install.sh",
"args": ["--all"],
"cwd": "/path/to/mcp-local-context"
}
}
</details>
<details> <summary>Claude Desktop Configuration</summary>
Add this to your Claude Desktop claude_desktop_config.json file:
"mcpServers": {
"local-docs": {
"url": "http://127.0.0.1:8000/mcp"
}
}
Or use the command-based configuration with pip installation:
"mcpServers": {
"local-docs": {
"command": "mcp-local-context"
}
}
Or use the command-based configuration with manual installation:
"mcpServers": {
"local-docs": {
"command": "./install.sh",
"args": ["--all"],
"cwd": "/path/to/mcp-local-context"
}
}
</details>
<details> <summary>VS Code Configuration</summary>
Add this to your VS Code MCP config file:
"servers": {
"LocalDocs": {
"type": "streamable-http",
"url": "http://127.0.0.1:8000/mcp"
}
}
</details>
<details> <summary>Cline Configuration</summary>
Add this to your Cline configuration file:
"mcpServers": {
"local-docs": {
"url": "http://127.0.0.1:8000/mcp"
}
}
Or use the command-based configuration with pip installation:
"mcpServers": {
"local-docs": {
"command": "mcp-local-context"
}
}
Or use the command-based configuration with manual installation:
"mcpServers": {
"local-docs": {
"command": "./install.sh",
"args": ["--all"],
"cwd": "/path/to/mcp-local-context"
}
}
</details>
Configuring Source Directories
By default, documents are stored in a sources/ directory in the project folder. You can customize the source directories using command-line arguments or environment variables:
# Using command-line arguments with manual installation
./install.sh --all docs api-docs specs
# Using command-line arguments with pip installation
mcp-local-context --sources docs api-docs specs
# Using environment variables with manual installation
SOURCE_DIRS="docs api-docs specs" ./install.sh --all
# Using environment variables with pip installation
SOURCE_DIRS="docs api-docs specs" mcp-local-context
Usage
Once configured, you can use the following tools in your AI assistant:
1. List Local Documents
To see all available document files:
list_local_docs
This will return a list of all document files in your configured source folders.
2. List Documents by Type
To see all documents of a specific type:
list_docs_by_type doc_type="guide"
Replace "guide" with the document type you want to list ("documentation", "guide", or "convention").
3. Search Local Documents (Path-based)
To search for specific document files by path:
search_local_docs query="component"
Replace "component" with your search term. This will return a list of files that match your query in their path.
You can also filter by document type:
search_local_docs query="component" doc_type="documentation"
4. Semantic Search (Content-based)
To search for documents based on meaning and content:
semantic_search query="How to create a responsive layout"
This uses RAG to find the most relevant documents based on the semantic meaning of your query, not just keyword matching. It returns excerpts from the most relevant documents.
You can specify the maximum number of results and filter by document type:
semantic_search query="How to handle events" max_results=10 doc_type="guide"
5. Get Document Content
To retrieve the content of a specific document file:
get_local_doc file_path="app-studio/README.md"
Replace "app-studio/README.md" with the path to the document file you want to access. The response will include the document's content and its type.
6. Build Document Index
If you've added new documents or updated existing files, you can rebuild the search index:
build_docs_index
This processes all document files, classifies them by type, and creates a new search index for semantic search.
Adding Your Own Documents
Simply add your Markdown, MDX, or text files to your configured source folders. The server will automatically detect, classify, and serve them.
Document Type Classification
The server automatically classifies documents based on their content and file path:
- Documentation: Technical reference material (default type if no other type is detected)
- Guides: Files with "guide" in the path or title, or content that appears to be instructional
- Conventions: Files with "convention" in the path or title, or content related to standards/rules
Organization Tips
For better organization and more accurate classification:
- Use descriptive file names that indicate the document type (e.g., "api-reference.md" for documentation, "getting-started-guide.md" for guides)
- Organize files in subdirectories by type (e.g.,
/docs/guides/,/docs/conventions/) - Use separate source directories for different projects or document categories
- Include clear headings in your documents that indicate their purpose
Environment Variables
The server can be configured using the following environment variables:
SOURCE_DIRS: Comma-separated list of source directories (e.g., "docs,api-docs,specs")MCP_HOST: Host to run the server on (default: 127.0.0.1)MCP_PORT: Port to run the server on (default: 8000)MCP_PATH: Path for the MCP endpoint (default: /mcp)
Development
Setting Up Development Environment
Clone the repository and install development dependencies:
# Clone the repository
git clone https://github.com/steedmonteiro/mcp-local-context.git
cd mcp-local-context
# Install dependencies using the installation script
./install.sh --install
# Or install in development mode using pip
pip install -e .
Modifying the Server
The main server code is in docs_server.py. After making changes, restart the server to apply them.
Command-Line Options
The server supports the following command-line options:
--sources: List of source folders to index (default: sources)--host: Host to run the server on (default: 127.0.0.1)--port: Port to run the server on (default: 8000)--path: Path for the MCP endpoint (default: /mcp)
Installation Script Options
The installation script (install.sh) supports the following options:
-h, --help: Show help message-i, --install: Install dependencies-r, --run [source_dirs]: Run the server with specified source directories-a, --all [source_dirs]: Install dependencies and run the server (one-step setup)--host [hostname]: Host to run the server on (default: 127.0.0.1)--port [port]: Port to run the server on (default: 8000)--path [path]: Path for the MCP endpoint (default: /mcp)
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。