Skip to main content
Glama

docs_rs_search_crates

Search for Rust crates by keywords on crates.io, allowing AI agents to find relevant packages and access documentation. Supports sorting by relevance, downloads, updates, or newness.

Instructions

Search for Rust crates by keywords on crates.io.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
per_pageNoNumber of results per page (default: 10, max: 100)
queryYesSearch keywords for finding relevant crates. Keywords should be in English.
sortNoSort order: 'relevance', 'downloads', 'recent-downloads', 'recent-updates', 'new' (default: relevance)

Implementation Reference

  • The handler function `searchCrates` that executes the tool logic: queries the crates.io API with the provided search parameters, maps the results to a structured format, and returns formatted Markdown content listing the crates.
    private async searchCrates(args: any) { const { query, per_page = 10, sort = "relevance" } = args; try { const response = await axios.get<{ crates: any[] }>("https://crates.io/api/v1/crates", { params: { q: query, per_page: Math.min(per_page, 100), sort, }, }); const crates = response.data.crates.map((crate: any) => ({ name: crate.name, description: crate.description || "No description available", downloads: crate.downloads, version: crate.newest_version, documentation: crate.documentation, })); return { content: [ { type: "text", text: `# Crate Search Results for "${query}"\n\n${crates .map( (crate: CrateSearchResult) => `## ${crate.name} (${crate.version})\n\n` + `**Description:** ${crate.description}\n\n` + `**Downloads:** ${crate.downloads.toLocaleString()}\n\n` + `**Documentation:** ${crate.documentation || "N/A"}\n\n---\n` ) .join("\n")}`, }, ], }; } catch (error) { throw new Error(`Failed to search crates: ${error}`); } }
  • Input schema defining the parameters for the tool: query (required string), per_page (optional number), sort (optional string).
    inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords for finding relevant crates. Keywords should be in English.", }, per_page: { type: "number", description: "Number of results per page (default: 10, max: 100)", }, sort: { type: "string", description: "Sort order: 'relevance', 'downloads', 'recent-downloads', 'recent-updates', 'new' (default: relevance)", }, }, required: ["query"], },
  • src/index.ts:50-71 (registration)
    Registration of the tool in the ListTools response, providing name, description, and input schema.
    { name: "docs_rs_search_crates", description: "Search for Rust crates by keywords on crates.io.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords for finding relevant crates. Keywords should be in English.", }, per_page: { type: "number", description: "Number of results per page (default: 10, max: 100)", }, sort: { type: "string", description: "Sort order: 'relevance', 'downloads', 'recent-downloads', 'recent-updates', 'new' (default: relevance)", }, }, required: ["query"], }, },
  • src/index.ts:149-150 (registration)
    Dispatch case in the CallTool handler switch statement that routes to the searchCrates handler function.
    case "docs_rs_search_crates": return await this.searchCrates(request.params.arguments);

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/nuskey8/docs-rs-mcp'

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