check_package_updates
Identify updates for a Dart or Flutter package by submitting the package name. Optionally, compare versions to determine if newer releases are available.
Instructions
Check for updates to a specific package or compare versions
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| currentVersion | No | Current version to compare against (optional) | |
| packageName | Yes | Name of the package to check for updates |
Input Schema (JSON Schema)
{
"properties": {
"currentVersion": {
"description": "Current version to compare against (optional)",
"type": "string"
},
"packageName": {
"description": "Name of the package to check for updates",
"type": "string"
}
},
"required": [
"packageName"
],
"type": "object"
}
Implementation Reference
- src/pubdev-mcp.ts:305-344 (handler)The main handler function that fetches the latest package information from pub.dev, compares the current version if provided using compareVersions, fetches version history to calculate versions behind, and returns update status.private async checkPackageUpdates(packageName: string, currentVersion?: string) { const url = `https://pub.dev/api/packages/${packageName}`; const data = await this.fetchWithCache<any>(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<any>(versionsUrl, `versions-${packageName}`); const currentIndex = versionsData.versions.findIndex((v: any) => v.version === currentVersion); const latestIndex = versionsData.versions.findIndex((v: any) => v.version === latestVersion); if (currentIndex > -1 && latestIndex > -1) { updateStatus.versionsBehind = currentIndex - latestIndex; } } return { content: [ { type: "text", text: JSON.stringify(updateStatus, null, 2) } ] }; }
- src/pubdev-mcp.ts:80-93 (schema)Input schema for the check_package_updates tool, requiring packageName and optionally currentVersion.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"] }
- src/pubdev-mcp.ts:77-94 (registration)Registration of the check_package_updates tool in the ListTools response, including name, description, and input schema.{ 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"] } },
- src/pubdev-mcp.ts:198-202 (registration)Dispatcher case in CallToolRequestHandler that routes calls to the checkPackageUpdates handler.case "check_package_updates": return await this.checkPackageUpdates( args.packageName as string, args.currentVersion as string );
- src/pubdev-mcp.ts:529-542 (helper)Helper function to compare semantic versions, used in checkPackageUpdates to determine if an update is available.private compareVersions(version1: string, version2: string): number { 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; }