Skip to main content
Glama

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
NameRequiredDescriptionDefault
packageNameYesName of the package to get versions for
limitNoMaximum number of versions to return (default: 10)

Implementation Reference

  • 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) } ] }; }
  • 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"]
  • 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"] } },
  • 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);
  • 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) } ] }; }

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