search_crates
Find Rust packages on crates.io by name or keywords to discover libraries for specific functionality, returning details like descriptions, versions, and download counts.
Instructions
Search for Rust crates on crates.io by name or keywords.
USE THIS WHEN: You need to find Rust packages/crates for a specific purpose or library.
BEST FOR: Discovering which Rust crates exist for a topic or functionality.
Returns multiple matching crates with names, versions, descriptions, download counts, and URLs.
After finding a crate, use:
- crates_metadata() to get detailed information about a specific crate
- The documentation URL to read full docs (use WebFetch)
Args:
query: Search keywords (e.g., "http client", "web framework", "serde")
limit: Maximum number of results (default 5, max 100)
Returns:
JSON with list of matching crates, total results, and metadata
Example: search_crates("web framework") → Finds actix-web, rocket, axum, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| limit | No |
Implementation Reference
- src/RTFD/providers/crates.py:169-193 (handler)The main handler function for the 'search_crates' MCP tool. It delegates to the internal _search_crates method and serializes the response.async def search_crates(query: str, limit: int = 5) -> CallToolResult: """ Search for Rust crates on crates.io by name or keywords. USE THIS WHEN: You need to find Rust packages/crates for a specific purpose or library. BEST FOR: Discovering which Rust crates exist for a topic or functionality. Returns multiple matching crates with names, versions, descriptions, download counts, and URLs. After finding a crate, use: - crates_metadata() to get detailed information about a specific crate - The documentation URL to read full docs (use WebFetch) Args: query: Search keywords (e.g., "http client", "web framework", "serde") limit: Maximum number of results (default 5, max 100) Returns: JSON with list of matching crates, total results, and metadata Example: search_crates("web framework") → Finds actix-web, rocket, axum, etc. """ result = await self._search_crates(query, per_page=limit) return serialize_response_with_meta(result)
- src/RTFD/providers/crates.py:77-126 (helper)Internal helper method that performs the actual HTTP request to crates.io API, handles rate limiting, parses and formats the search results.async def _search_crates(self, query: str, per_page: int = 5) -> dict[str, Any]: """Search for crates by name/keyword.""" await self._rate_limit() try: async with await self._http_client() as client: response = await client.get( f"{self.BASE_URL}/crates", params={"q": query, "per_page": min(per_page, 100), "page": 1}, ) response.raise_for_status() data = response.json() # Format the response crates = data.get("crates", []) formatted_crates = [] for crate in crates[:per_page]: formatted_crates.append( { "name": crate.get("name"), "version": crate.get("max_version"), "description": crate.get("description", ""), "downloads": crate.get("downloads"), "recent_downloads": crate.get("recent_downloads"), "repository": crate.get("repository"), "documentation": crate.get("documentation"), "homepage": crate.get("homepage"), "license": crate.get("license"), "categories": crate.get("categories", []), "keywords": crate.get("keywords", []), "created_at": crate.get("created_at"), "updated_at": crate.get("updated_at"), } ) return { "query": query, "results": formatted_crates, "total": data.get("meta", {}).get("total"), "source": "https://crates.io/", } except Exception as e: return { "query": query, "error": str(e), "source": "https://crates.io/", }
- src/RTFD/providers/crates.py:166-222 (registration)The get_tools method registers the search_crates tool by defining it and including it in the returned dictionary of MCP tools.def get_tools(self) -> dict[str, Callable]: """Return MCP tool functions.""" async def search_crates(query: str, limit: int = 5) -> CallToolResult: """ Search for Rust crates on crates.io by name or keywords. USE THIS WHEN: You need to find Rust packages/crates for a specific purpose or library. BEST FOR: Discovering which Rust crates exist for a topic or functionality. Returns multiple matching crates with names, versions, descriptions, download counts, and URLs. After finding a crate, use: - crates_metadata() to get detailed information about a specific crate - The documentation URL to read full docs (use WebFetch) Args: query: Search keywords (e.g., "http client", "web framework", "serde") limit: Maximum number of results (default 5, max 100) Returns: JSON with list of matching crates, total results, and metadata Example: search_crates("web framework") → Finds actix-web, rocket, axum, etc. """ result = await self._search_crates(query, per_page=limit) return serialize_response_with_meta(result) async def crates_metadata(crate: str) -> CallToolResult: """ Get detailed metadata for a specific Rust crate from crates.io. USE THIS WHEN: You need comprehensive information about a specific Rust crate. RETURNS: Detailed crate metadata including version, URLs, downloads, and license. Does NOT include full documentation content. The response includes: - Crate name, version, description - Documentation URL (docs.rs) - can be passed to WebFetch for full API docs - Repository URL (usually GitHub) - can be used with GitHub provider - Homepage, license, categories, keywords - Download statistics, creation/update dates - Minimum Rust version required Args: crate: Crate name (e.g., "serde", "tokio", "actix-web") Returns: JSON with comprehensive crate metadata Example: crates_metadata("serde") → Returns metadata with docs.rs link and GitHub repo """ result = await self._get_crate_metadata(crate) return serialize_response_with_meta(result) return {"search_crates": search_crates, "crates_metadata": crates_metadata}
- src/RTFD/providers/crates.py:30-39 (registration)Provider metadata that lists 'search_crates' as one of the exposed tool names.def get_metadata(self) -> ProviderMetadata: return ProviderMetadata( name="crates", description="Rust crates.io package registry metadata", expose_as_tool=True, tool_names=["crates_metadata", "search_crates"], supports_library_search=True, required_env_vars=[], optional_env_vars=[], )