get_featured_packages
Retrieve featured and popular Typst packages from the Typst Universe registry to discover useful tools for document creation.
Instructions
Get a list of featured/popular packages from Typst Universe.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/scraper.ts:237-268 (handler)The core handler function that scrapes the Typst Universe homepage for featured packages using Cheerio, extracts package details, removes duplicates, and returns TypstPackage[]export async function getFeaturedPackages(): Promise<TypstPackage[]> { const html = await fetchPage(UNIVERSE_URL); const $ = cheerio.load(html); const packages: TypstPackage[] = []; // Featured packages are typically at the top of the main page $('a[href^="/universe/package/"]').slice(0, 20).each((_, element) => { const $el = $(element); const href = $el.attr('href'); if (!href) return; const text = $el.text().trim(); const match = text.match(/^([a-z0-9_-]+)(\d+\.\d+\.\d+)(.*)$/i); if (match) { const [, name, version, description] = match; packages.push({ name: name.trim(), version: version.trim(), description: description.trim(), url: `${BASE_URL}${href}`, }); } }); // Remove duplicates return packages.filter((pkg, index, self) => index === self.findIndex(p => p.name === pkg.name) ); }
- src/scraper.ts:6-11 (schema)Type definition for the output of getFeaturedPackagesexport interface TypstPackage { name: string; version: string; description: string; url: string; }
- src/index.ts:72-80 (schema)MCP tool schema definition including name, description, and empty input schema{ name: 'get_featured_packages', description: 'Get a list of featured/popular packages from Typst Universe.', inputSchema: { type: 'object', properties: {}, }, }, ];
- src/index.ts:254-277 (registration)Registration and dispatching logic in the tool call handler switch statement, which invokes getFeaturedPackages and formats the response for MCPcase 'get_featured_packages': { const packages = await getFeaturedPackages(); if (packages.length === 0) { return { content: [ { type: 'text', text: 'No featured packages found.', }, ], }; } const formattedResults = packages.map(formatPackage).join('\n\n'); return { content: [ { type: 'text', text: `Featured packages (${packages.length}):\n\n${formattedResults}`, }, ], }; }
- src/index.ts:97-99 (helper)Helper function used to format individual package output in the tool response.function formatPackage(pkg: TypstPackage): string { return `📦 ${pkg.name} v${pkg.version}\n ${pkg.description}\n URL: ${pkg.url}`; }