Skip to main content
Glama
devqxi

Pub.dev MCP Server

by devqxi

check_package_updates

Check for updates to a specific Dart/Flutter package or compare versions to maintain current dependencies.

Instructions

Check for updates to a specific package or compare versions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNameYesName of the package to check for updates
currentVersionNoCurrent version to compare against (optional)

Implementation Reference

  • Main handler function that checks for package updates by fetching the latest version from pub.dev API, comparing it to the current version if provided, calculating if an update is available and versions behind, then returning a JSON-formatted status.
    async checkPackageUpdates(packageName, currentVersion) {
        const url = `https://pub.dev/api/packages/${packageName}`;
        const data = await this.fetchWithCache(url, `package-${packageName}`);
        const latestVersion = data.latest.version;
        const latestPublished = data.latest.published;
        let updateStatus = {
            packageName,
            currentVersion: currentVersion || 'unknown',
            latestVersion,
            latestPublished,
            updateAvailable: false,
            versionsBehind: 0
        };
        if (currentVersion) {
            updateStatus.updateAvailable = this.compareVersions(currentVersion, latestVersion) < 0;
            // Get version history to count versions behind
            const versionsUrl = `https://pub.dev/api/packages/${packageName}/versions`;
            const versionsData = await this.fetchWithCache(versionsUrl, `versions-${packageName}`);
            const currentIndex = versionsData.versions.findIndex((v) => v.version === currentVersion);
            const latestIndex = versionsData.versions.findIndex((v) => v.version === latestVersion);
            if (currentIndex > -1 && latestIndex > -1) {
                updateStatus.versionsBehind = currentIndex - latestIndex;
            }
        }
        return {
            content: [
                {
                    type: "text",
                    text: JSON.stringify(updateStatus, null, 2)
                }
            ]
        };
    }
  • Input schema definition for the check_package_updates tool, specifying packageName as required string and optional currentVersion string.
    {
        name: "check_package_updates",
        description: "Check for updates to a specific package or compare versions",
        inputSchema: {
            type: "object",
            properties: {
                packageName: {
                    type: "string",
                    description: "Name of the package to check for updates"
                },
                currentVersion: {
                    type: "string",
                    description: "Current version to compare against (optional)"
                }
            },
            required: ["packageName"]
        }
    },
  • Registration in the tool dispatch switch statement, mapping the tool name to the checkPackageUpdates handler method.
    case "check_package_updates":
        return await this.checkPackageUpdates(args.packageName, args.currentVersion);
  • Helper function to compare two semantic version strings, used to determine if currentVersion is behind latestVersion.
    compareVersions(version1, version2) {
        const v1Parts = version1.split('.').map(Number);
        const v2Parts = version2.split('.').map(Number);
        for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
            const v1Part = v1Parts[i] || 0;
            const v2Part = v2Parts[i] || 0;
            if (v1Part < v2Part)
                return -1;
            if (v1Part > v2Part)
                return 1;
        }
        return 0;
    }
  • Caching helper for API fetches to pub.dev, used by the handler to retrieve package and versions data.
    async fetchWithCache(url, cacheKey) {
        const cached = this.packageCache.get(cacheKey);
        const now = Date.now();
        if (cached && (now - cached.timestamp) < this.CACHE_DURATION) {
            return cached.data;
        }
        const response = await fetch(url, {
            headers: {
                'User-Agent': 'MCP-PubDev-Server/1.0.0',
                'Accept': 'application/json'
            }
        });
        if (!response.ok) {
            throw new Error(`HTTP ${response.status}: ${response.statusText}`);
        }
        const data = await response.json();
        this.packageCache.set(cacheKey, { data, timestamp: now });
        return data;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe how it works—e.g., where it checks for updates (e.g., package registry), whether it requires authentication, rate limits, or what the output looks like. This leaves significant gaps for a tool that likely queries external sources.

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, efficient sentence with zero waste. It's appropriately sized and front-loaded, clearly stating the core functionality without unnecessary details.

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

Completeness2/5

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

Given the complexity of checking package updates (likely involving external APIs) and the lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like data sources, error handling, or return format, which are crucial for effective tool 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?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description adds no additional meaning beyond what's in the schema—it doesn't explain the format of 'packageName' (e.g., npm, PyPI) or how 'currentVersion' affects the comparison. 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 tool's purpose with specific verbs ('check for updates', 'compare versions') and identifies the resource ('package'). It distinguishes from some siblings like 'get_documentation_changes' but doesn't explicitly differentiate from 'compare_package_versions' or 'get_package_versions', which appear related.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'compare_package_versions' or 'get_package_versions'. It mentions both checking updates and comparing versions but doesn't clarify the context or prerequisites for these operations.

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/devqxi/pubdev-mcp-server'

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