OpenSwarm: Command for Claude Code

.cursor/commands/mcp-code-exec.md

mcp-code-exec is a command for Claude Code, Cursor from VRSEN/OpenSwarm. It costs 0 tokens per session (2,872 once invoked), scanned A, original, MIT.

A command for converting an MCP server into a code-based setup where an agent loads only the tools it needs. MCP is a standard way for agents to connect to outside tools and data.

In plain words
What is it for?
Organising MCP tools as importable Python modules and processing data in code before returning results to the agent.
Why use it?
It reduces the amount of tool information and intermediate results placed in the agent’s working context when many tools are connected.

Command for Claude CodeCursor

Written for Cursor and Claude Code: installed under .cursor/, but also a Claude Code command (commands/*.md).

This is VRSEN/OpenSwarm's own configuration. It tells Claude Code and Cursor how to work on OpenSwarm itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything OpenSwarm configures →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is ./agent_name/mcp_servers/[server_name]/.

About the project

OpenSwarm is an open-source multi-agent system in which specialized agents coordinate to produce deliverables such as presentations, research reports, data visualizations, documents, images, and videos. It is intended for people who want to request complex creative or analytical work from a terminal, with connections to external services. Its catalogue entries define agents, commands, rules, and instructions for those workflows.

VRSEN/OpenSwarm · 2,873 stars · on GitHub

Reuse

Borrowing it

Nothing to install: this file belongs to VRSEN/OpenSwarm. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/VRSEN/OpenSwarm/main/.cursor/commands/mcp-code-exec.md
Clone the repo
git clone --depth 1 https://github.com/VRSEN/OpenSwarm

Made for: Claude Code, Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mcp-code-exec

README.md
[![agentmods](https://agentmods.dev/badge/commands/vrsen/openswarm/mcp-code-exec/github.svg)](https://agentmods.dev/commands/vrsen/openswarm/mcp-code-exec)
Your own site
<a href="https://agentmods.dev/commands/vrsen/openswarm/mcp-code-exec"><img src="https://agentmods.dev/badge/commands/vrsen/openswarm/mcp-code-exec/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mcp-code-exec

Your own site · 80×15
<a href="https://agentmods.dev/commands/vrsen/openswarm/mcp-code-exec"><img src="https://agentmods.dev/badge/commands/vrsen/openswarm/mcp-code-exec.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,872 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.02872
Opus 5.5 $0.00000 $0.01149
Sonnet 5.5 $0.00000 $0.00574
Haiku 4.5 $0.00000 $0.00287

Measured 1mo ago against content hash 7f824ab799bd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

mcp-code-exec 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 1mo 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.

.cursor/commands/mcp-code-exec.md · 334 lines

How it starts

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

MCP Code Execution Pattern - Implementation Guide

Your task is to convert an MCP server into the Code Execution Pattern described in Anthropic's blog post. This pattern enables progressive disclosure of tools, reducing token usage by up to 98% compared to loading all tools upfront.

Why This Pattern?

Problem with Traditional MCP:

  • Loading all tools upfront consumes 150,000+ tokens
  • Intermediate tool results flow through model context repeatedly
  • Agents slow down with many connected tools

Solution - Code Execution Pattern:

  • Tools organized as importable Python modules (filesystem-based)
  • Agents load only what they need (progressive disclosure)
  • Data processing happens in code before returning to model
  • Result: 98.7% token reduction (150K → 2K tokens)

Step-by-Step Implementation

Step 0: Create a TO-DO List.

Before starting, check if the user has provided the necessary auth credentials for the MCP servers. If not, ask the user to provide them before starting this task.

After credentials are provided, create a to-do list for yourself with all the steps you need to complete below.

Step 1: Create MCP Server Files

Create a dedicated folder for the MCP server in ./agent_name/mcp_servers/ directory.

Example:

./agent_name/mcp_servers/[server_name]/
├── notion.py           # Server singleton & connection management (with discovery in __main__)
├── salesforce.py
├── github.py
├── youtube.py
└── __init__.py         # Package exports

Step 2: Create the Server Module

The server.py module manages the MCP server connection as a singleton. It is converted into tools using ToolFactory.from_mcp method, available in agency_swarm specifically for this pattern. This method converts the MCP server into a list of tools.

Include tool discovery in the __main__ block to list available tools.

Note: This pattern works with any MCP server type, except HostedMCPTool. The template below shows MCPServerStdio (most common), but you can use:

Read the full file on GitHub · 334 lines

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. 1mo ago First seen · 334 lines · 0 tokens per session scan A 7f824ab799bd

Subscribe to this mod's changes

mcp-code-exec is a command published in the GitHub repository VRSEN/OpenSwarm (2,873 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,872 tokens. 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.