mcp-server-circleci

Official

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Integrates with CircleCI to retrieve build failure logs and identify flaky tests. Supports accessing logs via CircleCI URLs or local project context, and analyzing test execution history to detect unreliable tests in a project's test suite.

CircleCI MCP 服务器

模型上下文协议 (MCP) 是一种新的标准化协议,用于管理大型语言模型 (LLM) 与外部系统之间的上下文。在此存储库中,我们为CircleCI提供了一个 MCP 服务器。

这使您可以使用 Cursor IDE 或任何 MCP 客户端,使用自然语言通过 CircleCI 完成任务,例如:

https://github.com/user-attachments/assets/3c765985-8827-442a-a8dc-5069e01edb74

要求

安装

光标

将以下内容添加到您的游标 MCP 配置中:

{ "mcpServers": { "circleci-mcp-server": { "command": "npx", "args": ["-y", "@circleci/mcp-server-circleci"], "env": { "CIRCLECI_TOKEN": "your-circleci-token", "CIRCLECI_BASE_URL": "https://circleci.com" // Optional - required for on-prem customers only } } } }

有关使用带有游标的 MCP 服务器的更多信息,请参阅以下指南: https://docs.cursor.com/context/model-context-protocol#configuring-mcp-servers

克劳德桌面

将以下内容添加到您的 claude_desktop_config.json:

{ "mcpServers": { "circleci-mcp-server": { "command": "npx", "args": ["-y", "@circleci/mcp-server-circleci"], "env": { "CIRCLECI_TOKEN": "your-circleci-token", "CIRCLECI_BASE_URL": "https://circleci.com" // Optional - required for on-prem customers only } } } }

要查找/创建此文件,首先打开 Claude 桌面设置。然后点击“设置”面板左侧栏中的“开发者”,然后点击“编辑配置”。

这将在以下位置创建一个配置文件:

  • macOS:〜/资源库/应用程序支持/Claude/claude_desktop_config.json
  • Windows:%APPDATA%\Claude\claude_desktop_config.json

有关使用 MCP 服务器和 Claude Desktop 的更多信息,请参阅以下指南: https://modelcontextprotocol.io/quickstart/user

克劳德·科德

安装Claude Code后,运行以下命令:

claude mcp add circleci-mcp-server -e CIRCLECI_TOKEN=your-circleci-token -- npx -y @circleci/mcp-server-circleci

有关使用 Claude Code 的 MCP 服务器的更多信息,请参阅以下指南: https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp

VS 代码

将 MCP 服务器添加到您的 settings.json 中的mcp -> servers下:

"circleci-mcp-server": { "command": "npx", "args": ["-y", "@circleci/mcp-server-circleci"], "env": { "CIRCLECI_TOKEN": "your-circleci-token", "CIRCLECI_BASE_URL": "https://circleci.com" // Optional - required for on-prem customers only } }

有关使用 MCP 服务器和 VS Code 的更多信息,请参阅以下指南: https://code.visualstudio.com/docs/copilot/chat/mcp-servers

风帆冲浪

将以下内容添加到您的 windsurf mcp_config.json:

{ "mcpServers": { "circleci-mcp-server": { "command": "npx", "args": ["-y", "@circleci/mcp-server-circleci"], "env": { "CIRCLECI_TOKEN": "your-circleci-token", "CIRCLECI_BASE_URL": "https://circleci.com" // Optional - required for on-prem customers only } } } }

有关使用 MCP 服务器和 windsurf 的更多信息,请参阅以下指南: https://docs.windsurf.com/windsurf/mcp

特征

支持的工具

  • get_build_failure_logs从 CircleCI 构建中检索详细的失败日志。此工具有两种使用方式:
    1. 使用 CircleCI URL:
    2. 使用本地项目上下文:
      • 通过提供以下内容从您的本地工作区工作:
        • 工作区根路径
        • Git 远程 URL
        • 分支机构名称
      • 示例:“查找当前分支上最新的失败管道”

    该工具返回格式化的日志,包括:

    • 职位名称
    • 逐步执行细节
    • 失败消息和上下文

    这对于以下情况尤其有用:

    • 调试失败的构建
    • 分析测试失败
    • 调查部署问题
    • 无需离开 IDE 即可快速访问构建日志
  • find_flaky_tests通过分析测试执行历史记录,识别 CircleCI 项目中的不稳定测试。这利用了此处描述的不稳定测试检测功能: https://circleci.com/blog/introducing-test-insights-with-flaky-test-detection/#flaky-test-detection此工具有两种使用方式:
    1. 使用 CircleCI 项目 URL:
    2. 使用本地项目上下文:
      • 通过提供以下内容从您的本地工作区工作:
        • 工作区根路径
        • Git 远程 URL
      • 例如:“查找当前项目中的不稳定测试”

    该工具返回有关不稳定测试的详细信息,包括:

    • 测试名称和文件位置
    • 失败消息和上下文

    这可以帮助您:

    • 识别测试套件中不可靠的测试
    • 获取有关测试失败的详细背景信息
    • 做出有关测试改进的数据驱动决策

发展

入门

  1. 克隆存储库:
    git clone https://github.com/CircleCI-Public/mcp-server-circleci.git cd mcp-server-circleci
  2. 安装依赖项:
    pnpm install
  3. 构建项目:
    pnpm build

使用 MCP Inspector 进行开发

在 MCP 服务器上进行迭代最简单的方法是使用 MCP 检查器。您可以在https://modelcontextprotocol.io/docs/tools/inspector上了解更多关于 MCP 检查器的信息。

  1. 启动开发服务器:
    pnpm watch # Keep this running in one terminal
  2. 在单独的终端中,启动检查器:
    pnpm inspector
  3. 配置环境:
    • 将您的CIRCLECI_TOKEN添加到检查器 UI 中的环境变量部分
    • 令牌需要对您的 CircleCI 项目的读取权限
    • 您也可以设置 CircleCI 基本 URL。默认为https//circleci.com

测试

  • 运行测试套件:
    pnpm test
  • 在开发期间以监视模式运行测试:
    pnpm test:watch

有关更详细的贡献指南,请参阅CONTRIBUTING.md

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

此 MCP 服务器允许您使用 Cursor IDE 或任何启用 MCP 客户端的代理,使用自然语言通过 CircleCI 完成操作,例如:在我的分支上查找最新失败的管道并获取日志

  1. Requirements
    1. Installation
      1. Cursor
      2. Claude Desktop
      3. Claude Code
      4. VS Code
      5. Windsurf
    2. Features
      1. Supported Tools
    3. Development
      1. Getting Started
      2. Development with MCP Inspector
      3. Testing
    ID: 65ardm1kp6