docs_rs_readme
Retrieve README content for Rust crates from docs.rs to understand crate functionality and usage documentation.
Instructions
Get README/overview content of the specified crate
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| crate_name | Yes | Name of the crate to get README for | |
| version | No | Specific version (optional, defaults to latest) |
Implementation Reference
- src/index.ts:213-252 (handler)The main handler function for the 'docs_rs_readme' tool. It fetches the documentation page from docs.rs for the specified crate (and optional version), extracts the main content using Cheerio, converts it to Markdown using Turndown, and returns it formatted as tool content.private async getReadMe(args: any) { const { crate_name, version = "latest" } = args; try { const url = `https://docs.rs/${crate_name}/${version}/${crate_name}/index.html`; const response = await axios.get<string>(url); const $ = cheerio.load(response.data); const mainContent = $(".rustdoc .docblock").first(); if (mainContent.length === 0) { const alternativeContent = $(".rustdoc-main .item-decl").first(); if (alternativeContent.length === 0) { return { content: [ { type: "text", text: `# ${crate_name} Documentation\n\nNo documentation content found at ${url}`, }, ], }; } } const htmlContent = mainContent.html() || ""; const markdownContent = turndownService.turndown(htmlContent); return { content: [ { type: "text", text: `# ${crate_name} Documentation\n\n${markdownContent}`, }, ], }; } catch (error) { throw new Error(`Failed to get README for ${crate_name}: ${error}`); } }
- src/index.ts:75-88 (schema)Input schema definition for the 'docs_rs_readme' tool, specifying required 'crate_name' and optional 'version' parameters.inputSchema: { type: "object", properties: { crate_name: { type: "string", description: "Name of the crate to get README for", }, version: { type: "string", description: "Specific version (optional, defaults to latest)", }, }, required: ["crate_name"], },
- src/index.ts:72-89 (registration)Tool registration in the ListTools response, including name, description, and input schema.{ name: "docs_rs_readme", description: "Get README/overview content of the specified crate", inputSchema: { type: "object", properties: { crate_name: { type: "string", description: "Name of the crate to get README for", }, version: { type: "string", description: "Specific version (optional, defaults to latest)", }, }, required: ["crate_name"], }, },
- src/index.ts:151-152 (registration)Handler dispatch/registration in the CallTool switch statement, mapping the tool name to the getReadMe method.case "docs_rs_readme": return await this.getReadMe(request.params.arguments);