Skip to main content
Glama

compare_package_versions

Compare two versions of a Dart or Flutter package to identify differences. Analyze changes in functionality, dependencies, or documentation between specified versions for informed decision-making.

Instructions

Compare two versions of a package and show differences

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromVersionYesSource version to compare from
packageNameYesName of the package to compare
toVersionYesTarget version to compare to

Implementation Reference

  • The core handler function for the 'compare_package_versions' tool. It fetches package versions from pub.dev API, retrieves pubspec data for the from and to versions, computes dependency changes using helper, and returns a JSON-structured comparison including versions, publish dates, dependencies, and changes.
    async comparePackageVersions(packageName, fromVersion, toVersion) { const versionsUrl = `https://pub.dev/api/packages/${packageName}/versions`; const data = await this.fetchWithCache(versionsUrl, `versions-${packageName}`); const fromVersionData = data.versions.find((v) => v.version === fromVersion); const toVersionData = data.versions.find((v) => v.version === toVersion); if (!fromVersionData || !toVersionData) { throw new Error('One or both versions not found'); } const comparison = { packageName, comparison: { from: { version: fromVersion, published: fromVersionData.published, dependencies: fromVersionData.pubspec?.dependencies || {}, devDependencies: fromVersionData.pubspec?.dev_dependencies || {} }, to: { version: toVersion, published: toVersionData.published, dependencies: toVersionData.pubspec?.dependencies || {}, devDependencies: toVersionData.pubspec?.dev_dependencies || {} } }, changes: { dependencyChanges: this.compareDependencies(fromVersionData.pubspec?.dependencies || {}, toVersionData.pubspec?.dependencies || {}), devDependencyChanges: this.compareDependencies(fromVersionData.pubspec?.dev_dependencies || {}, toVersionData.pubspec?.dev_dependencies || {}) } }; return { content: [ { type: "text", text: JSON.stringify(comparison, null, 2) } ] }; }
  • The input schema and metadata for the tool, defining required string parameters: packageName, fromVersion, toVersion.
    name: "compare_package_versions", description: "Compare two versions of a package and show differences", inputSchema: { type: "object", properties: { packageName: { type: "string", description: "Name of the package to compare" }, fromVersion: { type: "string", description: "Source version to compare from" }, toVersion: { type: "string", description: "Target version to compare to" } }, required: ["packageName", "fromVersion", "toVersion"] } },
  • Registration in the request handler switch statement, dispatching calls to the comparePackageVersions method.
    case "compare_package_versions": return await this.comparePackageVersions(args.packageName, args.fromVersion, args.toVersion);
  • Helper function used by the handler to compute differences in dependencies: added, removed, updated between old and new sets.
    compareDependencies(oldDeps, newDeps) { const changes = { added: [], removed: [], updated: [] }; // Find added dependencies for (const [pkg, version] of Object.entries(newDeps)) { if (!(pkg in oldDeps)) { changes.added.push(`${pkg}: ${version}`); } } // Find removed and updated dependencies for (const [pkg, oldVersion] of Object.entries(oldDeps)) { if (!(pkg in newDeps)) { changes.removed.push(`${pkg}: ${oldVersion}`); } else if (newDeps[pkg] !== oldVersion) { changes.updated.push({ package: pkg, from: oldVersion, to: newDeps[pkg] }); } } return changes;
  • Tool registration in the MCP server's tools list, including name, description, and schema. (Approximate lines based on context; exact tool entry 99-119)
    }, version: { type: "string", description: "Specific version (optional, defaults to latest)" }, docType: { type: "string", enum: ["readme", "changelog", "example", "api_docs"], description: "Type of documentation to retrieve" } }, required: ["packageName"] } }, { name: "compare_package_versions", description: "Compare two versions of a package and show differences", inputSchema: { type: "object", properties: { packageName: { type: "string", description: "Name of the package to compare" }, fromVersion: { type: "string", description: "Source version to compare from" }, toVersion: { type: "string", description: "Target version to compare to" } }, required: ["packageName", "fromVersion", "toVersion"] } }, { name: "search_packages", description: "Search for packages on pub.dev with filters", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query" }, sort: { type: "string", enum: ["top", "text", "created", "updated", "popularity", "points", "likes"], description: "Sort order for results" }, page: { type: "number", description: "Page number for pagination (default: 1)" } }, required: ["query"] } } ] };

Other Tools

Related 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