get_package_versions
Retrieve all available versions and release dates of a Dart or Flutter package from pub.dev. Specify the package name and optionally limit the number of versions returned for efficient version management.
Instructions
Get all available versions of a package with their release dates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of versions to return (default: 10) | |
| packageName | Yes | Name of the package to get versions for |
Implementation Reference
- src/pubdev-mcp.ts:346-370 (handler)The main handler function that fetches package versions from the pub.dev API, applies caching, limits the results, and returns a formatted JSON response.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) } ] }; }
- src/pubdev-mcp.ts:204-208 (registration)Registration in the CallToolRequest handler switch statement that routes calls to the getPackageVersions method.case "get_package_versions": return await this.getPackageVersions( args.packageName as string, args.limit as number );
- src/pubdev-mcp.ts:95-112 (schema)Tool registration including name, description, and input schema definition in the ListToolsRequest handler.{ 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"] } },