No description
Find a file
2025-03-12 18:15:05 -07:00
docs Rename doc server to stdio server 2025-03-12 14:52:36 -07:00
examples Rename doc server to stdio server 2025-03-12 14:52:36 -07:00
src Remove old binaries 2025-03-12 18:15:05 -07:00
tests Clippy fixes 2025-03-12 17:53:28 -07:00
.gitignore Init 2025-03-06 22:49:18 -08:00
Cargo.lock Add tests 2025-03-11 12:12:13 -07:00
Cargo.toml Remove old binaries 2025-03-12 18:15:05 -07:00
CLAUDE.md Rename doc server to stdio server 2025-03-12 14:52:36 -07:00
LICENSE Update project name 2025-03-06 22:51:01 -08:00
README.md Rename doc server to stdio server 2025-03-12 14:52:36 -07:00

CrateDocs MCP

This is an MCP (Model Context Protocol) server that provides tools for Rust crate documentation lookup. It allows LLMs to look up documentation for Rust crates they are unfamiliar with.

Features

  • Lookup crate documentation: Get general documentation for a Rust crate
  • Search crates: Search for crates on crates.io based on keywords
  • Lookup item documentation: Get documentation for a specific item (e.g., struct, function, trait) within a crate

Installation

git clone https://github.com/yourusername/cratedocs-mcp.git
cd cratedocs-mcp
cargo build --release

Running the Server

There are multiple ways to run the documentation server:

Using the Unified CLI

The unified command-line interface provides subcommands for all server modes:

# Run in STDIN/STDOUT mode
cargo run --bin cratedocs stdio

# Run in HTTP/SSE mode (default address: 127.0.0.1:8080)
cargo run --bin cratedocs http

# Run in HTTP/SSE mode with custom address
cargo run --bin cratedocs http --address 0.0.0.0:3000

# Enable debug logging
cargo run --bin cratedocs http --debug

Legacy Commands

For backward compatibility, you can still use the original binaries:

# STDIN/STDOUT Mode
cargo run --bin stdio-server

# HTTP/SSE Mode
cargo run --bin axum-docs

By default, the HTTP server will listen on http://127.0.0.1:8080/sse.

Available Tools

The server provides the following tools:

1. lookup_crate

Retrieves documentation for a specified Rust crate.

Parameters:

  • crate_name (required): The name of the crate to look up
  • version (optional): The version of the crate (defaults to latest)

Example:

{
  "name": "lookup_crate",
  "arguments": {
    "crate_name": "tokio",
    "version": "1.28.0"
  }
}

2. search_crates

Searches for Rust crates on crates.io.

Parameters:

  • query (required): The search query
  • limit (optional): Maximum number of results to return (defaults to 10, max 100)

Example:

{
  "name": "search_crates",
  "arguments": {
    "query": "async runtime",
    "limit": 5
  }
}

3. lookup_item

Retrieves documentation for a specific item in a crate.

Parameters:

  • crate_name (required): The name of the crate
  • item_path (required): Path to the item (e.g., 'std::vec::Vec')
  • version (optional): The version of the crate (defaults to latest)

Example:

{
  "name": "lookup_item",
  "arguments": {
    "crate_name": "serde",
    "item_path": "serde::Deserialize",
    "version": "1.0.160"
  }
}

Implementation Notes

  • The server includes a caching mechanism to prevent redundant API calls for the same documentation
  • It interfaces with docs.rs for crate documentation and crates.io for search functionality
  • Results are returned as plain text/HTML content that can be parsed and presented by the client

MCP Protocol Integration

This server implements the Model Context Protocol (MCP) which allows it to be easily integrated with LLM clients that support the protocol. For more information about MCP, visit the MCP repository.

License

MIT License