
codecov
io.github.egulatee/codecov
MCP server for querying Codecov coverage data with configurable URL support
Documentation
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: mcp-server-codecov
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 mcp-server-codecov
4. Verify installation
claude mcp get codecov
Expected output: codecov: mcp-server-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
- 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
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 mcp-server-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", "mcp-server-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", "mcp-server-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
Installing from npm Globally
npm install -g mcp-server-codecov
Benefits:
- Simple one-command installation
- Automatic updates with
npm update -g mcp-server-codecov - No manual build steps required
- Works across all projects
Verify installation:
npm list -g mcp-server-codecov
which mcp-server-codecov
npm view mcp-server-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}
Currently supports GitHub repositories (gh). Support for other providers (GitLab, Bitbucket) can be added by modifying the API paths.
License
MIT
mcp-server-codecovnpm install mcp-server-codecov