CE-MCP将代码执行融入智能体系统,提升效率但放大安全风险。
From Tool Orchestration to Code Execution: A Study of MCP Design Choices
- 用代码块统一调度工具,避免逐个调用的低效
- 相比传统模式,降低60%以上令牌消耗和延迟
- 适合需要复杂流程的生产级智能体系统
模型上下文协议(MCP)为智能体系统提供统一平台,用于发现、选择和编排异构环境中的工具。随着工具目录扩大和多个MCP服务器并行连接,传统逐工具调用导致协调开销增加、状态管理碎片化,并限制长上下文操作。为此,近期设计引入代码执行作为核心能力,形成代码执行型MCP(CE-MCP),使智能体可将SQL查询、文件分析、多步数据转换等复杂流程整合为单一程序,在隔离运行环境中执行。本文形式化区分上下文耦合(传统)与解耦(CE-MCP)架构,分析其可扩展性权衡。基于MCP-Bench框架在10个代表性服务器上评估任务行为、工具使用模式、执行延迟与协议效率,结果表明CE-MCP显著降低令牌使用量与执行延迟,但攻击面大幅扩展。通过应用MAESTRO框架,识别出五个执行阶段中的十六类攻击,包括异常媒介代码注入与不安全能力合成等具体威胁。在多种LLM上验证漏洞,并提出分层防御架构,包含容器沙箱与语义门控。研究为生产级可执行智能体工作流提供了可扩展与安全平衡的路线图。
原文摘要 · Abstract (English)
Model Context Protocols (MCPs) provide a unified platform for agent systems to discover, select, and orchestrate tools across heterogeneous execution environments. As MCP-based systems scale to incorporate larger tool catalogs and multiple concurrently connected MCP servers, traditional tool-by-tool invocation increases coordination overhead, fragments state management, and limits support for wide-context operations. To address these scalability challenges, recent MCP designs have incorporated code execution as a first-class capability, an approach called Code Execution MCP (CE-MCP). This enables agents to consolidate complex workflows, such as SQL querying, file analysis, and multi-step data transformations, into a single program that executes within an isolated runtime environment. In this work, we formalize the architectural distinction between context-coupled (traditional) and context-decoupled (CE-MCP) models, analyzing their fundamental scalability trade-offs. Using the MCP-Bench framework across 10 representative servers, we empirically evaluate task behavior, tool utilization patterns, execution latency, and protocol efficiency as the scale of connected MCP servers and available tools increases, demonstrating that while CE-MCP significantly reduces token usage and execution latency, it introduces a vastly expanded attack surface. We address this security gap by applying the MAESTRO framework, identifying sixteen attack classes across five execution phases-including specific code execution threats such as exception-mediated code injection and unsafe capability synthesis. We validate these vulnerabilities through adversarial scenarios across multiple LLMs and propose a layered defense architecture comprising containerized sandboxing and semantic gating. Our findings provide a rigorous roadmap for balancing scalability and security in production-ready executable agent workflows.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。