Skip to main content
Glama
Aas-ee
by Aas-ee

fetchGithubReadme

Extract README content from any GitHub repository using the repository URL. Simplify access to project documentation without manual navigation.

Instructions

Fetch README content from a GitHub repository URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • Registers the 'fetchGithubReadme' MCP tool (configurable via MCP_TOOL_FETCH_GITHUB_NAME env var) with input schema and execution handler.
    server.tool(
        fetchGithubToolName,
        "Fetch README content from a GitHub repository URL",
        {
            url: z.string().min(1).refine(
                (url) => validateGithubUrl(url),
                "URL must be a valid GitHub repository URL (supports HTTPS, SSH formats)"
            )
        },
        async ({url}) => {
            try {
                console.error(`Fetching GitHub README: ${url}`);
                const result = await fetchGithubReadme(url);
    
                if (result) {
                    return {
                        content: [{
                            type: 'text',
                            text: result
                        }]
                    };
                } else {
                    return {
                        content: [{
                            type: 'text',
                            text: 'README not found or repository does not exist'
                        }],
                        isError: true
                    };
                }
            } catch (error) {
                console.error('Failed to fetch GitHub README:', error);
                return {
                    content: [{
                        type: 'text',
                        text: `Failed to fetch README: ${error instanceof Error ? error.message : 'Unknown error'}`
                    }],
                    isError: true
                };
            }
        }
    );
  • Main exported handler function for fetching GitHub README content from repository URL.
    export async function fetchGithubReadme(githubUrl: string): Promise<string | null> {
        return getReadmeFromUrl(githubUrl);
    }
  • Input schema using Zod to validate GitHub repository URL.
    {
        url: z.string().min(1).refine(
            (url) => validateGithubUrl(url),
            "URL must be a valid GitHub repository URL (supports HTTPS, SSH formats)"
        )
    },
  • Helper function to validate GitHub repository URLs (HTTPS and SSH formats) used in schema refinement.
    const validateGithubUrl = (url: string): boolean => {
        try {
    
            const isSshGithub = /^git@github\.com:/.test(url);
    
            if (isSshGithub) {
                // SSH 格式: git@github.com:owner/repo.git
                return /^git@github\.com:[^\/]+\/[^\/]+/.test(url);
            }
    
            const urlObj = new URL(url);
    
            // 支持多种 GitHub URL 格式
            const isHttpsGithub = urlObj.hostname === 'github.com' || urlObj.hostname === 'www.github.com';
    
            if (isHttpsGithub) {
                // 检查路径格式: /owner/repo
                const pathParts = urlObj.pathname.split('/').filter(part => part.length > 0);
                return pathParts.length >= 2;
            }
    
            return false;
        } catch {
            return false;
        }
    };
  • Helper to extract owner and repo from GitHub URLs (HTTPS, SSH). Used in README fetching logic.
    function extractOwnerAndRepo(url: string): { owner: string; repo: string } | null {
        try {
            const normalizedUrl = url.trim().toLowerCase();
    
            // Regex patterns for HTTPS and SSH URLs
            const patterns = [
                /(?:https?:\/\/)?(?:www\.)?github\.com\/([^\/\s]+)\/([^\/\s]+)/i,
                /git@github\.com:([^\/\s]+)\/([^\/\s]+)\.git/i
            ];
    
            for (const pattern of patterns) {
                const match = url.match(pattern);
                if (match) {
                    const [, owner, rawRepo] = match;
    
                    // Clean repo name: remove query params, fragments, .git suffix, paths
                    const repo = rawRepo.replace(/(?:[?#].*$|\.git$|\/.*$)/g, '');
                    if (owner && repo && owner.length > 0 && repo.length > 0) {
                        return { owner: owner.trim(), repo: repo.trim() };
                    }
                }
            }
    
            return null;
        } catch (error) {
            console.warn('Failed to parse GitHub URL:', url, error);
            return null;
        }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't mention error handling (e.g., invalid URLs, private repos), rate limits, authentication needs, or output format. This leaves significant gaps in understanding how the tool behaves beyond the basic fetch operation.

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, clear sentence with zero wasted words. It's front-loaded with the core purpose and efficiently communicates the essential information without unnecessary elaboration.

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?

Given no annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't address error cases, return format, or behavioral constraints that an agent would need to use this tool effectively in real-world scenarios.

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?

The description adds minimal semantic context beyond the schema: it implies the 'url' parameter should be a GitHub repository URL. However, with 0% schema description coverage and only one parameter, this provides some value but doesn't fully compensate for the lack of schema documentation (e.g., URL format expectations).

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

Purpose4/5

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

The description clearly states the action ('Fetch') and resource ('README content from a GitHub repository URL'), making the tool's purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'fetchCsdnArticle' or 'fetchJuejinArticle' beyond specifying GitHub as the source, which is a minor gap.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'search' or other fetch tools. It mentions GitHub specifically, but doesn't explain when to prefer this over general search or other content-fetching tools, leaving usage context implied at best.

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

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/Aas-ee/open-webSearch'

If you have feedback or need assistance with the MCP directory API, please join our Discord server