github_code_scanning_get_variant_analysis_repo_task
Retrieve the analysis status of a repository in a CodeQL variant analysis to monitor code scanning progress and results.
Instructions
Get the analysis status of a repository in a CodeQL variant analysis
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | owner | |
| repo | Yes | repo | |
| codeql_variant_analysis_id | Yes | codeql_variant_analysis_id | |
| repo_owner | Yes | repo_owner | |
| repo_name | Yes | repo_name |
Implementation Reference
- src/tools/code-scanning.ts:243-245 (handler)The handler function that executes the tool logic. It makes a GET request to the GitHub API to get the analysis status of a repository in a CodeQL variant analysis.
handler: async (args: Record<string, any>) => { return githubRequest("GET", `/repos/${args.owner}/${args.repo}/code-scanning/codeql/variant-analyses/${args.codeql_variant_analysis_id}/repos/${args.repo_owner}/${args.repo_name}`, undefined, undefined); }, - src/tools/code-scanning.ts:236-241 (schema)Zod schema defining the input parameters: owner, repo, codeql_variant_analysis_id, repo_owner, and repo_name.
inputSchema: z.object({ owner: z.string().describe("owner"), repo: z.string().describe("repo"), codeql_variant_analysis_id: z.string().describe("codeql_variant_analysis_id"), repo_owner: z.string().describe("repo_owner"), repo_name: z.string().describe("repo_name") - src/tools/code-scanning.ts:234-246 (registration)The tool definition object in the codeScanningTools array, containing name, description, inputSchema, and handler.
name: "github_code_scanning_get_variant_analysis_repo_task", description: "Get the analysis status of a repository in a CodeQL variant analysis", inputSchema: z.object({ owner: z.string().describe("owner"), repo: z.string().describe("repo"), codeql_variant_analysis_id: z.string().describe("codeql_variant_analysis_id"), repo_owner: z.string().describe("repo_owner"), repo_name: z.string().describe("repo_name") }), handler: async (args: Record<string, any>) => { return githubRequest("GET", `/repos/${args.owner}/${args.repo}/code-scanning/codeql/variant-analyses/${args.codeql_variant_analysis_id}/repos/${args.repo_owner}/${args.repo_name}`, undefined, undefined); }, }, - src/client.ts:9-58 (helper)The githubRequest helper function used by the handler to make authenticated 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>;