- Explore MCP Servers
- rust-docs-mcp
Rust Docs Mcp
What is Rust Docs Mcp
rust-docs-mcp is a web server that provides documentation for Rust crates through an HTTP API endpoint, allowing users to fetch and search for crate documentation programmatically.
Use cases
Use cases for rust-docs-mcp include integrating Rust documentation into development tools, automating documentation retrieval for CI/CD processes, and providing documentation search capabilities in applications.
How to use
To use rust-docs-mcp, clone the repository, configure the environment variables, build the project using Cargo, and then start the server. You can fetch documentation by sending a POST request to the /mcp endpoint with the crate name.
Key features
Key features include an HTTP endpoint for fetching Rust crate documentation, a JSON-based API for easy integration, support for querying any published crate on crates.io, automatic parsing and formatting of documentation, and configurability via environment variables.
Where to use
rust-docs-mcp can be used in software development environments where Rust crate documentation is needed, such as in IDEs, CI/CD pipelines, or any application that requires programmatic access to Rust documentation.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Rust Docs Mcp
rust-docs-mcp is a web server that provides documentation for Rust crates through an HTTP API endpoint, allowing users to fetch and search for crate documentation programmatically.
Use cases
Use cases for rust-docs-mcp include integrating Rust documentation into development tools, automating documentation retrieval for CI/CD processes, and providing documentation search capabilities in applications.
How to use
To use rust-docs-mcp, clone the repository, configure the environment variables, build the project using Cargo, and then start the server. You can fetch documentation by sending a POST request to the /mcp endpoint with the crate name.
Key features
Key features include an HTTP endpoint for fetching Rust crate documentation, a JSON-based API for easy integration, support for querying any published crate on crates.io, automatic parsing and formatting of documentation, and configurability via environment variables.
Where to use
rust-docs-mcp can be used in software development environments where Rust crate documentation is needed, such as in IDEs, CI/CD pipelines, or any application that requires programmatic access to Rust documentation.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Rust Docs MCP Server
A web server that provides Rust crate documentation through an HTTP API endpoint. This service allows you to fetch and search documentation for Rust crates programmatically.
Features
- HTTP endpoint for fetching Rust crate documentation
- JSON-based API for easy integration
- Support for querying any published crate on crates.io
- Automatic parsing and formatting of documentation
- Configurable via environment variables
Prerequisites
- Rust and Cargo (latest stable version recommended)
- Internet connection (to fetch crate documentation)
Installation
-
Clone the repository:
git clone https://github.com/your-username/rust-docs-mcp-workers.git cd rust-docs-mcp-workers -
Create an
.envfile from the example:cp .env.example .env -
Edit the
.envfile to configure your settings:PORT=7777 # The port on which the server will run -
Build the project:
cargo build --release
Usage
Starting the Server
# Run in development mode
cargo run
# Run with specific logging level
RUST_LOG=info cargo run
# Run the compiled binary directly
./target/release/rust-docs-mcp-server
The server will start and listen for HTTP requests on the configured port (default: 6666 or from the PORT environment variable).
API Endpoints
POST /mcp
Fetch documentation for a specific Rust crate.
Request Format:
{
"command": "lookup_crate_docs",
"args": {
"crate_name": "tokio"
}
}
Parameters:
command: Must be"lookup_crate_docs"(required)args.crate_name: The name of the crate to look up (optional, defaults to “tokio”)
Response Format:
{
"content": [
{
"type_": "text",
"text": "# Tokio\n\nA runtime for writing reliable network applications without compromising speed.\n\n..."
}
],
"is_error": null
}
Error Response:
{
"content": [
{
"type_": "text",
"text": "Error message"
}
],
"is_error": true
}
Example Request with curl
curl -X POST http://localhost:7777/mcp \
-H "Content-Type: application/json" \
-d '{"command": "lookup_crate_docs", "args": {"crate_name": "serde"}}'
HTTP API 访问指南
服务器启动后,可以通过 HTTP 协议访问文档服务。服务默认监听在 http://localhost:7777 (或环境变量 PORT 指定的端口)。
API 端点
POST /mcp
查询 Rust crate 文档的主要端点。
请求格式:
{
"command": "lookup_crate_docs",
"args": {
"crate_name": "目标crate名称"
}
}
参数说明:
command: 必须为"lookup_crate_docs"args.crate_name: 要查询的 crate 名称,可选,默认为 “tokio”
响应格式:
{
"content": [
{
"type_": "text",
"text": "返回的文档内容..."
}
],
"is_error": null
}
多种客户端访问示例
使用 curl
# 查询 tokio crate 的文档
curl -X POST http://localhost:7777/mcp \
-H "Content-Type: application/json" \
-d '{"command": "lookup_crate_docs"}'
# 查询特定 crate (例如 serde) 的文档
curl -X POST http://localhost:7777/mcp \
-H "Content-Type: application/json" \
-d '{"command": "lookup_crate_docs", "args": {"crate_name": "serde"}}'
使用 Python
import requests
import json
url = "http://localhost:7777/mcp"
headers = {"Content-Type": "application/json"}
# 查询 actix-web crate 的文档
payload = {
"command": "lookup_crate_docs",
"args": {
"crate_name": "actix-web"
}
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.json())
使用 JavaScript (Node.js)
const fetch = require('node-fetch');
const url = 'http://localhost:7777/mcp';
const headers = { 'Content-Type': 'application/json' };
// 查询 tokio crate 的文档
const payload = {
command: 'lookup_crate_docs',
args: {
crate_name: 'tokio'
}
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
使用 Rust
use reqwest::Client;
use serde_json::{json, Value};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
// 查询 serde crate 的文档
let response = client.post("http://localhost:7777/mcp")
.header("Content-Type", "application/json")
.json(&json!({
"command": "lookup_crate_docs",
"args": {
"crate_name": "serde"
}
}))
.send()
.await?;
let result: Value = response.json().await?;
println!("{:#?}", result);
Ok(())
}
服务状态确认
可以使用简单的 HTTP 请求来确认服务是否正常运行:
# 使用 curl 确认服务状态
curl -X POST http://localhost:7777/mcp \
-H "Content-Type: application/json" \
-d '{"command": "lookup_crate_docs", "args": {"crate_name": "tokio"}}' \
-o /dev/null -s -w "%{http_code}\n"
如果服务正常运行,应该返回 200 状态码。
in Windsurf ide
Windsurf is a powerful agent AI IDE that supports a variety of languages including rust. To integrate your rust-docs-mcp-server with Windsurf, follow these steps:
Using rust-docs-mcp-server in Windsurf
测试配置
在 Cascade 面板输入:
Use the lookup_crate_docs tool to get documentation for “tokio”.
Windsurf 将发送 POST 请求,返回文档内容。
Project Structure
src/main.rs- Main application codeCargo.toml- Project dependencies and configuration.env- Environment configuration (not committed to repository).env.example- Example environment configuration
Dependencies
actix-web- HTTP server frameworkserde- Serialization/deserializationreqwest- HTTP clientscraper- HTML parsingtokio- Asynchronous runtimetracing- Logging and diagnosticsdotenvy- Environment variable loading
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










