Back to KB

save --ignore-scripts`

Difficulty
Intermediate
Read Time
82 min

The MCP package looked clean. The installed tree did not.

By Codcompass Team··82 min read

Securing the MCP Tool Surface: Why Transitive Dependency Scanning is Non-Negotiable

Current Situation Analysis

The Model Context Protocol (MCP) has rapidly evolved into the standard interface for connecting AI agents to external tools and data sources. As organizations integrate MCP servers into their agent workflows, a critical security assumption is being tested: that the safety of an MCP server is defined by its top-level package.

This assumption is flawed. MCP servers are installable tool surfaces. When an operator or an agent runtime installs an MCP server, the package manager resolves a complete dependency tree. This tree includes transitive dependencies that the server author may not directly control, yet these dependencies execute within the same security context as the server itself.

A recent audit of 31 MCP server packages across npm and PyPI revealed a massive discrepancy between surface-level checks and actual runtime risk. The audit performed two distinct evaluations for each package:

  1. Direct Package Check: Scanning only the top-level package metadata and declared dependencies.
  2. Installed Tree Scan: Resolving the package, installing it in isolation, and scanning the full dependency graph.

The results were stark. Direct package checks identified only 1 finding across the entire population. In contrast, installed tree scans uncovered 69 findings. This indicates that 35% of the audited servers (11 out of 31) introduced vulnerabilities through their transitive dependencies, even when the top-level package appeared clean.

This gap is often overlooked because many security tools default to shallow scanning. Operators assume that if a package has no known vulnerabilities attached to its identifier, it is safe to deploy. However, the audit data proves that the risk profile of an MCP server is determined by its runtime dependency graph, not its registry entry. Furthermore, the audit covered 21 npm packages and 10 PyPI packages, highlighting that MCP is a polyglot ecosystem; security programs limited to a single language runtime are inherently incomplete.

WOW Moment: Key Findings

The delta between shallow and deep scanning is not marginal noise; it represents a fundamental blind spot in current MCP adoption practices. The severity distribution of the findings further underscores the urgency. The installed tree scan detected vulnerabilities ranging from critical to medium, with a significant concentration in high-severity categories.

Scan StrategyFindings DetectedUnique VulnerabilitiesCritical/High SeverityEcosystem Coverage
Top-Level Package Check110Single Ecosystem
Installed Dependency Tree695436 (2 Critical, 34 High)npm + PyPI

Why this matters:

  • Risk Multiplier: The tree scan detected 68x more findings than the package check. Relying on shallow scans leaves the vast majority of supply chain risk undetected.
  • Severity Concentration: Of the 54 unique vulnerabilities found in trees, 36 were rated Critical or High. This is not low-severity clutter; these are actionable risks that could compromise the host environment or the data accessed by the MCP server.
  • Polyglot Reality: With nearly one-third of the targets being PyPI packages, any MCP security posture that ignores Python dependencies is leaving a significant portion of the attack surface unmonitored.

Core Solution

To mitigate transitive dependency risks in MCP deployments, organizations must shift from package-level validation to runtime tree analysis. This requires a workflow that resolves dependencies in isolation, captures the exact installed versions, and scans the full graph before deployment.

Architecture Decisions

  1. Isolation: MCP servers must be installed in a sandboxed environment during the audit phase. Installing directly into a host environment risks contamination and makes it difficult to attribute findings to the specific server under test.
  2. **

🎉 Mid-Year Sale — Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register — Start Free Trial

7-day free trial · Cancel anytime · 30-day money-back