get_github_actions
Retrieve available GitHub Actions workflows from a repository to understand automation options and trigger points.
Instructions
Get available GitHub Actions for a repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Owner of the repository (username or organization) | |
| repo | Yes | Name of the repository | |
| token | No | GitHub personal access token (optional) |
Implementation Reference
- src/index.ts:662-720 (handler)The core handler function that fetches GitHub Actions workflows from the specified repository using the GitHub API, including workflow details and file contents.async function getGitHubActions(owner: string, repo: string, token?: string) { // Use provided token or fall back to config token const authToken = token || config.githubToken; try { const headers: Record<string, string> = { 'Accept': 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28' }; if (authToken) { headers['Authorization'] = `Bearer ${authToken}`; } // Fetch workflows from the GitHub API const workflowsResponse = await axios.get( `https://api.github.com/repos/${owner}/${repo}/actions/workflows`, { headers } ); // Extract workflow information const workflows = workflowsResponse.data.workflows.map((workflow: any) => ({ id: workflow.id, name: workflow.name, path: workflow.path, state: workflow.state, url: workflow.html_url })); // For each workflow, get the associated jobs const workflowDetails = await Promise.all( workflows.map(async (workflow: any) => { try { // Get the raw workflow file content const contentResponse = await axios.get( `https://api.github.com/repos/${owner}/${repo}/contents/${workflow.path}`, { headers } ); const content = Buffer.from(contentResponse.data.content, 'base64').toString('utf-8'); return { ...workflow, content }; } catch (error) { // If we can't get the content, just return the workflow without it return workflow; } }) ); return workflowDetails; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`GitHub API error: ${error.response?.status} ${error.response?.statusText} - ${error.response?.data?.message || error.message}`); } throw error; } }
- src/index.ts:108-129 (schema)The input schema definition for the get_github_actions tool, including parameters owner, repo, and optional token.{ name: "get_github_actions", description: "Get available GitHub Actions for a repository", inputSchema: { type: "object", properties: { owner: { type: "string", description: "Owner of the repository (username or organization)" }, repo: { type: "string", description: "Name of the repository" }, token: { type: "string", description: "GitHub personal access token (optional)" } }, required: ["owner", "repo"] } },
- src/index.ts:728-752 (registration)The registration and dispatch logic in the CallToolRequestSchema handler that processes calls to get_github_actions and invokes the core handler function.case "get_github_actions": { const owner = String(request.params.arguments?.owner); const repo = String(request.params.arguments?.repo); const token = request.params.arguments?.token ? String(request.params.arguments?.token) : undefined; if (!owner || !repo) { throw new Error("Owner and repo are required"); } try { const actions = await getGitHubActions(owner, repo, token); return { content: [{ type: "text", text: JSON.stringify(actions, null, 2) }] }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get GitHub Actions: ${error.message}`); } throw error; } }