Skip to main content
Glama
W1seGit

Typst Universe MCP Server

by W1seGit

search_packages

Search for Typst packages and templates in the Typst Universe registry using query text, category filters, and type specifications to find relevant resources for your projects.

Instructions

Search for Typst packages in the Typst Universe. You can search by query text, filter by category, and specify the kind (packages or templates).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch query text to find packages (e.g., "math", "diagram", "table")
kindNoType of items to search for. Defaults to "packages".packages
categoryNoFilter by category (e.g., "visualization", "math", "text")
limitNoMaximum number of results to return. Defaults to 20.

Implementation Reference

  • Core handler function that performs web scraping on Typst Universe to search for packages based on query, kind, category, and limit.
    export async function searchPackages(options: SearchOptions = {}): Promise<TypstPackage[]> {
        const { query, kind = 'packages', category, limit = 50 } = options;
    
        // Build the search URL
        const searchParams = new URLSearchParams();
        searchParams.set('kind', kind);
    
        if (query) {
            searchParams.set('q', query);
        }
    
        if (category) {
            searchParams.set('category', category);
        }
    
        const searchUrl = `${UNIVERSE_URL}/search/?${searchParams.toString()}`;
        const html = await fetchPage(searchUrl);
        const $ = cheerio.load(html);
    
        const packages: TypstPackage[] = [];
    
        // Parse the package list from the page
        // The packages are typically listed as links with package info
        $('a[href^="/universe/package/"]').each((_, element) => {
            const $el = $(element);
            const href = $el.attr('href');
    
            if (!href) return;
    
            // Extract text content - name, version, and description are typically in the link text
            const text = $el.text().trim();
    
            // Try to parse the package info from the text
            // Format is typically: "name0.0.0Description text here"
            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 (same package might appear multiple times)
        const uniquePackages = packages.filter((pkg, index, self) =>
            index === self.findIndex(p => p.name === pkg.name)
        );
    
        return uniquePackages.slice(0, limit);
    }
  • Zod validation schema for input parameters of search_packages tool.
    const SearchPackagesSchema = z.object({
        query: z.string().optional(),
        kind: z.enum(['packages', 'templates']).optional().default('packages'),
        category: z.string().optional(),
        limit: z.number().optional().default(20),
    });
  • src/index.ts:22-49 (registration)
    MCP Tool object registration defining name, description, and JSON input schema for search_packages.
    {
        name: 'search_packages',
        description: 'Search for Typst packages in the Typst Universe. You can search by query text, filter by category, and specify the kind (packages or templates).',
        inputSchema: {
            type: 'object',
            properties: {
                query: {
                    type: 'string',
                    description: 'Search query text to find packages (e.g., "math", "diagram", "table")',
                },
                kind: {
                    type: 'string',
                    enum: ['packages', 'templates'],
                    description: 'Type of items to search for. Defaults to "packages".',
                    default: 'packages',
                },
                category: {
                    type: 'string',
                    description: 'Filter by category (e.g., "visualization", "math", "text")',
                },
                limit: {
                    type: 'number',
                    description: 'Maximum number of results to return. Defaults to 20.',
                    default: 20,
                },
            },
        },
    },
  • src/index.ts:173-202 (registration)
    Dispatch handler in MCP CallToolRequestSchema that validates args, calls searchPackages, formats results, and returns response.
    case 'search_packages': {
        const validatedArgs = SearchPackagesSchema.parse(args);
        const packages = await searchPackages({
            query: validatedArgs.query,
            kind: validatedArgs.kind,
            category: validatedArgs.category,
            limit: validatedArgs.limit,
        });
    
        if (packages.length === 0) {
            return {
                content: [
                    {
                        type: 'text',
                        text: 'No packages found matching your search criteria.',
                    },
                ],
            };
        }
    
        const formattedResults = packages.map(formatPackage).join('\n\n');
        return {
            content: [
                {
                    type: 'text',
                    text: `Found ${packages.length} package(s):\n\n${formattedResults}`,
                },
            ],
        };
    }
  • TypeScript interface defining input options for the searchPackages function.
    export interface SearchOptions {
        query?: string;
        kind?: 'packages' | 'templates';
        category?: string;
        limit?: number;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions search capabilities but lacks details on critical behaviors: it doesn't specify if this is a read-only operation (implied but not stated), how results are returned (e.g., pagination, sorting), rate limits, authentication needs, or error handling. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its operational traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences that efficiently convey the tool's purpose and key parameters. It's front-loaded with the main action ('Search for Typst packages'), and the second sentence adds useful context without redundancy. Every sentence earns its place, though it could be slightly more structured (e.g., bullet points for parameters).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (search with filters), 100% schema coverage, and no output schema, the description is partially complete. It covers the basic purpose and parameters but lacks behavioral details (e.g., result format, pagination) and explicit usage guidelines vs. siblings. Without annotations or output schema, more context on what to expect from the search results would improve completeness for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, providing clear details for all 4 parameters (e.g., 'query' for search text, 'kind' with enum and default, 'category' for filtering, 'limit' with default). The description adds minimal value beyond the schema by listing the parameters ('search by query text, filter by category, and specify the kind') but doesn't explain semantics like how 'query' interacts with 'category' or what 'limit' entails in practice. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search for Typst packages') and resource ('Typst Universe'), making the purpose immediately understandable. It distinguishes from siblings like 'get_featured_packages' (which likely shows curated items) and 'get_package_details' (which retrieves specific package info) by emphasizing search functionality. However, it doesn't explicitly mention how it differs from 'list_categories' (which might list categories without searching).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through phrases like 'You can search by query text, filter by category, and specify the kind,' suggesting when to use this tool for searching with filters. However, it doesn't provide explicit guidance on when to choose this over alternatives like 'get_featured_packages' (e.g., for curated vs. search-based results) or 'list_categories' (e.g., for browsing categories vs. searching within them). No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/W1seGit/Typst-Universe-MCP'

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