SafeDep MCP Server: Vet Open-Source Packages for AI
Vet open-source packages with SafeDep's MCP server to detect vulnerabilities and malicious code before using AI-generated code suggestions.
npx -y @docs/mcp.mdOverview
The SafeDep MCP (Model Context Protocol) server provides a lightweight, self-hosted HTTP service that supplies vetted, machine-readable context about open‑source packages to AI systems and developer tools. Instead of returning raw package metadata, the MCP server returns enriched signals — vulnerability summaries, malware flags, license findings, dependency usage evidence, and policy decisions — so an LLM or automated agent can make safer suggestions when it recommends or auto-imports third‑party code.
Running the MCP server locally (or in your CI/CD network) gives AI assistants an authoritative source of truth: before a model suggests adding a dependency, the assistant can query the MCP server to decide whether the package meets your security, license, and quality requirements.
Features
- Package vetting for multiple ecosystems: npm, PyPI, Maven, RubyGems, Go modules, Rust, PHP, etc.
- Enriched signals: CVE summaries, exploitability / usage evidence, license declarations, and SafeDep malware detections.
- Policy as code: evaluate CEL (Common Expression Language) expressions against package data and return pass/fail decisions.
- Low-latency HTTP endpoints that integrate with LLMs, IDE plugins, GitHub Actions, and other automation.
- Configurable enrichment: connect to SafeDep Cloud for advanced malware analysis or run offline/limited mode.
- JSON responses formatted for programmatic consumption; optional human-readable summaries for logs and UI.
Installation / Configuration
You can run the MCP server as a standalone binary, via Docker, or build from source. The examples below use environment variables to configure API access and behavior.
Install a prebuilt binary (macOS/Linux):
# Download and unpack a release from GitHub Releases
Run with Docker:
Build from source (Go):
Common environment variables:
SAFEDEP_API_KEY API key for SafeDep Cloud (optional for local-only mode)
MCP_PORT Port for the MCP HTTP server (default: 8080)
MCP_BIND Address to bind (default: 0.0.0.0)
POLICY_FILE Path to a CEL policy file to evaluate package decisions
CLOUD_URL SafeDep Cloud endpoint (if using hosted enrichment)
Example config file (policies.cel):
# Deny packages with a critical CVE or GPL-3.0 license
deny = vulns.critical.exists(p, true) || licenses.contains_license("GPL-3.0")
API Endpoints (examples)
The MCP server exposes simple REST endpoints that AI systems can call before taking actions that add or modify dependencies.
| Endpoint | Method | Purpose |
|---|---|---|
| /mcp/context | POST | Return enriched context and policy decision for one or more packages |
| /health | GET | Liveness/health check |
| /metrics | GET | Prometheus metrics (if enabled) |
Example request (POST /mcp/context):
Example (abbreviated) response:
Available Resources
- GitHub repo: https://github.com/safedep/vet
- Documentation: https://docs.safedep.io/
- CEL (policy language): https://cel.dev/
- SafeDep Cloud (optional): https://safedep.io/
Use these resources to explore advanced configuration (Scorecards, dynamic malware analysis), exporter formats (SARIF/SBOM), and example policy libraries.
Use Cases
- AI code assistants: Before suggesting an import or dependency, an LLM calls /mcp/context to receive security and license guidance used to accept or reject the recommendation.
- CI / pre-merge automation: A lightweight MCP server in CI evaluates new/updated dependencies against organizational policies and fails the build when a package is disallowed.
- IDE extensions: An editor plugin queries MCP to surface risk badges inline when a developer types an import or edits package manifests.
- Supply-chain triage: Security teams use MCP responses to quickly group packages by risk (malware flags, exploitable CVEs, or problematic licenses) during reviews.
- Policy enforcement: Define license, vulnerability, and scorecard rules as CEL and have consistent, machine-evaluable decisions returned to any consumer.
Quick examples
Fail CI when any package violates policy (shell pseudo-workflow):
# Start local MCP server (background)
&
# Query MCP for packages detected in the repo (tooling gathers package