Skip to main content
Glama
spacemeowx2

Cargo Doc MCP Server

by spacemeowx2

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"],
      },
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the tool's purpose and use cases but lacks details on behavioral traits such as error handling, response format, or any constraints like rate limits or authentication needs. This leaves gaps in understanding how the tool behaves beyond its basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with two sentences that directly state the purpose and provide usage guidance without any wasted words. Each sentence adds value, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description covers purpose and usage well but lacks details on behavioral aspects and output. Without annotations or an output schema, it should ideally provide more context on what to expect from the tool's response, leaving it somewhat incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('project_path' and 'crate_name') with clear descriptions. The description does not add any additional meaning or context about the parameters beyond what the schema provides, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get crate's main documentation page') and resource ('crate'), distinguishing it from sibling tools like 'list_symbols' and 'search_doc' by focusing on retrieving primary documentation rather than listing symbols or searching within documentation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly provides when to use this tool ('Useful for unresolved imports... or understanding crate features') with a concrete example ('e.g. use get_crate_doc when seeing 'unresolved import tokio::sync''), effectively guiding the agent on appropriate contexts without mentioning alternatives, which is sufficient for clear usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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