get_package_versions
Retrieve available versions and release dates for Dart/Flutter packages from pub.dev to manage dependencies and track updates.
Instructions
Get all available versions of a package with their release dates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packageName | Yes | Name of the package to get versions for | |
| limit | No | Maximum number of versions to return (default: 10) |
Implementation Reference
- src/pubdev-mcp.js:265-287 (handler)The handler function that implements the core logic for the 'get_package_versions' tool: fetches package versions from pub.dev API with caching, limits to the specified number, and formats as JSON response.async getPackageVersions(packageName, limit = 10) { const url = `https://pub.dev/api/packages/${packageName}/versions`; const data = await this.fetchWithCache(url, `versions-${packageName}`); const versions = data.versions .slice(0, limit) .map((v) => ({ version: v.version, publishedAt: v.published, description: v.pubspec?.description })); return { content: [ { type: "text", text: JSON.stringify({ packageName, totalVersions: data.versions.length, versions }, null, 2) } ] }; }
- src/pubdev-mcp.js:60-72 (schema)Input schema definition for the 'get_package_versions' tool, specifying packageName as required and limit as optional.inputSchema: { type: "object", properties: { packageName: { type: "string", description: "Name of the package to get versions for" }, limit: { type: "number", description: "Maximum number of versions to return (default: 10)" } }, required: ["packageName"]
- src/pubdev-mcp.js:57-74 (registration)Tool registration in the list of available tools, including name, description, and input schema.{ name: "get_package_versions", description: "Get all available versions of a package with their release dates", inputSchema: { type: "object", properties: { packageName: { type: "string", description: "Name of the package to get versions for" }, limit: { type: "number", description: "Maximum number of versions to return (default: 10)" } }, required: ["packageName"] } },
- src/pubdev-mcp.js:158-159 (registration)Switch case that registers and routes incoming tool calls for 'get_package_versions' to the handler method.case "get_package_versions": return await this.getPackageVersions(args.packageName, args.limit);
- src/pubdev-mcp.ts:346-370 (handler)TypeScript version of the handler function implementing the 'get_package_versions' tool logic with type annotations.private async getPackageVersions(packageName: string, limit: number = 10) { const url = `https://pub.dev/api/packages/${packageName}/versions`; const data = await this.fetchWithCache<any>(url, `versions-${packageName}`); const versions: PackageVersion[] = data.versions .slice(0, limit) .map((v: any) => ({ version: v.version, publishedAt: v.published, description: v.pubspec?.description })); return { content: [ { type: "text", text: JSON.stringify({ packageName, totalVersions: data.versions.length, versions }, null, 2) } ] }; }