Skip to main content
Glama
W1seGit

Typst Universe MCP Server

by W1seGit

get_package_details

Retrieve detailed information about Typst packages, including descriptions, authors, categories, repository links, import code, and version history.

Instructions

Get detailed information about a specific Typst package, including its description, authors, categories, repository link, import code, and version history.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNameYesThe exact name of the package (e.g., "cetz", "polylux", "fletcher")

Implementation Reference

  • The core handler function that scrapes the Typst Universe package page to extract detailed information including version, description, authors, categories, repository, homepage, import code, and version history.
    export async function getPackageDetails(packageName: string): Promise<PackageDetails | null> {
        const packageUrl = `${UNIVERSE_URL}/package/${packageName}`;
    
        try {
            const html = await fetchPage(packageUrl);
            const $ = cheerio.load(html);
    
            // Extract package name and version from the header
            const headerText = $('h1').first().text().trim();
    
            // Get the description from meta tag or first paragraph
            const metaDescription = $('meta[name="description"]').attr('content') ||
                $('meta[property="og:description"]').attr('content') || '';
    
            // Extract the full description from the main content
            const mainContent = $('main').text().trim();
    
            // Find version in the page
            const versionMatch = mainContent.match(/(\d+\.\d+\.\d+)/);
            const version = versionMatch ? versionMatch[1] : 'unknown';
    
            // Extract authors
            const authors: string[] = [];
            $('a[href*="author"]').each((_, el) => {
                const authorName = $(el).text().trim();
                if (authorName && !authors.includes(authorName)) {
                    authors.push(authorName);
                }
            });
    
            // Extract categories
            const categories: string[] = [];
            $('a[href*="category="]').each((_, el) => {
                const category = $(el).text().trim();
                if (category && !categories.includes(category)) {
                    categories.push(category);
                }
            });
    
            // Extract repository link
            let repository: string | undefined;
            const githubLink = $('a[href*="github.com"]').first().attr('href');
            if (githubLink && !githubLink.includes('typst/packages')) {
                repository = githubLink;
            }
    
            // Extract homepage
            let homepage: string | undefined;
            $('a').each((_, el) => {
                const href = $(el).attr('href');
                const text = $(el).text().toLowerCase();
                if (href && (text.includes('.io') || text.includes('.com') || text.includes('homepage')) &&
                    !href.includes('github.com') && !href.includes('typst.app')) {
                    homepage = href;
                }
            });
    
            // Build import code
            const importCode = `#import "@preview/${packageName}:${version}"`;
    
            // Extract version history
            const versionHistory: string[] = [];
            $(`a[href^="/universe/package/${packageName}/"]`).each((_, el) => {
                const versionText = $(el).text().trim();
                if (versionText.match(/^\d+\.\d+\.\d+$/)) {
                    versionHistory.push(versionText);
                }
            });
    
            return {
                name: packageName,
                version,
                description: metaDescription,
                fullDescription: mainContent.substring(0, 2000), // Limit full description length
                authors,
                categories,
                repository,
                homepage,
                importCode,
                versionHistory,
                url: packageUrl,
            };
        } catch (error) {
            console.error(`Failed to fetch package details for ${packageName}:`, error);
            return null;
        }
    }
  • src/index.ts:51-63 (registration)
    Registration of the 'get_package_details' tool in the TOOLS array, including name, description, and input schema.
        name: 'get_package_details',
        description: 'Get detailed information about a specific Typst package, including its description, authors, categories, repository link, import code, and version history.',
        inputSchema: {
            type: 'object',
            properties: {
                packageName: {
                    type: 'string',
                    description: 'The exact name of the package (e.g., "cetz", "polylux", "fletcher")',
                },
            },
            required: ['packageName'],
        },
    },
  • Zod schema used for validating the input arguments to the getPackageDetails function.
    const GetPackageDetailsSchema = z.object({
        packageName: z.string().min(1, 'Package name is required'),
    });
  • Tool dispatch handler in the switch statement that validates arguments and calls the getPackageDetails function.
    case 'get_package_details': {
        const validatedArgs = GetPackageDetailsSchema.parse(args);
        const details = await getPackageDetails(validatedArgs.packageName);
    
        if (!details) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Package "${validatedArgs.packageName}" not found. Please check the package name and try again.`,
                    },
                ],
                isError: true,
            };
        }
    
        return {
            content: [
                {
                    type: 'text',
                    text: formatPackageDetails(details),
                },
            ],
        };
    }
  • TypeScript interface defining the structure of the PackageDetails return type.
    export interface PackageDetails {
        name: string;
        version: string;
        description: string;
        fullDescription: string;
        authors: string[];
        categories: string[];
        repository?: string;
        homepage?: string;
        importCode: string;
        versionHistory: string[];
        url: string;
    }
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 describes what information is returned but does not address key behavioral aspects such as error handling (e.g., what happens if the package doesn't exist), rate limits, authentication needs, or whether it's a read-only operation. The description adds some value by listing the data fields, but misses critical operational context.

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

Conciseness5/5

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

The description is a single, well-structured sentence that efficiently lists all key information points without redundancy. It is front-loaded with the main purpose and follows with specific details, making it easy to parse. Every part of the sentence adds value.

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 low complexity (1 parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the purpose and data returned, but lacks behavioral details (e.g., error cases) that would be important for an agent to use it correctly. Without annotations or output schema, the description should do more to compensate, but it only partially meets this need.

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?

Schema description coverage is 100%, with the parameter 'packageName' fully documented in the schema. The description does not add any parameter-specific details beyond what the schema provides (e.g., it doesn't clarify format constraints or provide examples beyond the schema's examples). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Get detailed information') and resource ('a specific Typst package'), with explicit listing of the information included (description, authors, categories, etc.). It distinguishes from sibling tools like 'get_featured_packages' (which lists packages) and 'search_packages' (which searches) by focusing on detailed metadata for a single package.

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 when detailed package metadata is needed, but does not explicitly state when to use this tool versus alternatives like 'search_packages' or 'list_categories'. It provides context by specifying the type of information returned, but lacks explicit guidance on exclusions or prerequisites.

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