search_packages
Find packages by keyword across all ecosystems to locate packages that perform specific functions.
Instructions
Find packages by keyword across all ecosystems. Use when looking for packages that do something specific.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Keywords to search for | |
| limit | No | Max results (default 20) |
Implementation Reference
- lib/db.js:90-106 (handler)Core handler function that executes the package search using full-text search (FTS5) on the local SQLite database, handling query quoting for special characters.
export function searchPackagesInDb(query, limit = 20) { if (!db) return null; // Quote the query to handle special FTS5 characters like hyphens // FTS5 treats - as NOT operator, so "better-sqlite3" becomes "better NOT sqlite3" // Quoting the entire phrase treats it as a literal search const quotedQuery = `"${query.replace(/"/g, '""')}"`; return db .prepare( `SELECT p.ecosystem, p.name, p.description, p.licenses, p.downloads, p.dependent_packages_count, p.repository_url FROM packages p JOIN packages_fts fts ON p.id = fts.rowid WHERE packages_fts MATCH ? LIMIT ?` ) .all(quotedQuery, limit); } - lib/tools.js:93-104 (schema)Input schema definition for the 'search_packages' tool, specifying query and optional limit parameters.
name: "search_packages", description: "Find packages by keyword across all ecosystems. Use when looking for packages that do something specific.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Keywords to search for" }, limit: { type: "number", description: "Max results (default 20)" }, }, required: ["query"], }, }, - index.js:153-160 (registration)Tool handler registration in the switch statement of handleToolCall, which checks for database availability, calls the search function, and formats the output.
case "search_packages": { if (!getDb()) { return "Search requires local database. No database loaded."; } const results = searchPackagesInDb(args.query, args.limit || 20); return `Search results for "${args.query}":\n\n${formatSearchResults(results)}`; } - index.js:239-241 (registration)Registration of the ListTools handler that returns the tools array including 'search_packages' schema.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });