Skip to main content
Glama
damonxue

OSSInsight MCP Server

get_repo_analysis

Analyze GitHub repository metrics including activity, stars, and issues to gain insights into project performance and trends.

Instructions

Get detailed analysis of a GitHub repository, including activity, stars, issues, and other metrics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
owner_repoYesRepository name in the format 'owner/repo'
time_periodNoTime range for analysis (optional)

Implementation Reference

  • Core handler function that performs the repository analysis by querying the OSSInsight API or falling back to web scraping.
    async function getRepoAnalysis(ownerRepo: string, timePeriod?: string): Promise<any> {
      const [owner, repo] = ownerRepo.split('/');
      if (!owner || !repo) {
        throw new Error('Invalid repository format. Use "owner/repo"');
      }
    
      try {
        // Get repository basic info from API
        const repoResponse = await apiRequest(`/repo/${owner}/${repo}`) as ApiResponse;
        
        // Extract data from response structure (which matches repo.json)
        const repoData = (repoResponse['data'] || repoResponse) as RepositoryData;
        
        // Create a structured response with the available data
        const analysis = {
          basic_info: {
            name: repoData.name,
            full_name: repoData.full_name,
            description: repoData.description,
            html_url: repoData.html_url,
            homepage: repoData.homepage,
            created_at: repoData.created_at,
            updated_at: repoData.updated_at,
            language: repoData.language,
            license: repoData.license,
            topics: repoData.topics
          },
          statistics: {
            stars: repoData.stargazers_count,
            watchers: repoData.watchers_count,
            forks: repoData.forks_count,
            open_issues: repoData.open_issues_count,
            size: repoData.size
          },
          owner: {
            login: repoData.owner?.login,
            type: repoData.owner?.type,
            html_url: repoData.owner?.html_url,
            avatar_url: repoData.owner?.avatar_url
          },
          web_url: `${OSSINSIGHT_WEB_URL}/analyze/${owner}/${repo}`
        };
        
        return analysis;
      } catch (error) {
        // If API fails, try to extract data from the web page
        console.error(`API request failed, falling back to web scraping: ${error}`);
        const webUrl = `${OSSINSIGHT_WEB_URL}/analyze/${owner}/${repo}`;
        
        return {
          message: "API request failed. Falling back to web scraping.",
          web_data: await scrapeOSSInsightPage(webUrl, {
            title: 'h1',
            stars: '.stars-count',
            forks: '.forks-count',
            open_issues: '.issues-count',
            // Add more selectors as needed
          }),
          web_url: webUrl
        };
      }
    }
  • Zod schema defining the input parameters for the get_repo_analysis tool.
    export const GetRepoAnalysisParamsSchema = z.object({
      owner_repo: z.string().describe("Repository name in the format 'owner/repo'"),
      time_period: z.enum(['last_28_days', 'last_90_days', 'last_year', 'all_time']).optional()
        .describe("Time range for analysis (optional)")
    });
  • index.ts:288-291 (registration)
    Registration of the tool in the list of available tools returned by ListToolsRequest.
      name: "get_repo_analysis",
      description: "Get detailed analysis of a GitHub repository, including activity, stars, issues, and other metrics.",
      inputSchema: zodToJsonSchema(GetRepoAnalysisParamsSchema)
    },
  • Dispatch handler in CallToolRequestSchema that parses arguments and invokes the getRepoAnalysis function.
    case "get_repo_analysis": {
      const args = GetRepoAnalysisParamsSchema.parse(request.params.arguments);
      const analysis = await getRepoAnalysis(args.owner_repo, args.time_period);
      return { content: [{ type: "text", text: JSON.stringify(analysis, null, 2) }] };
    }
  • Helper function for making API requests to OSSInsight, used by the getRepoAnalysis handler.
    async function apiRequest(endpoint: string, params: Record<string, any> = {}, useRepoApi: boolean = true) {
      // Build URL and query parameters
      const baseUrl = useRepoApi ? OSSINSIGHT_REPO_API_URL : OSSINSIGHT_API_URL;
      const url = new URL(`${baseUrl}${endpoint}`);
      
      // Add query parameters
      Object.entries(params).forEach(([key, value]) => {
        if (value !== undefined) {
          url.searchParams.append(key, String(value));
        }
      });
    
      // Send request
      const response = await fetch(url.toString(), {
        headers: {
          "Accept": "application/json"
        }
      });
    
      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(`OSSInsight API error: ${response.status} ${response.statusText}\n${errorText}`);
      }
    
      return response.json();
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions what metrics are included, it doesn't describe important behavioral aspects like whether this is a read-only operation, what permissions might be required, whether there are rate limits, what format the analysis returns, or if there are any side effects. The description is too minimal for a tool that presumably makes API calls to GitHub.

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

Conciseness4/5

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

The description is appropriately concise with a single sentence that efficiently communicates the core purpose. It's front-loaded with the main action ('Get detailed analysis') and includes relevant details. There's no wasted verbiage or unnecessary elaboration, though it could benefit from slightly more context.

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 that presumably makes external API calls to GitHub and returns complex analysis data, the description is incomplete. With no annotations and no output schema, the description should provide more context about what 'detailed analysis' includes, what format it returns, any authentication requirements, rate limits, or error conditions. The current description leaves too many important questions unanswered for effective tool use.

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 no specific parameter information beyond what's already in the schema. With 100% schema description coverage, both parameters are well-documented in the schema itself. The description doesn't provide additional context about parameter usage, constraints, or examples that would help an agent understand how to use them effectively.

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 tool's purpose with specific verbs ('Get detailed analysis') and resources ('GitHub repository'), and lists key metrics included (activity, stars, issues). It distinguishes itself from sibling tools like 'get_collection' or 'list_collections' by focusing on repository analysis rather than collections. However, it doesn't explicitly differentiate from 'get_developer_analysis', which might be a related sibling.

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. There's no mention of when this analysis tool is appropriate versus other sibling tools like 'get_developer_analysis' or 'natural_language_query'. It lacks any context about prerequisites, limitations, or typical use cases for repository analysis.

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/damonxue/mcp-ossinsight'

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