Make AI slightly less stupid about Rust APIs.
rustdoc-query queries crate public APIs from docs.rs rustdoc JSON. Use it as
an embeddable Rust library or an MCP server.
The supported Rust API is:
rustdoc_query::contract::generated::*for versioned request and outcome typesrustdoc_query::service::RustdocQueryServicefor crate queriesrustdoc_query::mcp::RustdocMcpServerfor an embeddable MCP adapter
Other modules are implementation details.
The service operates on public API only. It provides crate and module overviews, public item detail, name search, and documentation search. The generated v2 contract is the source of truth for request fields, defaults, and outcomes.
JSON is the default representation. TOON is available for compact text output. The request and outcome types are unchanged.
Library users can call RustdocQueryService::json_value or
RustdocQueryService::toon. MCP users can set
RUSTDOC_QUERY_OUTPUT_FORMAT=toon or pass --output-format toon.
Add the package as a dependency:
[dependencies]
rustdoc-query = "0.1"Construct RustdocQueryService, then call its async overview, find, or
get_item methods with the corresponding generated request type. Results are
the matching generated outcome type and include typed API errors.
API documentation is available at docs.rs.
Install from crates.io:
cargo install rustdoc-queryOr install a release build:
curl -LsSf https://releases.gnu.foo/rustdoc-query/latest/install.sh | shThe server uses stdio JSON-RPC. A client configuration needs this command:
{
"command": "rustdoc-query"
}It registers these tools:
crate_overviewfind_items, including documentation searchget_item
Logs are written to standard error. Set RUSTDOC_QUERY_CACHE_DIR to override
the local rustdoc cache directory.
git clone https://github.com/gnufood/rustdoc-query.git
cd rustdoc-query
mise install --locked
just build
./target/debug/rustdoc-queryjust hooks-install| Command | Purpose |
|---|---|
just build |
Build the workspace. |
just check |
Type-check all workspace targets. |
just test |
Run the test suite with nextest. |
just lint |
Run Clippy. |
just schema |
Verify generated schema artifacts. |
just ci |
Run the full local CI sequence. |
Licensed under either of:
at your option.