SA
OfficialSecurity

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.

Quick Install
npx -y @docs/mcp.md

Overview

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
curl -LO https://github.com/safedep/vet/releases/download/vX.Y.Z/vet_X.Y.Z_linux_amd64.tar.gz
tar -xzf vet_X.Y.Z_linux_amd64.tar.gz
sudo mv vet /usr/local/bin/

Run with Docker:

docker run -d \
  -e SAFEDEP_API_KEY="${SAFEDEP_API_KEY}" \
  -p 8080:8080 \
  ghcr.io/safedep/vet:mcp-latest

Build from source (Go):

git clone https://github.com/safedep/vet.git
cd vet
go build ./cmd/vet
./vet server --mcp

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.

EndpointMethodPurpose
/mcp/contextPOSTReturn enriched context and policy decision for one or more packages
/healthGETLiveness/health check
/metricsGETPrometheus metrics (if enabled)

Example request (POST /mcp/context):

{
  "packages": [
    {"ecosystem": "npm", "name": "lodash", "version": "4.17.21"},
    {"ecosystem": "pypi", "name": "requests", "version": "2.31.0"}
  ],
  "policy": "default" 
}

Example (abbreviated) response:

{
  "results": [
    {
      "package": {"ecosystem":"npm","name":"lodash","version":"4.17.21"},
      "vulns": {"critical": 0, "high": 1, "evidence": [...]},
      "malware": {"flagged": false},
      "licenses": ["MIT"],
      "policy_decision": {"allowed": true, "reasons": []}
    },
    ...
  ]
}

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)
vet server --mcp &

# Query MCP for packages detected in the repo (tooling gathers package