Skip to main content
Glama

get_crate_doc

Retrieve the main documentation page for a Rust crate to resolve unresolved imports or understand crate features, using the Cargo Doc MCP Server.

Instructions

Get crate's main documentation page. Useful for unresolved imports (e.g. use get_crate_doc when seeing 'unresolved import tokio::sync') or understanding crate features.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
crate_nameYesName of the crate to get documentation for
project_pathYesPath to the Rust project (must be absolute path)

Implementation Reference

  • Core implementation of get_crate_doc tool: checks if docs built, gets doc path from cache, reads index.html as markdown via RustdocUrl.readContent.
    public async getCrateDoc(projectPath: string, crateName: string): Promise<string> { const isBuilt = await this.checkDoc(projectPath, crateName); if (!isBuilt) { throw new DocError( DocErrorCode.BUILD_FAILED, 'Failed to build documentation' ); } const cached = await this.cache.get(projectPath, crateName); if (!cached) { throw new DocError( DocErrorCode.CACHE_ERROR, 'Cache error: Documentation entry not found' ); } try { const { docPath } = cached; return await RustdocUrl.readContent(docPath); } catch (error) { throw new DocError( DocErrorCode.SEARCH_FAILED, 'Failed to read crate documentation', error ); } }
  • Input schema definition for the get_crate_doc tool, specifying project_path and crate_name as required string parameters.
    inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the Rust project (must be absolute path)", }, crate_name: { type: "string", description: "Name of the crate to get documentation for", } }, required: ["project_path", "crate_name"], },
  • src/index.ts:154-170 (registration)
    Tool call handler registration in switch statement: extracts args, calls docManager.getCrateDoc, returns text content.
    case "get_crate_doc": { const { project_path, crate_name } = request.params.arguments as { project_path: string; crate_name: string; }; const content = await docManager.getCrateDoc(project_path, crate_name); return { content: [ { type: "text", text: content, }, ], }; }
  • src/index.ts:88-106 (registration)
    Tool registration in ListTools response: defines name, description, and input schema.
    { name: "get_crate_doc", description: "Get crate's main documentation page. Useful for unresolved imports (e.g. use get_crate_doc when seeing 'unresolved import tokio::sync') or understanding crate features.", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to the Rust project (must be absolute path)", }, crate_name: { type: "string", description: "Name of the crate to get documentation for", } }, required: ["project_path", "crate_name"], }, }, {

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/spacemeowx2/cargo-doc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server