Skip to main content
Glama
onemarc

GitHub Actions MCP Server

by onemarc

create_workflow

Automate GitHub repository processes by generating a new GitHub Actions workflow file. Specify triggers, jobs, and file path to streamline CI/CD pipelines.

Instructions

Create a new GitHub Actions workflow file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNoBranch to create the workflow onmain
commitMessageNoCommit messageAdd GitHub Actions workflow
jobsYesJobs configuration
nameYesWorkflow name - should be descriptive and related to the workflow's purpose
onYesTrigger events (e.g., {push: {branches: ['main']}, pull_request: {}})
ownerYesRepository owner
pathYesPath for the workflow file (e.g., '.github/workflows/ci.yml')
repoYesRepository name

Implementation Reference

  • The main handler function that implements the create_workflow tool. It generates YAML content for a GitHub Actions workflow based on input args and uses Octokit to create or update the file in the repository.
    const handleCreateWorkflow: ToolHandler = async (args, octokit: Octokit) => { const { owner, repo, path, name, on: triggerEvents, jobs, branch = "main", commitMessage = "Add GitHub Actions workflow" } = args; // Create workflow YAML content let modifiedTriggerEvents = { ...triggerEvents }; if (!modifiedTriggerEvents) { modifiedTriggerEvents = {}; } // Add workflow_dispatch if not already present if (!modifiedTriggerEvents.workflow_dispatch) { modifiedTriggerEvents.workflow_dispatch = {}; } const formattedTriggerEvents = JSON.stringify(modifiedTriggerEvents, null, 2).replace(/"/g, ''); const yamlContent = `name: ${name} on: ${formattedTriggerEvents} jobs: ${Object.entries(jobs || {}).map(([jobName, jobConfig]: [string, any]) => { return ` ${jobName}: runs-on: ${jobConfig['runs-on'] || 'ubuntu-latest'} ${jobConfig.steps ? ' steps:' : ''} ${jobConfig.steps ? jobConfig.steps.map((step: any, index: number) => { let stepYaml = ` - name: ${step.name || `Step ${index + 1}`}`; if (step.uses) stepYaml += `\n uses: ${step.uses}`; if (step.run) stepYaml += `\n run: ${step.run}`; if (step.with) stepYaml += `\n with:\n${Object.entries(step.with || {}).map(([key, value]) => ` ${key}: ${value}`).join('\n')}`; if (step.env) stepYaml += `\n env:\n${Object.entries(step.env || {}).map(([key, value]) => ` ${key}: ${value}`).join('\n')}`; return stepYaml; }).join('\n') : ''}`; }).join('\n\n')}`; try { const response = await octokit.rest.repos.createOrUpdateFileContents({ owner, repo, path, message: commitMessage, content: Buffer.from(yamlContent).toString('base64'), branch }); return { success: true, message: "Workflow created successfully", data: { path, sha: response.data.content?.sha, url: response.data.content?.html_url } }; } catch (error: any) { throw new WorkflowError(`Failed to create workflow: ${error.message}`, error.response?.data); } };
  • The input schema and metadata definition for the create_workflow tool, specifying properties, descriptions, and required fields.
    name: "create_workflow", description: "Create a new GitHub Actions workflow file", inputSchema: { type: "object", properties: { owner: { type: "string", description: "Repository owner" }, repo: { type: "string", description: "Repository name" }, path: { type: "string", description: "Path for the workflow file (e.g., '.github/workflows/ci.yml')" }, name: { type: "string", description: "Workflow name - should be descriptive and related to the workflow's purpose" }, on: { type: "object", description: "Trigger events (e.g., {push: {branches: ['main']}, pull_request: {}})" }, jobs: { type: "object", description: "Jobs configuration" }, branch: { type: "string", description: "Branch to create the workflow on", default: "main" }, commitMessage: { type: "string", description: "Commit message", default: "Add GitHub Actions workflow" } }, required: ["owner", "repo", "path", "name", "on", "jobs"] } },
  • Registration of all tool handlers, including create_workflow mapped to its handler function.
    export const toolHandlers: Record<string, ToolHandler> = { create_workflow: handleCreateWorkflow, list_workflows: handleListWorkflows, get_workflow: handleGetWorkflow, get_workflow_usage: handleGetWorkflowUsage, list_workflow_runs: handleListWorkflowRuns, get_workflow_run: handleGetWorkflowRun, get_workflow_run_jobs: handleGetWorkflowRunJobs, trigger_workflow: handleTriggerWorkflow, cancel_workflow_run: handleCancelWorkflowRun, rerun_workflow: handleRerunWorkflow, };

Other Tools

Related Tools

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/onemarc/github-actions-mcp-server'

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