Skip to main content
Glama
devqxi

Pub.dev MCP Server

by devqxi

get_package_info

Retrieve detailed information about Dart and Flutter packages from pub.dev, including version data, dependencies, and documentation for development analysis.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNameYesName of the package to retrieve information for

Implementation Reference

  • The primary handler function that implements the get_package_info tool. It fetches package data from pub.dev API using caching, extracts relevant information into a structured PackageInfo object, 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)
          }
        ]
      };
    }
  • Registration of the get_package_info tool in the ListToolsRequestHandler, including name, description, and input schema.
    {
      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 output structure for package information used in the handler.
    interface PackageInfo {
      name: string;
      version: string;
      description?: string;
      homepage?: string;
      repository?: string;
      publishedAt: string;
      dependencies?: Record<string, string>;
      devDependencies?: Record<string, string>;
    }
  • Dispatch case in the CallToolRequestHandler that routes calls to the getPackageInfo method.
    case "get_package_info":
      return await this.getPackageInfo(args.packageName as string);
  • Helper method for fetching data from pub.dev with caching, used by the getPackageInfo handler.
    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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool does, not how it behaves. It doesn't disclose whether this is a read-only operation, if it requires authentication, rate limits, error conditions, or what format the detailed information returns. The description adds no behavioral context beyond the basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core purpose without unnecessary words. It's appropriately sized for a single-parameter tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what 'detailed information' includes, the response format, potential errors, or behavioral constraints. Given the lack of structured data, the description should provide more context about the tool's operation and outputs.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single 'packageName' parameter adequately. The description doesn't add any parameter-specific details beyond what the schema provides (like examples of package names or format requirements), meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get detailed information'), target resource ('Dart/Flutter package'), and source ('from pub.dev'). It distinguishes from sibling tools like 'get_package_versions' (which focuses on version history) and 'search_packages' (which searches multiple packages).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when detailed package information is needed, but doesn't explicitly state when to use this tool versus alternatives like 'get_package_versions' for version-specific data or 'check_package_updates' for update information. No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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