The DeepSource MCP Server integrates with DeepSource to provide AI assistants with access to code quality metrics, issues, and analysis results through the Model Context Protocol (MCP).
With this server, you can:
- List available DeepSource projects with their keys and names
- Retrieve and filter code quality issues by path, analyzers, or tags
- Access and filter analysis runs for a project
- View detailed information about specific analysis runs using runUid or commitOid
- Get issues from the most recent run on a specific branch
- Access dependency vulnerabilities with detailed fixability and reachability information
- Fetch and update quality metrics (code coverage, duplicate code percentage) and their thresholds
- Manage metric settings to enable/disable reporting and enforce thresholds
- Generate security compliance reports for standards like OWASP Top 10, SANS Top 25, and MISRA-C
- Use pagination (Relay-style cursor-based or legacy offset-based) for large datasets
DeepSource MCP Server
A Model Context Protocol (MCP) server that integrates with DeepSource to provide AI assistants with access to code quality metrics, issues, and analysis results.
Table of Contents
- Overview
- Quick Start
- Installation
- Configuration
- Available Tools
- Usage Examples
- Architecture
- Development
- Troubleshooting & FAQ
- Contributing
- License
- External Resources
Overview
The DeepSource MCP Server enables AI assistants like Claude to interact with DeepSource's code quality analysis capabilities through the Model Context Protocol. This integration allows AI assistants to:
- Retrieve code metrics and analysis results
- Access and filter issues by analyzer, path, or tags
- Check quality status and set thresholds
- Analyze project quality over time
- Access security compliance reports (OWASP, SANS, MISRA-C)
- Monitor dependency vulnerabilities
- Manage quality gates and thresholds
Quick Start
1. Get Your DeepSource API Key
- Log in to your DeepSource account
- Navigate to Settings → API Access
- Click Generate New Token
- Copy your API key and keep it secure
2. Install in Claude Desktop
- Open Claude Desktop
- Go to Settings → Developer → Edit Config
- Add this configuration to the
mcpServers
section:
- Restart Claude Desktop
3. Test Your Connection
Ask Claude: "What DeepSource projects do I have access to?"
If configured correctly, Claude will list your available projects.
Installation
NPX (Recommended)
The simplest way to use the DeepSource MCP Server:
Docker
For containerized environments:
Local Development
For development or customization:
Configuration
Environment Variables
Variable | Required | Default | Description |
---|---|---|---|
DEEPSOURCE_API_KEY | Yes | - | Your DeepSource API key for authentication |
LOG_FILE | No | - | Path to log file. If not set, no logs are written |
LOG_LEVEL | No | DEBUG | Minimum log level: DEBUG , INFO , WARN , ERROR |
Performance Considerations
- Pagination: Use appropriate page sizes (10-50 items) to balance response time and data completeness
- Rate Limits: DeepSource API has rate limits. The server implements automatic retry with exponential backoff
- Caching: Results are not cached. Consider implementing caching for frequently accessed data
Available Tools
1. projects
List all available DeepSource projects.
Parameters: None
Example Response:
2. project_issues
Get issues from a DeepSource project with filtering and pagination.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
first | number | No | Number of items to return (forward pagination) |
after | string | No | Cursor for forward pagination |
last | number | No | Number of items to return (backward pagination) |
before | string | No | Cursor for backward pagination |
path | string | No | Filter issues by file path |
analyzerIn | string[] | No | Filter by analyzers (e.g., ["python", "javascript"]) |
tags | string[] | No | Filter by issue tags |
Example Response:
3. runs
List analysis runs for a project with filtering.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
first | number | No | Number of items to return (forward pagination) |
after | string | No | Cursor for forward pagination |
last | number | No | Number of items to return (backward pagination) |
before | string | No | Cursor for backward pagination |
analyzerIn | string[] | No | Filter by analyzers |
4. run
Get details of a specific analysis run.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
runIdentifier | string | Yes | The runUid (UUID) or commitOid (commit hash) |
isCommitOid | boolean | No | Whether runIdentifier is a commit hash (default: false) |
5. recent_run_issues
Get issues from the most recent analysis run on a branch.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
branchName | string | Yes | The branch name |
first | number | No | Number of items to return |
after | string | No | Cursor for forward pagination |
6. dependency_vulnerabilities
Get security vulnerabilities in project dependencies.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
first | number | No | Number of items to return |
after | string | No | Cursor for forward pagination |
Example Response:
7. quality_metrics
Get code quality metrics with optional filtering.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
shortcodeIn | string[] | No | Filter by metric codes (see below) |
Available Metrics:
LCV
- Line CoverageBCV
- Branch CoverageDCV
- Documentation CoverageDDP
- Duplicate Code PercentageSCV
- Statement CoverageTCV
- Total CoverageCMP
- Code Maturity
8. update_metric_threshold
Update the threshold for a quality metric.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
repositoryId | string | Yes | The GraphQL repository ID |
metricShortcode | string | Yes | The metric shortcode (e.g., "LCV") |
metricKey | string | Yes | The language or context key |
thresholdValue | number|null | No | New threshold value, or null to remove |
9. update_metric_setting
Update metric reporting and enforcement settings.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
repositoryId | string | Yes | The GraphQL repository ID |
metricShortcode | string | Yes | The metric shortcode |
isReported | boolean | Yes | Whether to report this metric |
isThresholdEnforced | boolean | Yes | Whether to enforce thresholds |
10. compliance_report
Get security compliance reports.
Parameter | Type | Required | Description |
---|---|---|---|
projectKey | string | Yes | The unique identifier for the DeepSource project |
reportType | string | Yes | Type of report (see below) |
Available Report Types:
OWASP_TOP_10
- Web application security vulnerabilitiesSANS_TOP_25
- Most dangerous software errorsMISRA_C
- Guidelines for safety-critical C codeCODE_COVERAGE
- Code coverage reportCODE_HEALTH_TREND
- Quality trends over timeISSUE_DISTRIBUTION
- Issue categorizationISSUES_PREVENTED
- Prevented issues countISSUES_AUTOFIXED
- Auto-fixed issues count
Usage Examples
Monitor Code Quality Trends
Track your project's quality metrics over time:
This combines multiple tools to:
- Get recent runs for the main branch
- Retrieve coverage metrics for each run
- Display the trend
Set Up Quality Gates
Implement quality gates for CI/CD:
This will:
- Update the line coverage threshold to 80%
- Configure enforcement for the threshold
- Check current critical security issues
Investigate Security Vulnerabilities
Comprehensive security analysis:
This performs:
- Dependency vulnerability scan
- Code security issue analysis
- OWASP Top 10 compliance check
- Prioritized remediation suggestions
Code Review Assistance
Get AI-powered code review insights:
This will:
- Find the most recent run on the branch
- Filter for critical and high severity issues
- Group by file and issue type
- Suggest fixes
Team Productivity Metrics
Track team code quality metrics:
This aggregates:
- Coverage metrics per project
- Issue counts by severity
- Trends over the last month
- Team performance insights
Architecture
The DeepSource MCP Server uses modern TypeScript patterns for maintainability and type safety.
Key Components
- MCP Server Integration (
src/index.ts
)- Registers and implements tool handlers
- Manages MCP protocol communication
- Handles errors and logging
- DeepSource Client (
src/deepsource.ts
)- GraphQL API communication
- Authentication and retry logic
- Response parsing and validation
- Type System (
src/types/
)- Branded types for type safety
- Discriminated unions for state management
- Zod schemas for runtime validation
Type Safety Features
Branded Types
Discriminated Unions
Development
Prerequisites
- Node.js 20 or higher
- pnpm 10.7.0 or higher
- Docker (optional, for container builds)
Setup
Development Commands
Command | Description |
---|---|
pnpm install | Install dependencies |
pnpm run build | Build TypeScript code |
pnpm run dev | Start with auto-reload |
pnpm test | Run all tests |
pnpm test:watch | Run tests in watch mode |
pnpm test:coverage | Generate coverage report |
pnpm run lint | Run ESLint |
pnpm run format | Format with Prettier |
pnpm run check-types | TypeScript type checking |
pnpm run ci | Run full CI pipeline |
Troubleshooting & FAQ
Common Issues
Authentication Error
Solution: Verify your DEEPSOURCE_API_KEY
is correct and has necessary permissions.
No Projects Found
Solution: Ensure your API key has access to at least one project in DeepSource.
Rate Limit Exceeded
Solution: The server implements automatic retry. Wait a moment or reduce request frequency.
Pagination Cursor Invalid
Solution: Cursors expire. Start a new pagination sequence from the beginning.
FAQ
Q: Which DeepSource plan do I need? A: The MCP server works with all DeepSource plans. Some features like security compliance reports may require specific plan features.
Q: Can I use this with self-hosted DeepSource? A: Yes, configure the API endpoint in your environment variables (feature coming in v1.3.0).
Q: How do I debug issues?
A: Enable debug logging by setting LOG_LEVEL=DEBUG
and check the log file specified in LOG_FILE
.
Q: Is my API key secure? A: The API key is only stored in your local Claude Desktop configuration and is never transmitted except to DeepSource's API.
Q: Can I contribute custom tools? A: Yes! See the Contributing section for guidelines.
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Workflow
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Run tests (
pnpm test
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Code Standards
- Follow TypeScript best practices
- Maintain test coverage above 80%
- Use meaningful commit messages
- Update documentation for new features
License
MIT - see LICENSE file for details.
External Resources
Made with ❤️ by the DeepSource MCP Server community
You must be authenticated.
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.
Tools
A Model Context Protocol server that integrates with DeepSource to provide AI assistants with access to code quality metrics, issues, and analysis results.
Related MCP Servers
- AsecurityFlicenseAqualityA Model Context Protocol server that enables AI models to interact with SourceSync.ai's knowledge management platform for managing documents, ingesting content from various sources, and performing semantic searches.Last updated -2514
- -securityAlicense-qualityA Model Context Protocol server that enables AI agents to retrieve and understand entire codebases at once, providing tools to analyze local workspaces or remote GitHub repositories.Last updated -9TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enhances AI-generated code quality through comprehensive analysis across 10 critical dimensions, helping identify issues before they become problems.Last updated -3PythonApache 2.0
- -securityFlicense-qualityA comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.Last updated -16TypeScript