github_apps_create_installation_access_token
Create an installation access token for a GitHub App to authenticate API requests on behalf of an installation.
Instructions
Create an installation access token for an app
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| installation_id | Yes | installation_id | |
| body | No | Request body (JSON object) |
Implementation Reference
- src/tools/apps.ts:125-127 (handler)Handler function that makes a POST request to create an installation access token for a GitHub App. Uses installation_id from args and accepts an optional body.
handler: async (args: Record<string, any>) => { return githubRequest("POST", `/app/installations/${args.installation_id}/access_tokens`, args.body, undefined); }, - src/tools/apps.ts:121-124 (schema)Input schema defines two parameters: installation_id (required string) and body (optional JSON object).
inputSchema: z.object({ installation_id: z.string().describe("installation_id"), body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON object)") }), - src/index.ts:8-8 (registration)Import of appsTools array into the main index.ts file where tools are registered with the MCP server.
import { appsTools } from "./tools/apps.js"; - src/index.ts:110-129 (registration)Registration loop that registers all tools (including appsTools) with the MCP server via server.tool().
for (const tool of allTools) { server.tool( tool.name, tool.description, tool.inputSchema.shape as any, async (args: any) => { try { const result = await tool.handler(args as any); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } } ); - src/client.ts:9-47 (helper)The githubRequest helper function that performs HTTP requests to the GitHub API. Used by the handler to make the POST 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;