Skip to main content
Glama

github_api_insights_get_subject_stats

Retrieve subject-level API usage statistics for a GitHub organization, filtered by time range and optional subject name substring.

Instructions

Get subject stats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orgYesorg
min_timestampYesThe minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
max_timestampNoThe maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
pageNoThe page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
per_pageNoThe number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
directionNoThe direction to sort the results by.
sortNoThe property to sort the results by.
subject_name_substringNoProviding a substring will filter results where the subject name contains the substring. This is a case-insensitive search.

Implementation Reference

  • The tool definition for 'github_api_insights_get_subject_stats' with schema and handler. The handler makes a GET request to `/orgs/${args.org}/insights/api/subject-stats` with query parameters for min_timestamp, max_timestamp, page, per_page, direction, sort, and subject_name_substring.
      name: "github_api_insights_get_subject_stats",
      description: "Get subject stats",
      inputSchema: z.object({
        org: z.string().describe("org"),
        min_timestamp: z.string().describe("The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`."),
        max_timestamp: z.string().optional().describe("The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`."),
        page: z.number().optional().describe("The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\""),
        per_page: z.number().optional().describe("The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\""),
        direction: z.enum(["asc", "desc"]).optional().describe("The direction to sort the results by."),
        sort: z.array(z.enum(["last_rate_limited_timestamp", "last_request_timestamp", "rate_limited_request_count", "subject_name", "total_request_count"])).optional().describe("The property to sort the results by."),
        subject_name_substring: z.string().optional().describe("Providing a substring will filter results where the subject name contains the substring. This is a case-insensitive search.")
      }),
      handler: async (args: Record<string, any>) => {
        return githubRequest("GET", `/orgs/${args.org}/insights/api/subject-stats`, undefined, { min_timestamp: args.min_timestamp, max_timestamp: args.max_timestamp, page: args.page, per_page: args.per_page, direction: args.direction, sort: args.sort, subject_name_substring: args.subject_name_substring });
      },
    },
  • src/index.ts:87-100 (registration)
    The orgsTools module is imported and registered in the MCP server. The tool array (orgsTools) is included in allToolModules under the 'orgs' category, and each tool is registered via server.tool() in the registration loop.
      { category: "orgs", tools: orgsTools },
      { category: "packages", tools: packagesTools },
      { category: "private-registries", tools: privateRegistriesTools },
      { category: "projects", tools: projectsTools },
      { category: "pulls", tools: pullsTools },
      { category: "rate-limit", tools: rateLimitTools },
      { category: "reactions", tools: reactionsTools },
      { category: "repos", tools: reposTools },
      { category: "search", tools: searchTools },
      { category: "secret-scanning", tools: secretScanningTools },
      { category: "security-advisories", tools: securityAdvisoriesTools },
      { category: "teams", tools: teamsTools },
      { category: "users", tools: usersTools },
    ];
  • The githubRequest helper function used by the handler to make HTTP requests to the GitHub API.
    export async function githubRequest<T>(
      method: string,
      path: string,
      body?: Record<string, unknown>,
      params?: Record<string, string | number | boolean | string[] | undefined>
    ): Promise<T> {
      const url = new URL(`${BASE_URL}${path}`);
    
      if (params) {
        for (const [key, value] of Object.entries(params)) {
          if (value === undefined || value === null || value === "") continue;
          if (Array.isArray(value)) {
            url.searchParams.set(key, value.join(","));
          } else {
            url.searchParams.set(key, String(value));
          }
        }
      }
    
      const headers: Record<string, string> = {
        Authorization: `Bearer ${getToken()}`,
        Accept: "application/vnd.github+json",
        "X-GitHub-Api-Version": "2022-11-28",
        "User-Agent": "github-mcp/1.0.0",
      };
    
      if (body) {
        headers["Content-Type"] = "application/json";
      }
    
      const res = await fetch(url.toString(), {
        method,
        headers,
        body: body ? JSON.stringify(body) : undefined,
      });
    
      if (!res.ok) {
        const text = await res.text().catch(() => "");
        let detail = text;
        try {
          const json = JSON.parse(text);
          detail = json.message || text;
          if (json.errors) detail += ` -- ${JSON.stringify(json.errors)}`;
        } catch {}
        throw new Error(`GitHub API error ${res.status}: ${detail}`);
      }
    
      if (res.status === 204) return {} as T;
    
      return res.json() as Promise<T>;
    }
Behavior1/5

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

No annotations are present, and the description omits behavioral traits like read-only/write, side effects, authentication needs, rate limits, or pagination behavior. The tool's behavior is completely opaque.

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

Conciseness1/5

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

The description is a single phrase 'Get subject stats', which is under-specified rather than concise. It lacks necessary detail and does not earn its brevity.

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

Completeness1/5

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

With 8 parameters, no output schema, and no annotations, the description is inadequate. It fails to explain the meaning of 'subject', the nature of the stats, or how to interpret results, leaving significant gaps for an AI agent.

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%, and many parameter descriptions are detailed (e.g., ISO 8601 format, pagination links, sort options). The description adds no extra meaning beyond what the schema already provides, so baseline score applies.

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

Purpose2/5

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

The description 'Get subject stats' is vague. It names a verb and resource but 'subject' is undefined, leaving the tool's exact purpose unclear, especially compared to sibling tools like get_summary_stats or get_route_stats_by_actor.

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?

No usage guidelines are provided. The description does not indicate when to use this tool over alternatives, such as other stats tools in the same server, nor does it mention prerequisites or context.

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/Eyalm321/github-mcp'

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