rust-crate-src
Fetch Rust crate source code from crates.io. Available as a library and MCP server.
Usage
As a Library
use get_crate_source;
let source = get_crate_source.await?;
println!;
// With version constraint
let source = get_crate_source.await?;
As an MCP Server
Exposes the get_rust_crate_source tool:
- crate_name (required): Name of the crate to fetch
- version (optional): Semver version constraint (e.g., "1.0", "^1.2", "~1.2.3")
Returns:
- crate_name: Echo of requested crate
- version: Resolved exact version
- checkout_path: Path to extracted source
- message: Human-readable summary
Development
Architecture
| Module | Purpose |
|---|---|
lib.rs |
Public API facade |
version.rs |
Version resolution via crates.io API |
extract.rs |
Download and extract .crate tarballs |
bin/rust-crate-src-mcp.rs |
MCP server using rmcp |
For AI Agents
See AGENTS.md for development guidelines.
Acknowledgments
This project is based on the get_rust_crate_source tool from symposium.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.