Skip to content

lazhenyi/rs-docsrs-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rs-docsrs-mcp

A Model Context Protocol (MCP) server for docs.rs - enabling AI assistants to search and fetch Rust crate documentation.

CI Tests npm version License: MIT

Features

  • 🔍 Search Crates: Search for Rust crates on docs.rs by name or keyword
  • 📦 Crate Information: Get detailed information about specific crates
  • 📚 Documentation Access: Fetch documentation for specific modules, structs, functions, and more
  • 📑 Module Listing: List all modules, structs, enums, functions, traits, and macros in a crate
  • 📖 README Access: Retrieve crate README and metadata

Installation

Install globally via npm:

npm install -g rs-docsrs-mcp

Or use with npx:

npx rs-docsrs-mcp

Usage with Claude Desktop

Add to your Claude Desktop configuration file:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "docsrs": {
      "command": "npx",
      "args": ["-y", "rs-docsrs-mcp"]
    }
  }
}

If installed globally:

{
  "mcpServers": {
    "docsrs": {
      "command": "rs-docsrs-mcp"
    }
  }
}

Available Tools

1. docs_rs_search

Search for crates on docs.rs.

Parameters:

  • query (string, required): Crate name or keyword to search
  • limit (number, optional): Maximum number of results (1-50, default: 10)

Example:

{
  "query": "tokio",
  "limit": 5
}

2. docs_rs_crate_home

Get homepage information for a specific crate.

Parameters:

  • crate (string, required): Crate name

Example:

{
  "crate": "tokio"
}

3. docs_rs_get_doc

Get documentation for a specific path in a crate.

Parameters:

  • crate (string, required): Crate name
  • version (string, optional): Version (default: "latest")
  • path (string, optional): Documentation path (e.g., "tokio/runtime/index.html")

Examples:

{
  "crate": "tokio",
  "version": "latest",
  "path": "tokio/runtime/struct.Runtime.html"
}
{
  "crate": "serde",
  "path": "serde/trait.Serialize.html"
}

4. docs_rs_list_modules

List all modules and items in a crate.

Parameters:

  • crate (string, required): Crate name
  • version (string, optional): Version (default: "latest")

Example:

{
  "crate": "tokio",
  "version": "1.35.0"
}

Returns:

  • modules: List of modules with descriptions
  • structs: List of structs
  • enums: List of enums
  • functions: List of functions
  • traits: List of traits
  • macros: List of macros

5. docs_rs_get_readme

Get README and metadata for a crate.

Parameters:

  • crate (string, required): Crate name
  • version (string, optional): Version (default: "latest")

Example:

{
  "crate": "tokio"
}

Example Queries

Once configured, you can ask Claude:

  • "Search for HTTP client crates"
  • "Show me the tokio runtime documentation"
  • "List all modules in the serde crate"
  • "Get the README for actix-web"
  • "What structs are available in tokio?"

Development

Clone the repository:

git clone https://github.com/lazhenyi/rs-docsrs-mcp.git
cd rs-docsrs-mcp
npm install

Run locally:

npm start

Requirements

  • Node.js >= 20.0.0

How It Works

This MCP server scrapes documentation from docs.rs to provide structured information about Rust crates. It uses:

  • cheerio: For HTML parsing
  • node-fetch: For HTTP requests
  • @modelcontextprotocol/sdk: For MCP protocol implementation
  • zod: For parameter validation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details.

Links

Support

If you encounter any issues or have questions, please open an issue on GitHub.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •