Skip to main content
Glama
CircleCI-Public

mcp-server-circleci

Official

run_pipeline

Trigger a new CircleCI pipeline and get a URL to monitor its progress using project slug, direct URL, or workspace detection.

Instructions

This tool triggers a new CircleCI pipeline and returns the URL to monitor its progress.

Input options (EXACTLY ONE of these THREE options must be used):

Option 1 - Project Slug and branch (BOTH required):
- projectSlug: The project slug obtained from listFollowedProjects tool (e.g., "gh/organization/project")
- branch: The name of the branch (required when using projectSlug)

Option 2 - Direct URL (provide ONE of these):
- projectURL: The URL of the CircleCI project in any of these formats:
  * Project URL with branch: https://app.circleci.com/pipelines/gh/organization/project?branch=feature-branch
  * Pipeline URL: https://app.circleci.com/pipelines/gh/organization/project/123
  * Workflow URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def
  * Job URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def/jobs/xyz

Option 3 - Project Detection (ALL of these must be provided together):
- workspaceRoot: The absolute path to the workspace root
- gitRemoteURL: The URL of the git remote repository
- branch: The name of the current branch

Configuration:
- an optional configContent parameter can be provided to override the default pipeline configuration

Pipeline Selection:
- If the project has multiple pipeline definitions, the tool will return a list of available pipelines
- You must then make another call with the chosen pipeline name using the pipelineChoiceName parameter
- The pipelineChoiceName must exactly match one of the pipeline names returned by the tool
- If the project has only one pipeline definition, pipelineChoiceName is not needed

Additional Requirements:
- Never call this tool with incomplete parameters
- If using Option 1, make sure to extract the projectSlug exactly as provided by listFollowedProjects
- If using Option 2, the URLs MUST be provided by the user - do not attempt to construct or guess URLs
- If using Option 3, ALL THREE parameters (workspaceRoot, gitRemoteURL, branch) must be provided
- If none of the options can be fully satisfied, ask the user for the missing information before making the tool call

Returns:
- A URL to the newly triggered pipeline that can be used to monitor its progress

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNo

Implementation Reference

  • The main handler function for the 'run_pipeline' tool. It determines the project slug and branch from inputs, fetches pipeline definitions, handles multiple choices, and triggers the pipeline using the CircleCI client.
    export const runPipeline: ToolCallback<{
      params: typeof runPipelineInputSchema;
    }> = async (args) => {
      const {
        workspaceRoot,
        gitRemoteURL,
        branch,
        configContent,
        projectURL,
        pipelineChoiceName,
        projectSlug: inputProjectSlug,
      } = args.params ?? {};
    
      let projectSlug: string | undefined;
      let branchFromURL: string | undefined;
      const baseURL = getAppURL();
      if (inputProjectSlug) {
        if (!branch) {
          return mcpErrorOutput(
            'Branch not provided. When using projectSlug, a branch must also be specified.',
          );
        }
        projectSlug = inputProjectSlug;
      } else if (projectURL) {
        projectSlug = getProjectSlugFromURL(projectURL);
        branchFromURL = getBranchFromURL(projectURL);
      } else if (workspaceRoot && gitRemoteURL && branch) {
        projectSlug = await identifyProjectSlug({
          gitRemoteURL,
        });
      } else {
        return mcpErrorOutput(
          'Missing required inputs. Please provide either: 1) projectSlug with branch, 2) projectURL, or 3) workspaceRoot with gitRemoteURL and branch.',
        );
      }
    
      if (!projectSlug) {
        return mcpErrorOutput(`
              Project not found. Ask the user to provide the inputs user can provide based on the tool description.
    
              Project slug: ${projectSlug}
              Git remote URL: ${gitRemoteURL}
              Branch: ${branch}
              `);
      }
      const foundBranch = branchFromURL || branch;
      if (!foundBranch) {
        return mcpErrorOutput(
          'No branch provided. Ask the user to provide the branch.',
        );
      }
    
      const circleci = getCircleCIClient();
      const { id: projectId } = await circleci.projects.getProject({
        projectSlug,
      });
      const pipelineDefinitions = await circleci.pipelines.getPipelineDefinitions({
        projectId,
      });
    
      const pipelineChoices = [
        ...pipelineDefinitions.map((definition) => ({
          name: definition.name,
          definitionId: definition.id,
        })),
      ];
    
      if (pipelineChoices.length === 0) {
        return mcpErrorOutput(
          'No pipeline definitions found. Please make sure your project is set up on CircleCI to run pipelines.',
        );
      }
    
      const formattedPipelineChoices = pipelineChoices
        .map(
          (pipeline, index) =>
            `${index + 1}. ${pipeline.name} (definitionId: ${pipeline.definitionId})`,
        )
        .join('\n');
    
      if (pipelineChoices.length > 1 && !pipelineChoiceName) {
        return {
          content: [
            {
              type: 'text',
              text: `Multiple pipeline definitions found. Please choose one of the following:\n${formattedPipelineChoices}`,
            },
          ],
        };
      }
    
      const chosenPipeline = pipelineChoiceName
        ? pipelineChoices.find((pipeline) => pipeline.name === pipelineChoiceName)
        : undefined;
    
      if (pipelineChoiceName && !chosenPipeline) {
        return mcpErrorOutput(
          `Pipeline definition with name ${pipelineChoiceName} not found. Please choose one of the following:\n${formattedPipelineChoices}`,
        );
      }
    
      const runPipelineDefinitionId =
        chosenPipeline?.definitionId || pipelineChoices[0].definitionId;
    
      const runPipelineResponse = await circleci.pipelines.runPipeline({
        projectSlug,
        branch: foundBranch,
        definitionId: runPipelineDefinitionId,
        configContent,
      });
    
      return {
        content: [
          {
            type: 'text',
            text: `Pipeline run successfully. View it at: ${baseURL}/pipelines/${projectSlug}/${runPipelineResponse.number}`,
          },
        ],
      };
    };
  • Zod input schema defining parameters for the 'run_pipeline' tool, including projectSlug, branch, workspaceRoot, gitRemoteURL, projectURL, pipelineChoiceName, and configContent.
    export const runPipelineInputSchema = z.object({
      projectSlug: z.string().describe(projectSlugDescription).optional(),
      branch: z.string().describe(branchDescription).optional(),
      workspaceRoot: z
        .string()
        .describe(
          'The absolute path to the root directory of your project workspace. ' +
            'This should be the top-level folder containing your source code, configuration files, and dependencies. ' +
            'For example: "/home/user/my-project" or "C:\\Users\\user\\my-project"',
        )
        .optional(),
      gitRemoteURL: z
        .string()
        .describe(
          'The URL of the remote git repository. This should be the URL of the repository that you cloned to your local workspace. ' +
            'For example: "https://github.com/user/my-project.git"',
        )
        .optional(),
      projectURL: z
        .string()
        .describe(
          'The URL of the CircleCI project. Can be any of these formats:\n' +
            '- Project URL with branch: https://app.circleci.com/pipelines/gh/organization/project?branch=feature-branch\n' +
            '- Pipeline URL: https://app.circleci.com/pipelines/gh/organization/project/123\n' +
            '- Workflow URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def\n' +
            '- Job URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def/jobs/xyz',
        )
        .optional(),
      pipelineChoiceName: z
        .string()
        .describe(
          'The name of the pipeline to run. This parameter is only needed if the project has multiple pipeline definitions. ' +
            'If not provided and multiple pipelines exist, the tool will return a list of available pipelines for the user to choose from. ' +
            'If provided, it must exactly match one of the pipeline names returned by the tool.',
        )
        .optional(),
      configContent: z
        .string()
        .describe(
          'The content of the CircleCI YAML configuration file for the pipeline.',
        )
        .optional(),
    });
  • Tool object definition for 'run_pipeline' including name, detailed description, and reference to inputSchema.
    export const runPipelineTool = {
      name: 'run_pipeline' as const,
      description: `
        This tool triggers a new CircleCI pipeline and returns the URL to monitor its progress.
    
        Input options (EXACTLY ONE of these THREE options must be used):
    
        ${option1DescriptionBranchRequired}
    
        Option 2 - Direct URL (provide ONE of these):
        - projectURL: The URL of the CircleCI project in any of these formats:
          * Project URL with branch: https://app.circleci.com/pipelines/gh/organization/project?branch=feature-branch
          * Pipeline URL: https://app.circleci.com/pipelines/gh/organization/project/123
          * Workflow URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def
          * Job URL: https://app.circleci.com/pipelines/gh/organization/project/123/workflows/abc-def/jobs/xyz
    
        Option 3 - Project Detection (ALL of these must be provided together):
        - workspaceRoot: The absolute path to the workspace root
        - gitRemoteURL: The URL of the git remote repository
        - branch: The name of the current branch
    
        Configuration:
        - an optional configContent parameter can be provided to override the default pipeline configuration
    
        Pipeline Selection:
        - If the project has multiple pipeline definitions, the tool will return a list of available pipelines
        - You must then make another call with the chosen pipeline name using the pipelineChoiceName parameter
        - The pipelineChoiceName must exactly match one of the pipeline names returned by the tool
        - If the project has only one pipeline definition, pipelineChoiceName is not needed
    
        Additional Requirements:
        - Never call this tool with incomplete parameters
        - If using Option 1, make sure to extract the projectSlug exactly as provided by listFollowedProjects
        - If using Option 2, the URLs MUST be provided by the user - do not attempt to construct or guess URLs
        - If using Option 3, ALL THREE parameters (workspaceRoot, gitRemoteURL, branch) must be provided
        - If none of the options can be fully satisfied, ask the user for the missing information before making the tool call
    
        Returns:
        - A URL to the newly triggered pipeline that can be used to monitor its progress
        `,
      inputSchema: runPipelineInputSchema,
    };
  • Registration of the 'runPipelineTool' in the CCI_TOOLS array, which collects all CircleCI tools.
    export const CCI_TOOLS = [
      getBuildFailureLogsTool,
      getFlakyTestLogsTool,
      getLatestPipelineStatusTool,
      getJobTestResultsTool,
      configHelperTool,
      createPromptTemplateTool,
      recommendPromptTemplateTestsTool,
      runPipelineTool,
      listFollowedProjectsTool,
      runEvaluationTestsTool,
      rerunWorkflowTool,
      downloadUsageApiDataTool,
      findUnderusedResourceClassesTool,
      analyzeDiffTool,
      runRollbackPipelineTool,
      listComponentVersionsTool,
    ];
  • Mapping of 'run_pipeline' to the runPipeline handler in the CCI_HANDLERS object.
    export const CCI_HANDLERS = {
      get_build_failure_logs: getBuildFailureLogs,
      find_flaky_tests: getFlakyTestLogs,
      get_latest_pipeline_status: getLatestPipelineStatus,
      get_job_test_results: getJobTestResults,
      config_helper: configHelper,
      create_prompt_template: createPromptTemplate,
      recommend_prompt_template_tests: recommendPromptTemplateTests,
      run_pipeline: runPipeline,
      list_followed_projects: listFollowedProjects,
      run_evaluation_tests: runEvaluationTests,
      rerun_workflow: rerunWorkflow,
      download_usage_api_data: downloadUsageApiData,
      find_underused_resource_classes: findUnderusedResourceClasses,
      analyze_diff: analyzeDiff,
      run_rollback_pipeline: runRollbackPipeline,
      list_component_versions: listComponentVersions,
    } satisfies ToolHandlers;
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does an excellent job disclosing behavioral traits: it explains the multi-step pipeline selection process, clarifies that URLs must be user-provided (not constructed), describes the return value format, and specifies parameter interdependencies. It doesn't mention rate limits or authentication requirements, but provides substantial operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Input options, Configuration, Pipeline Selection, Additional Requirements, Returns) and front-loads the core purpose. While comprehensive, some sentences could be more concise (e.g., the URL format list is detailed but necessary). Every sentence adds value given the complex parameter interactions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 7 parameters, 0% schema coverage, no annotations, and no output schema, the description provides exceptional completeness. It covers all usage scenarios, parameter interdependencies, behavioral workflows (multi-step pipeline selection), return values, and error prevention guidance. Nothing essential appears missing for agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by providing rich semantic context for all parameters. It explains the three distinct usage patterns, clarifies parameter relationships (mutual exclusivity, required groupings), provides concrete examples for URL formats, and explains conditional parameter usage (pipelineChoiceName only needed for multiple pipelines).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('triggers a new CircleCI pipeline') and outcome ('returns the URL to monitor its progress'). It distinguishes this tool from siblings like 'get_latest_pipeline_status' (monitoring) and 'rerun_workflow' (re-running existing workflows) by focusing on initiating new pipelines.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool vs alternatives, including detailed instructions for three distinct parameter options with clear requirements ('EXACTLY ONE of these THREE options must be used'), prerequisites ('Never call this tool with incomplete parameters'), and fallback actions ('ask the user for the missing information before making the tool call').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/CircleCI-Public/mcp-server-circleci'

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