Skip to main content
Glama

get_package_info

Retrieve detailed information about Dart and Flutter packages from pub.dev, including version, dependencies, and documentation, using a specific package name.

Instructions

Get detailed information about a Dart/Flutter package from pub.dev

Input Schema

NameRequiredDescriptionDefault
packageNameYesName of the package to retrieve information for

Input Schema (JSON Schema)

{ "properties": { "packageName": { "description": "Name of the package to retrieve information for", "type": "string" } }, "required": [ "packageName" ], "type": "object" }

Implementation Reference

  • The main handler function that fetches package data from pub.dev API using caching, extracts relevant information, and returns formatted JSON response.
    private async getPackageInfo(packageName: string) { const url = `https://pub.dev/api/packages/${packageName}`; const data = await this.fetchWithCache<any>(url, `package-${packageName}`); const packageInfo: PackageInfo = { name: data.name, version: data.latest.version, description: data.latest.pubspec?.description, homepage: data.latest.pubspec?.homepage, repository: data.latest.pubspec?.repository, publishedAt: data.latest.published, dependencies: data.latest.pubspec?.dependencies, devDependencies: data.latest.pubspec?.dev_dependencies }; return { content: [ { type: "text", text: JSON.stringify({ package: packageInfo, stats: { likes: data.likes, points: data.points, popularity: data.popularity }, publishers: data.publishers, uploaders: data.uploaders }, null, 2) } ] }; }
  • Tool registration in the listTools handler, including name, description, and input schema definition.
    name: "get_package_info", description: "Get detailed information about a Dart/Flutter package from pub.dev", inputSchema: { type: "object", properties: { packageName: { type: "string", description: "Name of the package to retrieve information for" } }, required: ["packageName"] } },
  • TypeScript interface defining the structure of package information used in the handler.
    name: string; version: string; description?: string; homepage?: string; repository?: string; publishedAt: string; dependencies?: Record<string, string>; devDependencies?: Record<string, string>; }
  • Dispatcher case in the CallToolRequestSchema handler that routes to the getPackageInfo method.
    case "get_package_info": return await this.getPackageInfo(args.packageName as string);
  • Caching utility function used by getPackageInfo to fetch and cache API responses.
    private async fetchWithCache<T>(url: string, cacheKey: string): Promise<T> { const cached = this.packageCache.get(cacheKey); const now = Date.now(); if (cached && (now - cached.timestamp) < this.CACHE_DURATION) { return cached.data as T; } const response = await fetch(url, { headers: { 'User-Agent': 'MCP-PubDev-Server/1.0.0', 'Accept': 'application/json' } }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json() as T; this.packageCache.set(cacheKey, { data, timestamp: now }); return data; }

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