Enhance CircleCI With Pipeline Navigation Tools
In the realm of Continuous Integration and Continuous Delivery (CI/CD), efficiency and automation are paramount. This article delves into a critical feature request aimed at augmenting CircleCI's capabilities through the addition of robust navigation and discovery tools for pipelines and workflows. Currently, the MCP server offers useful 'leaf node' operations but lacks the essential 'discovery' or 'navigation' features. This deficiency creates a significant workflow gap, hindering the full potential of AI-driven automation.
The Challenge: Bridging the Gap in Autonomous Workflows
The Problem: AI assistants often struggle to programmatically discover workflow URLs, which are necessary for use with existing CircleCI tools. This limitation disrupts autonomous agent workflows and necessitates manual human intervention, thereby diminishing the efficiency gains promised by automation.
The Scenario: Imagine an AI identifying a failed pipeline, for instance, pipeline #33361. The AI's next logical step is to rerun the workflow using the rerun_workflow tool. However, this tool requires a specific workflow URL, typically in the format .../workflows/{workflow-id}. The AI, unfortunately, only possesses the pipeline URL, formatted as .../pipelines/{pipeline-id}. This is where the problem lies: there is no existing tool to navigate seamlessly from the pipeline to the workflow. Consequently, the AI is forced to request manual assistance from a user to navigate the CircleCI UI and copy the required workflow URL. This manual step breaks the chain of automation and introduces unnecessary delays.
The Impact: This reliance on manual intervention significantly impedes the progress of AI-assisted CI/CD processes. It underscores the need for tools that can programmatically traverse the CircleCI resource hierarchy, enabling AI assistants to operate autonomously and efficiently. By equipping AI with the ability to navigate and discover workflow URLs, we can unlock the full potential of AI-driven automation in CI/CD workflows.
Proposed Solution: Introducing Navigation/Discovery Tools
To address the current limitations and unlock the full potential of AI-driven automation within CircleCI, the following navigation/discovery tools are proposed. These tools aim to empower AI assistants to programmatically traverse the CircleCI resource hierarchy, enabling seamless and autonomous workflows.
1. list_pipelines_for_project
This tool serves as the starting point for pipeline discovery. By providing the projectSlug (e.g., "gh/organization/project") as input, the tool returns a list of recent pipelines. Each pipeline in the list includes essential details such as its ID, number, status, and URL. This allows AI assistants to quickly identify and access relevant pipelines for further analysis and action.
The list_pipelines_for_project tool is crucial for AI-driven CI/CD workflows because it provides the initial access point to the pipeline ecosystem. Without it, AI assistants would struggle to locate and interact with specific pipelines, hindering their ability to automate tasks such as identifying failed builds, triggering reruns, or analyzing test results. By offering a programmatic way to list recent pipelines, this tool empowers AI to take the first step in navigating the CI/CD landscape.
Key Benefits:
- Efficient Pipeline Discovery: Quickly identifies relevant pipelines based on project slug.
- Essential Pipeline Information: Provides key details such as ID, number, status, and URL.
- Foundation for Automation: Serves as the starting point for AI-driven CI/CD workflows.
2. get_pipeline_details
Acting as a bridge from pipelines to workflows, this tool requires either the pipelineNumber and projectSlug or the pipeline URL as input. In return, it provides comprehensive pipeline metadata, including the workflow count and workflow IDs. This tool is invaluable for AI assistants seeking to understand the structure and composition of a pipeline.
The get_pipeline_details tool fills a critical gap in the current CI/CD landscape by providing AI assistants with the ability to drill down into the specifics of a pipeline. This is essential for understanding the various components and processes involved in a build, allowing AI to make informed decisions about how to optimize and automate the CI/CD process. By providing workflow count and workflow IDs, this tool enables AI to move from the pipeline level to the workflow level, opening up a new realm of possibilities for automation.
Key Benefits:
- Detailed Pipeline Insights: Provides comprehensive metadata about a specific pipeline.
- Workflow Identification: Reveals the number of workflows within a pipeline and their corresponding IDs.
- Bridging the Gap: Connects pipelines to workflows, enabling deeper analysis and automation.
3. list_workflows_for_pipeline
This tool is designed to discover workflow URLs without the need for UI navigation. By providing the pipelineNumber and projectSlug or the pipeline URL, the tool returns a list of workflows within the specified pipeline. Each workflow in the list includes its ID, name, and URL, allowing AI assistants to directly access and interact with specific workflows.
The list_workflows_for_pipeline tool is a game-changer for AI-driven CI/CD workflows because it eliminates the need for manual UI navigation to find workflow URLs. This is a significant time-saver and efficiency booster, allowing AI assistants to quickly access and interact with specific workflows without human intervention. By providing a programmatic way to list workflows within a pipeline, this tool empowers AI to fully automate tasks such as rerunning failed workflows, analyzing test results, and optimizing build processes.
Key Benefits:
- Automated Workflow Discovery: Eliminates the need for manual UI navigation to find workflow URLs.
- Essential Workflow Information: Provides key details such as ID, name, and URL for each workflow.
- Seamless Automation: Enables AI to fully automate tasks related to specific workflows.
4. get_workflow_details
For detailed workflow inspection before operations, this tool requires the workflowId as input. It then provides comprehensive workflow metadata, including information about jobs, status, and timing. This allows AI assistants to gain a deep understanding of a workflow's execution and performance.
The get_workflow_details tool is essential for AI assistants that need to understand the inner workings of a workflow before taking action. By providing detailed information about jobs, status, and timing, this tool enables AI to make informed decisions about how to optimize and automate the CI/CD process. For example, AI can use this information to identify bottlenecks, pinpoint performance issues, and prioritize tasks based on their impact on overall build time. By providing a deep dive into workflow details, this tool empowers AI to become a true partner in the CI/CD process.
Key Benefits:
- In-Depth Workflow Analysis: Provides comprehensive metadata about a specific workflow.
- Performance Insights: Reveals key information about jobs, status, and timing.
- Informed Decision-Making: Enables AI to make data-driven decisions about workflow optimization and automation.
API Endpoints
These tools can be implemented leveraging existing CircleCI REST API endpoints:
GET /project/{project-slug}/pipeline- List recent pipelinesGET /pipeline/{pipeline-id}- Get pipeline detailsGET /pipeline/{pipeline-id}/workflow- List workflows in pipelineGET /workflow/{workflow-id}- Get workflow details
Implementation and Compatibility
Implementation Approach:
The implementation of these new tools should follow existing patterns within the src/tools/ directory. Consistent parameter naming with existing tools will ensure a cohesive user experience. The existing getWorkflowIdFromURL() utility should be leveraged where applicable to maintain code consistency and reduce redundancy. Importantly, the introduction of these new tools should not introduce any breaking changes to existing functionality.
Performance Considerations:
To ensure optimal performance, particularly when dealing with large pipeline lists, paginated responses should be implemented. An optional limit parameter can be introduced to allow users to control the size of the result set. The implementation should avoid introducing any additional authentication complexity, leveraging the existing authentication and authorization mechanisms.
Security Implications:
The introduction of these new tools should not raise any new security concerns. They will utilize the existing authentication and authorization mechanisms, ensuring that access to data is controlled and secure. The tools will expose the same data that is currently available via the CircleCI UI, meaning that no new sensitive information will be exposed.
Compatibility:
The new tools will be fully backward compatible, ensuring that existing functionality remains unaffected. They will follow established MCP tool patterns, ensuring a consistent and predictable user experience.
Motivation and Use Case
Primary Use Case: Enable fully autonomous AI workflows that can:
- Detect test failures in a pipeline
- Automatically discover the failed workflow
- Retrieve failure logs and test results
- Rerun the workflow (from failed or start)
- Verify the rerun succeeded
Current Workflow (Broken):
AI: Tests failed in pipeline #33361
AI: Attempt to rerun workflow
AI: ❌ "workflowId is required and could not be determined"
AI: User, please manually navigate to CircleCI, find the workflow URL, and give it to me.
User: [manual UI navigation, copy URL, paste to AI]
AI: Thank you, rerunning workflow now...
Desired Workflow (With Navigation Tools):
AI: Tests failed in pipeline #33361
AI: Let me find the workflows in this pipeline
AI: Found workflow id: abc-def-123 (FAILED)
AI: Retrieving failure logs...
AI: Analyzing test failures...
AI: Rerunning workflow from failed steps...
AI: Monitoring rerun status...
AI: ✅ Rerun succeeded, all tests passing
Benefits:
- Eliminates manual UI navigation steps
- Enables truly autonomous CI debugging workflows
- Reduces friction in AI-assisted development
- Leverages existing CircleCI API capabilities
- Maintains consistent tool design patterns
Additional Context
Current Tools (16 total): List projects, get pipeline status, get test results, rerun workflow, find flaky tests, etc.
Missing Category: Navigation/discovery tools - the "glue" that connects the existing tools into cohesive workflows.
Related Issues:
- #63 (Feature request: Tool to rerun workflow from failed) - This was the first step; navigation tools are the missing piece to make it truly autonomous
- #132 (Feature Request: Rerun workflow with ssh) - Navigation tools would also enable automatic SSH-enabled reruns for flaky test debugging
Evidence of Need: The regex pattern in src/lib/getWorkflowIdFromURL.ts expects /workflows/{id}, but users often only have pipeline URLs. Without navigation tools, there's no way to bridge this gap programmatically.
In conclusion, the addition of navigation and discovery tools to CircleCI represents a significant step forward in enabling truly autonomous AI-driven CI/CD workflows. By empowering AI assistants to programmatically traverse the CircleCI resource hierarchy, we can eliminate manual intervention, reduce friction in the development process, and unlock the full potential of automation. This will lead to faster build times, improved code quality, and a more efficient development lifecycle overall.
For more information on CircleCI's REST API, visit the official CircleCI documentation. This resource provides comprehensive details on available endpoints and how to utilize them effectively.