Skip to main content
Glama
devqxi

Pub.dev MCP Server

by devqxi

get_documentation_changes

Retrieve and compare documentation versions for Dart/Flutter packages to track updates in readme, changelog, examples, or API docs.

Instructions

Get documentation content and detect changes for a package

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNameYesName of the package to get documentation for
versionNoSpecific version (optional, defaults to latest)
docTypeNoType of documentation to retrieve

Implementation Reference

  • The core handler function `getDocumentationChanges` that implements the tool logic: constructs URL based on docType, fetches content from pub.dev, extracts text from HTML (except API docs), limits content size, and returns JSON with documentation details.
    async getDocumentationChanges(packageName, version, docType = 'readme') {
        let baseUrl;
        if (version) {
            baseUrl = `https://pub.dev/packages/${packageName}/versions/${version}`;
        }
        else {
            baseUrl = `https://pub.dev/packages/${packageName}`;
        }
        let docUrl;
        let contentType;
        switch (docType) {
            case 'readme':
                docUrl = `${baseUrl}/readme`;
                contentType = 'README';
                break;
            case 'changelog':
                docUrl = `${baseUrl}/changelog`;
                contentType = 'CHANGELOG';
                break;
            case 'example':
                docUrl = `${baseUrl}/example`;
                contentType = 'Example';
                break;
            case 'api_docs':
                docUrl = `https://pub.dev/documentation/${packageName}/${version || 'latest'}/`;
                contentType = 'API Documentation';
                break;
            default:
                throw new Error(`Unsupported documentation type: ${docType}`);
        }
        try {
            const response = await fetch(docUrl);
            let content;
            if (response.ok) {
                content = await response.text();
                // Extract meaningful content from HTML if needed
                if (docType !== 'api_docs') {
                    content = this.extractTextFromHtml(content);
                }
            }
            else {
                content = `${contentType} not available for this package/version`;
            }
            const docChange = {
                type: docType,
                content: content.substring(0, 5000), // Limit content size
                lastModified: response.headers.get('last-modified') || undefined
            };
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify({
                            packageName,
                            version: version || 'latest',
                            documentationType: docType,
                            documentation: docChange
                        }, null, 2)
                    }
                ]
            };
        }
        catch (error) {
            throw new Error(`Failed to fetch documentation: ${error}`);
        }
  • Tool registration in the ListToolsRequestHandler, defining the tool name, description, and input schema.
    {
        name: "get_documentation_changes",
        description: "Get documentation content and detect changes for a package",
        inputSchema: {
            type: "object",
            properties: {
                packageName: {
                    type: "string",
                    description: "Name of the package to get documentation for"
                },
                version: {
                    type: "string",
                    description: "Specific version (optional, defaults to latest)"
                },
                docType: {
                    type: "string",
                    enum: ["readme", "changelog", "example", "api_docs"],
                    description: "Type of documentation to retrieve"
                }
            },
            required: ["packageName"]
        }
    },
  • Input schema for the tool, validating packageName (required string), optional version string, and docType string with enum values.
    inputSchema: {
        type: "object",
        properties: {
            packageName: {
                type: "string",
                description: "Name of the package to get documentation for"
            },
            version: {
                type: "string",
                description: "Specific version (optional, defaults to latest)"
            },
            docType: {
                type: "string",
                enum: ["readme", "changelog", "example", "api_docs"],
                description: "Type of documentation to retrieve"
            }
        },
        required: ["packageName"]
    }
  • Switch case dispatcher in CallToolRequestHandler that invokes the getDocumentationChanges handler with parsed arguments.
    case "get_documentation_changes":
        return await this.getDocumentationChanges(args.packageName, args.version, args.docType);
  • TypeScript interface defining the structure of the documentation change output used in the handler.
    interface DocumentationChange {
      type: 'readme' | 'changelog' | 'example' | 'api_docs';
      content: string;
      lastModified?: string;
    }

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