Skip to main content
Glama

get_copilot_metrics_for_enterprise

Retrieve daily GitHub Copilot usage metrics for enterprise-wide analysis, including code completions, chat activity, active users, and language/editor breakdowns.

Instructions

Get daily Copilot usage metrics for the entire GitHub Enterprise (code completions, chat usage, active users, language/editor breakdown)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enterpriseNoEnterprise slug (defaults to GITHUB_ENTERPRISE env var)
sinceNoStart date in YYYY-MM-DD format (defaults to 28 days ago)
untilNoEnd date in YYYY-MM-DD format (defaults to today)
force_refreshNoIgnore cache and fetch fresh data

Implementation Reference

  • The async handler function that implements the logic for 'get_copilot_metrics_for_enterprise' tool, including input validation, parameter defaults, and invoking the GitHub client.
    async ({ enterprise, since, until, force_refresh }) => {
      try {
        const ent = enterprise ?? defaultEnterprise;
        if (!ent) {
          return { content: [{ type: "text", text: "Enterprise slug is required. Set GITHUB_ENTERPRISE or pass 'enterprise' parameter." }], isError: true };
        }
    
        const today = new Date().toISOString().split("T")[0];
        const defaultSince = new Date();
        defaultSince.setUTCDate(defaultSince.getUTCDate() - 28);
        const s = since ?? defaultSince.toISOString().split("T")[0];
        const u = until ?? today;
    
        validateDateRange(s, u);
    
        const metrics = await client.fetchMetrics("enterprise", ent, s, u, force_refresh ?? false, { identifier: ent });
    
        return { content: [{ type: "text", text: JSON.stringify(metrics, null, 2) }] };
      } catch (error) {
        return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
      }
    }
  • The registration of 'get_copilot_metrics_for_enterprise' tool using the MCP server's tool registration method.
    server.tool(
      "get_copilot_metrics_for_enterprise",
      "Get daily Copilot usage metrics for the entire GitHub Enterprise (code completions, chat usage, active users, language/editor breakdown)",
      {
        enterprise: z.string().optional().describe("Enterprise slug (defaults to GITHUB_ENTERPRISE env var)"),
        since: z.string().optional().describe("Start date in YYYY-MM-DD format (defaults to 28 days ago)"),
        until: z.string().optional().describe("End date in YYYY-MM-DD format (defaults to today)"),
        force_refresh: z.boolean().optional().describe("Ignore cache and fetch fresh data"),
      },
      async ({ enterprise, since, until, force_refresh }) => {
        try {
          const ent = enterprise ?? defaultEnterprise;
          if (!ent) {
            return { content: [{ type: "text", text: "Enterprise slug is required. Set GITHUB_ENTERPRISE or pass 'enterprise' parameter." }], isError: true };
          }
    
          const today = new Date().toISOString().split("T")[0];
          const defaultSince = new Date();
          defaultSince.setUTCDate(defaultSince.getUTCDate() - 28);
          const s = since ?? defaultSince.toISOString().split("T")[0];
          const u = until ?? today;
    
          validateDateRange(s, u);
    
          const metrics = await client.fetchMetrics("enterprise", ent, s, u, force_refresh ?? false, { identifier: ent });
    
          return { content: [{ type: "text", text: JSON.stringify(metrics, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );

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/tatsuyamiyazaki/copilot-usage-mcp'

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