Skip to main content
Glama

get_crate_doc

Retrieve Rust crate documentation to resolve import errors and understand crate features by providing project path and crate name.

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
project_pathYesPath to the Rust project (must be absolute path)
crate_nameYesName of the crate to get documentation for

Implementation Reference

  • Core handler function that verifies documentation is built, retrieves the cached doc path, and reads the main index.html content as markdown using 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 dispatch/registration in the CallToolRequestSchema handler, extracting arguments and calling the docManager.getCrateDoc handler.
    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-105 (registration)
    Tool metadata registration in ListToolsRequestSchema response, including name, description, and 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

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