Codecov MCP Server
Enables querying Codecov coverage data including file, commit, repository, and pull request coverage.
README
MCP Server for Codecov
A Model Context Protocol (MCP) server that provides tools for querying Codecov coverage data. Supports both codecov.io and self-hosted Codecov instances with configurable URL endpoints.
📦 Published on npm: @egulatee/mcp-codecov 🐳 Docker image: ghcr.io/egulatee/mcp-server-codecov
📖 Learn More: Read about building this MCP server with AI in just 2 hours.
Quick Start (Claude Code)
Get started in under 2 minutes:
1. Get your Codecov API token
Create an API token (not an upload token) from your Codecov account:
- Go to codecov.io (or your self-hosted URL)
- Click your avatar → Settings → Access tab
- Click "Generate Token" and name it "MCP Server API Access"
- Copy the token value
2. Set your environment variable
Add to your shell profile (~/.zshrc or ~/.bashrc):
export CODECOV_TOKEN="your-api-token-here"
Then reload: source ~/.zshrc
3. Install the MCP server
claude mcp add --transport stdio codecov \
--env CODECOV_BASE_URL=https://codecov.io \
--env CODECOV_TOKEN=${CODECOV_TOKEN} \
-- npx -y @egulatee/mcp-codecov
4. Verify installation
claude mcp get codecov
Expected output: codecov: @egulatee/mcp-codecov - ✓ Connected
That's it! You can now use Codecov tools in Claude Code. See Available Tools below.
Features
- File-level coverage: Get detailed line-by-line coverage data for specific files
- Commit coverage: Retrieve coverage statistics for individual commits
- Repository coverage: Get overall coverage metrics for repositories
- Pull request coverage: Analyze coverage changes and impact for pull requests
- Coverage comparison: Compare coverage between branches, commits, or tags
- Configurable URL: Point to any Codecov instance (codecov.io or self-hosted)
- Token authentication: API token support for accessing coverage data
Token Types
Important: Codecov has two different types of tokens:
- Upload Token: Used for pushing coverage reports TO Codecov during CI/CD. Found on your repository's Settings → General page.
- API Token: Used for reading coverage data FROM Codecov via the API. Created in your Codecov Settings → Access tab.
This MCP server requires an API token, not an upload token.
Available Tools
get_file_coverage
Get line-by-line coverage data for a specific file.
Parameters:
owner(required): Repository owner (username or organization)repo(required): Repository namefile_path(required): Path to the file within the repository (e.g., 'src/index.ts')ref(optional): Git reference (branch, tag, or commit SHA)
Example:
Get coverage for src/index.ts in owner/repo on main branch
get_commit_coverage
Get coverage data for a specific commit.
Parameters:
owner(required): Repository ownerrepo(required): Repository namecommit_sha(required): Commit SHA
Example:
Get coverage for commit abc123 in owner/repo
get_repo_coverage
Get overall coverage statistics for a repository.
Parameters:
owner(required): Repository ownerrepo(required): Repository namebranch(optional): Branch name (defaults to repository's default branch)
Example:
Get overall coverage for owner/repo on main branch
get_pull_request_coverage
Get coverage data for a specific pull request, including coverage changes and file-level impact.
Parameters:
owner(required): Repository owner (username or organization)repo(required): Repository namepull_number(required): Pull request number
Example:
Get coverage for pull request #123 in owner/repo
Use Cases:
- Check if PR meets coverage thresholds before approving
- Alert when PR decreases overall coverage
- Identify which files in a PR lack coverage
- Implement quality gates that block merges if coverage drops
compare_coverage
Compare coverage between two git references (branches, commits, or tags).
Parameters:
owner(required): Repository owner (username or organization)repo(required): Repository namebase(required): Base reference (e.g., 'main', commit SHA)head(required): Head reference to compare against base
Example:
Compare coverage between main branch and feature-branch in owner/repo
Use Cases:
- Compare coverage between release branches
- Analyze coverage changes between any two commits
- Track coverage trends across development cycles
- Validate coverage improvements in feature branches
Repository Activation
Important Note: Before a repository can receive coverage uploads, it must be activated in Codecov. This is a one-time setup step that cannot be automated via API.
Manual Activation Process
To activate a repository for coverage tracking:
- Log in to your Codecov instance (e.g., codecov.io)
- Navigate to your organization/user account
- Find the repository you want to activate
- Click the "Activate" button to enable coverage tracking
- Once activated, you can upload coverage reports from your CI/CD pipeline
Why manual activation is required: The Codecov API v2 does not provide a /activate endpoint. Repository activation must be done through the web UI or happens automatically on first coverage upload (depending on your Codecov configuration).
Verification and Troubleshooting
Common Issues
1. 401 Unauthorized Error
- Check token type: Ensure you're using an API token (from Settings → Access), not an upload token
- Verify the token is valid and has access to the repository
- For self-hosted instances, confirm you're using the correct
CODECOV_BASE_URL
2. Environment Variable Not Expanding
- Make sure the variable is exported in your shell (check
~/.zshrcor~/.bashrc) - Restart Claude Code after setting environment variables
- Verify the variable exists:
echo $CODECOV_TOKEN
3. Connection Failed
- Restart Claude Code or Claude Desktop
- Verify environment variables are set correctly:
echo $CODECOV_TOKEN - Check the configuration:
claude mcp get codecov
4. HTTP vs HTTPS
Always use https:// for the CODECOV_BASE_URL, not http://:
- Correct:
https://your-codecov-instance.com - Incorrect:
http://your-codecov-instance.com
Advanced Configuration
Self-Hosted Codecov
For self-hosted Codecov instances, use your instance URL:
claude mcp add --transport stdio codecov \
--env CODECOV_BASE_URL=https://codecov.your-company.com \
--env CODECOV_TOKEN=${CODECOV_TOKEN} \
-- npx -y @egulatee/mcp-codecov
Claude Desktop Setup
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"codecov": {
"command": "npx",
"args": ["-y", "@egulatee/mcp-codecov"],
"env": {
"CODECOV_BASE_URL": "https://codecov.io",
"CODECOV_TOKEN": "your-codecov-token-here"
}
}
}
}
Manual Configuration (Claude Code)
Add to ~/.claude.json:
{
"mcpServers": {
"codecov": {
"command": "npx",
"args": ["-y", "@egulatee/mcp-codecov"],
"env": {
"CODECOV_BASE_URL": "https://codecov.io",
"CODECOV_TOKEN": "${CODECOV_TOKEN}"
}
}
}
}
Notes:
- Environment variable expansion is supported using
${VAR}syntax - Variables like
${CODECOV_TOKEN}will be read from your shell environment - The
-yflag for npx automatically accepts the package installation prompt
Docker (no Node.js required)
Pull and run the official multi-platform image from GitHub Container Registry:
docker run --rm -i \
-e CODECOV_TOKEN=your_token \
ghcr.io/egulatee/mcp-server-codecov
Platforms: linux/amd64 and linux/arm64 (Apple Silicon, AWS Graviton)
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"codecov": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "CODECOV_TOKEN=your_token",
"ghcr.io/egulatee/mcp-server-codecov"
]
}
}
}
With self-hosted Codecov:
docker run --rm -i \
-e CODECOV_TOKEN=your_token \
-e CODECOV_BASE_URL=https://codecov.your-company.com \
ghcr.io/egulatee/mcp-server-codecov
Available tags: latest, 2, 2.1, 2.1.0 (full semver)
stdio bridge with socat:
The Docker image includes socat, which allows MCP clients that communicate over stdio to connect to the server running inside a container via a TCP socket:
# Start the server exposing a TCP port
docker run --rm -p 3000:3000 \
-e CODECOV_TOKEN=your_token \
ghcr.io/egulatee/mcp-server-codecov
# Bridge stdio ↔ TCP in a second terminal (or from your MCP client config)
socat TCP:localhost:3000 STDIO
Note:
socatmust also be installed on the host machine running the bridge command. Install withbrew install socat(macOS),apt install socat(Debian/Ubuntu), orapk add socat(Alpine).
Installing from npm Globally
npm install -g @egulatee/mcp-codecov
Benefits:
- Simple one-command installation
- Automatic updates with
npm update -g @egulatee/mcp-codecov - No manual build steps required
- Works across all projects
Verify installation:
npm list -g @egulatee/mcp-codecov
which mcp-codecov
npm view @egulatee/mcp-codecov version
Development Installation (Source)
Only use this method if you're contributing to the project:
git clone https://github.com/egulatee/mcp-server-codecov.git
cd mcp-server-codecov
npm install
npm run build
Then configure with the built path:
Claude Code CLI:
claude mcp add --transport stdio codecov \
--env CODECOV_BASE_URL=https://codecov.io \
--env CODECOV_TOKEN=${CODECOV_TOKEN} \
-- node /absolute/path/to/codecov-mcp/dist/index.js
Manual (~/.claude.json):
{
"mcpServers": {
"codecov": {
"command": "node",
"args": ["/absolute/path/to/codecov-mcp/dist/index.js"],
"env": {
"CODECOV_BASE_URL": "https://codecov.io",
"CODECOV_TOKEN": "${CODECOV_TOKEN}"
}
}
}
}
Claude Desktop:
{
"mcpServers": {
"codecov": {
"command": "node",
"args": ["/path/to/mcp-server-codecov/dist/index.js"],
"env": {
"CODECOV_BASE_URL": "https://codecov.io",
"CODECOV_TOKEN": "your-codecov-token-here"
}
}
}
}
Testing
This project maintains 97%+ code coverage with comprehensive unit tests using Vitest.
For detailed testing documentation, including how to run tests, coverage requirements, CI integration, and writing tests, see TESTING.md.
Development
# Install dependencies
npm install
# Build the project
npm run build
# Watch mode for development
npm run watch
Release Process
This project uses an automated release workflow via GitHub Actions. Releases are published to npm automatically when you push a version tag.
For detailed release instructions, including prerequisites, creating releases, manual releases, and version numbering, see RELEASE.md.
API Compatibility
This server uses Codecov's API v2. The API endpoints follow this pattern:
- File coverage:
/api/v2/gh/{owner}/repos/{repo}/file_report/{file_path} - Commit coverage:
/api/v2/gh/{owner}/repos/{repo}/commits/{commit_sha} - Repository coverage:
/api/v2/gh/{owner}/repos/{repo} - Pull request coverage:
/api/v2/gh/{owner}/repos/{repo}/pulls/{pull_number} - Coverage comparison:
/api/v2/gh/{owner}/repos/{repo}/compare/{base}...{head}
Currently supports GitHub repositories (gh). Support for other providers (GitLab, Bitbucket) can be added by modifying the API paths.
Resources
- 📝 Building the Codecov MCP Server in 2 Hours - A detailed walkthrough of developing this server using AI-augmented development techniques
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。