mcp-rust-docs
Provides access to Rust crate documentation, search, and metadata from docs.rs and crates.io.
README
MCP Rust Documentation Server
This is a Model Context Protocol (MCP) server that provides comprehensive access to Rust crate documentation and metadata, offering essential context for LLMs when working with Rust code.
Features
- Documentation Lookup: Fetches documentation for any Rust crate available on docs.rs
- Crate Search: Search for crates on crates.io with detailed results
- Metadata Retrieval: Get comprehensive metadata for specific crates
- Pagination Support: Handle large documentation with pagination
- Error Handling: Robust error handling with detailed logging
- Session Tracking: Session management for better debugging
- Structured Responses: Well-formatted, structured responses
Architecture
The server follows a modular architecture inspired by AWS MCP server patterns:
mcp-rust-docs/
├── index.js # Entry point (backward compatibility)
├── src/
│ ├── server.js # Main server implementation with tools
│ ├── models.js # Data models and validation schemas
│ └── utils.js # Utility functions and API clients
├── package.json
└── README.md
Tools Available
1. lookup_crate_docs
Fetches and returns documentation for a specific Rust crate from docs.rs.
Parameters:
crateName(required): Name of the Rust crateversion(optional): Specific version (defaults to 'latest')maxLength(optional): Maximum characters to return (default: 8000)startIndex(optional): Starting character index for pagination (default: 0)
Example Usage:
// Basic lookup
lookup_crate_docs({ crateName: "tokio" })
// Specific version with pagination
lookup_crate_docs({
crateName: "serde",
version: "1.0.0",
maxLength: 5000,
startIndex: 0
})
2. search_crates
Search for Rust crates on crates.io with comprehensive results.
Parameters:
query(required): Search query stringlimit(optional): Maximum results to return (1-50, default: 10)
Example Usage:
search_crates({ query: "web framework", limit: 5 })
3. get_crate_metadata
Get detailed metadata for a specific Rust crate from crates.io.
Parameters:
crateName(required): Name of the Rust crate
Example Usage:
get_crate_metadata({ crateName: "axum" })
Installation
# Clone the repository
git clone https://github.com/0xKoda/mcp-rust-docs.git
cd mcp-rust-docs
# Install dependencies
npm install
Prerequisites
- Node.js >= 16.0.0
- npm
Usage
# Start the server
npm start
# Development mode with debugging
npm run dev
# Run tests
npm test
Integrating with AI Assistants
Claude Desktop
Add the following to your Claude Desktop configuration file (claude_desktop_config.json):
{
"mcpServers": {
"rust-docs": {
"command": "node",
"args": ["/absolute/path/to/index.js"]
}
}
}
Amazon Q CLI
The server is compatible with Amazon Q CLI's MCP integration. Configure it in your Q CLI settings.
Example Usage Scenarios
Once the server is running and configured with your AI assistant, you can ask questions like:
Documentation Lookup
- "Look up the documentation for the 'tokio' crate"
- "Show me the documentation for 'serde' version 1.0.0"
- "Get the first 5000 characters of 'axum' documentation"
Crate Search
- "Search for web framework crates"
- "Find crates related to async programming"
- "Show me the top 5 HTTP client crates"
Metadata Queries
- "Get metadata for the 'reqwest' crate"
- "What's the latest version of 'clap'?"
- "Show me the download statistics for 'rand'"
Advanced Queries
- "Compare the documentation of 'tokio' and 'async-std'"
- "What are the main features of the 'ratatui' crate?"
- "Find alternatives to the 'hyper' crate"
Key Improvements Over Original
This implementation applies patterns from the AWS Documentation MCP Server:
1. Modular Architecture
- Separated concerns into models, utilities, and server logic
- Better maintainability and testability
2. Enhanced Error Handling
- Comprehensive error handling with detailed messages
- Proper HTTP status code handling
- Graceful degradation for network issues
3. Multiple Tools
lookup_crate_docs: Documentation fetchingsearch_crates: Crate discoveryget_crate_metadata: Detailed crate information
4. Better Validation
- Strong input validation using Zod schemas
- Parameter bounds checking
- Type safety throughout
5. Session Management
- Session IDs for tracking and debugging
- Better logging with session context
6. Pagination Support
- Handle large documentation with
startIndexandmaxLength - Continuation indicators for truncated content
7. Structured Responses
- Consistent response formatting
- Rich metadata in responses
- Better error reporting
Testing with MCP Inspector
You can test this server using the MCP Inspector:
npx @modelcontextprotocol/inspector
Then select "Connect to a local server" and follow the prompts.
API Endpoints Used
- docs.rs:
https://docs.rs/{crate}/{version}/{crate}/index.html - crates.io Search:
https://crates.io/api/v1/crates?q={query} - crates.io Metadata:
https://crates.io/api/v1/crates/{crate}
Configuration
The server can be configured through environment variables:
RUST_DOCS_LOG_LEVEL: Set logging level (default: 'info')RUST_DOCS_MAX_CONTENT_LENGTH: Maximum content length (default: 50000)RUST_DOCS_REQUEST_TIMEOUT: Request timeout in ms (default: 30000)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run tests
npm test
# Lint code
npm run lint
License
MIT
Changelog
v2.0.0
- Complete rewrite with modular architecture
- Added crate search functionality
- Added metadata retrieval
- Enhanced error handling and logging
- Added pagination support
- Improved documentation and examples
v1.0.0
- Initial release with basic documentation lookup
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。