You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔌 Plugin: MCP Server Source Code Scanner - Semgrep/Bandit Integration
Goal
Implement a gateway plugin that performs static analysis on MCP server source code using Semgrep, Bandit, or other SAST tools to detect security vulnerabilities, code quality issues, and dangerous patterns before servers are added to the gateway.
Why Now?
Code-Level Vulnerabilities: Container scanning misses application-level issues like SQL injection, command injection, and insecure deserialization
MCP-Specific Risks: MCP servers execute tools on behalf of AI agents—code vulnerabilities can have amplified impact
Shift-Left Security: Catching issues in code before deployment is cheaper than runtime detection
GitHub Integration: Many MCP servers are deployed from GitHub repos; source scanning is natural
Existing Code Safety Plugin: code_safety_linter plugin detects patterns in outputs, but pre-deployment source analysis is missing
📖 User Stories
US-1: Security Engineer - Scan Source Code for Vulnerabilities
As a Security Engineer I want MCP server source code scanned for security issues So that vulnerabilities are caught before deployment
Acceptance Criteria:
Given an MCP server from a GitHub repository:
source:
type: github
repo: org/mcp-server
branch: main
When the source scan runs:
Then the scanner should:
- Clone the repository
- Detect primary language
- Run appropriate scanners (Semgrep, Bandit)
- Return findings with:
- Rule ID and severity
- File path and line numbers
- Code snippet
- Remediation guidance
- Block if critical findings exist
US-2: Developer - View Scan Findings with Remediation
As a Developer I want actionable scan findings with code context So that I can quickly fix security issues
Acceptance Criteria:
Given a scan has completed with findings:
When I view the assessment report:
Then I see for each finding:
- Severity badge (CRITICAL/HIGH/MEDIUM/LOW)
- Rule description
- File path with clickable line number
- Code snippet with highlighted issue
- Remediation suggestion
- Link to rule documentation
🏗 Architecture
Supported Scanners
Scanner
Languages
Output Format
Semgrep
Python, JavaScript, Go, Java, etc.
SARIF, JSON
Bandit
Python
JSON
ESLint (security)
JavaScript/TypeScript
JSON
CodeQL
Multiple
SARIF
Plugin Flow
sequenceDiagram
participant Gateway as Gateway
participant Plugin as SourceScannerPlugin
participant Git as Git
participant Semgrep as Semgrep
participant Bandit as Bandit
Gateway->>Plugin: server_pre_register(github_repo)
Plugin->>Git: Clone repository
Plugin->>Plugin: Detect languages
par Python detected
Plugin->>Bandit: bandit -r . -f json
Bandit-->>Plugin: Python findings
and All languages
Plugin->>Semgrep: semgrep --config p/security-audit
Semgrep-->>Plugin: SARIF findings
end
Plugin->>Plugin: Merge and deduplicate
Plugin->>Plugin: Check severity threshold
Plugin->>Git: Cleanup temp directory
Plugin-->>Gateway: Findings or block
🔌 Plugin: MCP Server Source Code Scanner - Semgrep/Bandit Integration
Goal
Implement a gateway plugin that performs static analysis on MCP server source code using Semgrep, Bandit, or other SAST tools to detect security vulnerabilities, code quality issues, and dangerous patterns before servers are added to the gateway.
Why Now?
code_safety_linterplugin detects patterns in outputs, but pre-deployment source analysis is missing📖 User Stories
US-1: Security Engineer - Scan Source Code for Vulnerabilities
As a Security Engineer
I want MCP server source code scanned for security issues
So that vulnerabilities are caught before deployment
Acceptance Criteria:
US-2: Developer - View Scan Findings with Remediation
As a Developer
I want actionable scan findings with code context
So that I can quickly fix security issues
Acceptance Criteria:
🏗 Architecture
Supported Scanners
Plugin Flow
sequenceDiagram participant Gateway as Gateway participant Plugin as SourceScannerPlugin participant Git as Git participant Semgrep as Semgrep participant Bandit as Bandit Gateway->>Plugin: server_pre_register(github_repo) Plugin->>Git: Clone repository Plugin->>Plugin: Detect languages par Python detected Plugin->>Bandit: bandit -r . -f json Bandit-->>Plugin: Python findings and All languages Plugin->>Semgrep: semgrep --config p/security-audit Semgrep-->>Plugin: SARIF findings end Plugin->>Plugin: Merge and deduplicate Plugin->>Plugin: Check severity threshold Plugin->>Git: Cleanup temp directory Plugin-->>Gateway: Findings or block📋 Implementation Tasks
plugins/source_scanner/directory structureSourceScannerPluginclassmake verifychecks⚙️ Configuration Example
✅ Success Criteria
🔗 Related Issues