mcp-code-execution

A design pattern for agents that use code to interact with MCP servers, which provide tools and data to AI systems. The pattern lets an agent discover and call many tools through generated code.

In plain words
What is it for?
Use it when building agents that work across many MCP tools, process large results, need conditional workflows, or must keep personal data out of the model context.
Why use it?
It keeps large intermediate results and repeated tool calls out of the main conversation and supports loops, retries, state, and sensitive-data handling.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/laurigates/claude-plugins/mcp-code-execution
Any agent
npx skills add laurigates/claude-plugins --skill mcp-code-execution
Clone the repo
git clone --depth 1 https://github.com/laurigates/claude-plugins

Made for: Claude Code, Codex.

Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,197 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00043 $0.01197
Opus 5 $0.00022 $0.00598
Sonnet 5 $0.00009 $0.00239
Haiku 4.5 $0.00004 $0.00120

Measured 2d ago against content hash 13575b2da7dc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mcp-code-execution scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agent-patterns-plugin/skills/mcp-code-execution/SKILL.md · 123 lines

How it starts

The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MCP Code Execution Pattern

Expert knowledge for designing agent systems that generate and execute code to interact with MCP servers, instead of calling tools directly.

For the typed-wrapper code, the six key-pattern examples, and the project scaffolding steps, see REFERENCE.md.

When to Use This Skill

Use code execution when... Use direct tool calls / mcp-management when...
Designing agents that fan out across 10+ MCP servers or 50+ tools Installing or configuring one or two servers in .mcp.json
Intermediate results are large (>10K tokens) and would blow context Results are small and all needed by the model
Workflows need loops, retries, or conditionals across tool calls Linear sequences of 2–3 tool calls
PII must not reach the model context Tool responses contain no sensitive data
Tasks benefit from state persistence across runs Stateless, one-shot operations
You want agents to accumulate reusable skills Fixed, predefined workflows

Core Architecture

How It Works

Instead of loading all MCP tool definitions into context upfront, the agent:

  1. Discovers available tools by navigating a typed file tree
  2. Generates TypeScript/Python code that imports and calls typed wrapper functions
  3. Executes the code in a sandboxed environment
  4. Returns only filtered/summarized results to the model

This reduces token usage from O(all_tool_definitions) to O(only_relevant_imports).

File Tree Structure

project/
├── servers/
│   ├── google-drive/
│   │   ├── getDocument.ts
│   │   ├── getSheet.ts
│   │   └── index.ts          # Re-exports all tools
│   ├── salesforce/
│   │   └── index.ts
│   └── slack/
│       └── index.ts
├── skills/                    # Agent-accumulated reusable functions
├── workspace/                 # Persistent state between executions
├── client.ts                  # MCP client that routes calls to servers
└── sandbox.config.ts          # Execution environment configuration

Read the full file on GitHub · 123 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 123 lines · 43 tokens per session scan A 13575b2da7dc

Subscribe to this mod's changes

mcp-code-execution is a skill published in the GitHub repository laurigates/claude-plugins (54 stars, last pushed 3d ago), licensed MIT. It adds 43 tokens to every session and 1,197 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

a0-review-plugin

Full audit of Agent Zero plugins in usr/plugins/. Reviews manifest validity, directory structure, code patterns (Store Gating, notifications, imports), security, and duplicate detection against the community index. Use when asked to review, audit, validate, or check an existing plugin before using or contributing it.

agent0ai/agent-zero · 64 tokens

dev-environment-bootstrapping

Use this skill when the user asks to bootstrap, set up, create, or initialize a Shopware development environment from scratch — phrases like "set up a Shopware dev environment", "clone and install Shopware", "initialize a Shopware plugin project", "bootstrap Shopware and a new plugin called X", "get a fresh Shopware…

shopwareLabs/ai-coding-tools · 144 tokens

phpunit-integration-to-unit-migrating

Use this skill ONLY when the user explicitly requests an audit, migration, or evaluation of whether a Shopware integration test belongs in the unit suite — trigger phrases like "audit integration tests", "migrate integration tests to unit", "is this an integration test or a unit test", "evaluate integration tests for…

shopwareLabs/ai-coding-tools · 152 tokens

commit-message-writing

Use this skill when the user explicitly asks to generate, write, draft, or create a commit message, squash commit, commit title, or merge commit message for the Shopware core repository (shopware/shopware). Supports two modes — full commit messages (title + body) for branch commits, and squash merge titles…

shopwareLabs/ai-coding-tools · 160 tokens

hermes-diagnostic-review

Use when running a read-only diagnostic review of recent Hermes sessions to find recurring mistakes, failed tool calls, and repeated fixes, then propose suggestion-only improvements and reusable skills. Human-gated; never auto-applies.

AtlasOmnia/hermes-custom-pack · 49 tokens

a0-manage-plugin

Manage Agent Zero plugins lifecycle: browse the Plugin Hub, scan for security, install from Git/ZIP/Plugin Hub, update, uninstall, enable, disable, debug, and troubleshoot. Use when asked to install, update, uninstall, remove, scan, find, search, enable, disable, debug, or troubleshoot a plugin.

agent0ai/agent-zero · 72 tokens