github_code_scanning_update_alert
Update a GitHub code scanning alert by sending a request body with new details.
Instructions
Update a code scanning alert
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | owner | |
| repo | Yes | repo | |
| alert_number | Yes | alert_number | |
| body | No | Request body (JSON object) |
Implementation Reference
- src/tools/code-scanning.ts:72-74 (handler)The handler function that executes the 'github_code_scanning_update_alert' tool logic. It sends a PATCH request to the GitHub API to update a code scanning alert.
handler: async (args: Record<string, any>) => { return githubRequest("PATCH", `/repos/${args.owner}/${args.repo}/code-scanning/alerts/${args.alert_number}`, args.body, undefined); }, - src/tools/code-scanning.ts:66-71 (schema)Input schema for the tool using Zod validation. Expects 'owner', 'repo', 'alert_number' (all strings), and an optional 'body' (JSON object).
inputSchema: z.object({ owner: z.string().describe("owner"), repo: z.string().describe("repo"), alert_number: z.string().describe("alert_number"), body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON object)") }), - src/tools/code-scanning.ts:64-65 (registration)Tool name and description registration. The tool is defined as part of the exported 'codeScanningTools' array.
name: "github_code_scanning_update_alert", description: "Update a code scanning alert", - src/index.ts:64-64 (registration)The 'codeScanningTools' array is registered as a tool module in the MCP server under the 'code-scanning' category.
{ category: "code-scanning", tools: codeScanningTools }, - src/client.ts:9-59 (helper)The githubRequest helper function that makes authenticated HTTP requests to the GitHub API. Used by the handler to perform the PATCH request.
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>; }