
DeepSource
STDIOMCP server integrating DeepSource for AI assistants to access code quality metrics and analysis.
MCP server integrating DeepSource for AI assistants to access code quality metrics and analysis.
A Model Context Protocol (MCP) server that integrates with DeepSource to provide AI assistants with access to code quality metrics, issues, and analysis results.
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:
mcpServers
section:{ "mcpServers": { "deepsource": { "command": "npx", "args": ["-y", "deepsource-mcp-server@latest"], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key" } } } }
Ask Claude: "What DeepSource projects do I have access to?"
If configured correctly, Claude will list your available projects.
The simplest way to use the DeepSource MCP Server:
{ "mcpServers": { "deepsource": { "command": "npx", "args": ["-y", "deepsource-mcp-server@latest"], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key", "LOG_FILE": "/tmp/deepsource-mcp.log", "LOG_LEVEL": "INFO" } } } }
For containerized environments:
{ "mcpServers": { "deepsource": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DEEPSOURCE_API_KEY", "-e", "LOG_FILE=/tmp/deepsource-mcp.log", "-v", "/tmp:/tmp", "sapientpants/deepsource-mcp-server" ], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key" } } } }
For development or customization:
{ "mcpServers": { "deepsource": { "command": "node", "args": ["/path/to/deepsource-mcp-server/dist/index.js"], "env": { "DEEPSOURCE_API_KEY": "your-deepsource-api-key", "LOG_FILE": "/tmp/deepsource-mcp.log", "LOG_LEVEL": "DEBUG" } } } }
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 |
List all available DeepSource projects.
Parameters: None
Example Response:
[ { "key": "https://[email protected]", "name": "my-python-project" } ]
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:
{ "issues": [{ "id": "T2NjdXJyZW5jZTpnZHlqdnlxZ2E=", "title": "Avoid using hardcoded credentials", "shortcode": "PY-D100", "category": "SECURITY", "severity": "CRITICAL", "file_path": "src/config.py", "line_number": 42 }], "totalCount": 15, "pageInfo": { "hasNextPage": true, "endCursor": "YXJyYXljb25uZWN0aW9uOjQ=" } }
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 |
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) |
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 |
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:
{ "vulnerabilities": [{ "id": "VUL-001", "package": "requests", "version": "2.25.0", "severity": "HIGH", "cve": "CVE-2021-12345", "description": "Remote code execution vulnerability" }], "totalCount": 3 }
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 MaturityUpdate 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 |
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 |
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 countTrack your project's quality metrics over time:
"Show me the code coverage trend for my main branch"
This combines multiple tools to:
Implement quality gates for CI/CD:
"Set up quality gates: 80% line coverage, 0 critical security issues"
This will:
Comprehensive security analysis:
"Analyze all security vulnerabilities in my project including dependencies"
This performs:
Get AI-powered code review insights:
"What are the most critical issues in the recent commits to feature/new-api?"
This will:
Track team code quality metrics:
"Show me code quality metrics across all our Python projects"
This aggregates:
The DeepSource MCP Server uses modern TypeScript patterns for maintainability and type safety.
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Claude/AI │────▶│ MCP Server │────▶│ DeepSource API │
│ Assistant │◀────│ (TypeScript) │◀────│ (GraphQL) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
MCP Server Integration (src/index.ts
)
DeepSource Client (src/deepsource.ts
)
Type System (src/types/
)
// Prevent mixing different ID types type ProjectKey = string & { readonly __brand: 'ProjectKey' }; type RunId = string & { readonly __brand: 'RunId' };
type RunState = | { status: 'PENDING'; queuePosition?: number } | { status: 'SUCCESS'; finishedAt: string } | { status: 'FAILURE'; error?: { message: string } };
# Clone the repository git clone https://github.com/sapientpants/deepsource-mcp-server.git cd deepsource-mcp-server # Install dependencies pnpm install # Build the project pnpm run build # Run tests pnpm test
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 |
Error: Invalid API key or unauthorized access
Solution: Verify your DEEPSOURCE_API_KEY
is correct and has necessary permissions.
Error: No projects found
Solution: Ensure your API key has access to at least one project in DeepSource.
Error: API rate limit exceeded
Solution: The server implements automatic retry. Wait a moment or reduce request frequency.
Error: Invalid cursor for pagination
Solution: Cursors expire. Start a new pagination sequence from the beginning.
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.
We welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature
)pnpm test
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)MIT - see LICENSE file for details.
Made with ❤️ by the DeepSource MCP Server community