Efficiently compose multiple MCP tool operations by launching a subagent that writes and executes TypeScript or Python code. Use when you need to compose 3+ MCP tool calls, process their results together, implement complex logic, or avoid token overhead from loading many MCP tool schemas into main context. The subagent has MCP servers configured and writes code that calls tools dynamically.
Launches a subagent to write and execute code that orchestrates multiple MCP tool calls, enabling complex workflows while reducing token overhead.
npx claudepluginhub mcfearsome/cc-mcp-executor-skillThis skill inherits all available tools. When active, it can use any tool Claude has access to.
EXAMPLES.mdPYTHON_GUIDE.mdREFERENCE.mdSUBAGENT_SETUP.mdTYPESCRIPT_GUIDE.mdlib/mcp-client.tslib/mcp_client.pyscripts/python/conditional_logic.pyscripts/python/data_aggregation.pyscripts/python/error_recovery.pyscripts/python/file_processing.pyscripts/python/multi_tool_workflow.pyscripts/python/parallel_execution.pyscripts/typescript/conditional-logic.tsscripts/typescript/data-aggregation.tsscripts/typescript/error-recovery.tsscripts/typescript/file-processing.tsscripts/typescript/multi-tool-workflow.tsscripts/typescript/parallel-execution.tstemplates/basic-python.template.pyThis skill teaches you (Main Claude Code) how to efficiently handle multi-tool MCP workflows by launching a subagent that writes and executes code to compose MCP tool calls.
Main Context (YOU - no MCP servers configured)
↓
Recognize multi-tool MCP workflow needed
↓
Launch subagent via Task tool
↓
Subagent Context (has MCP servers configured)
↓
Write TypeScript/Python code
↓
Execute code via Bash (deno/python)
↓
Code calls multiple MCP tools via local MCP client
↓
Return results to YOU (main context)
Problem: Loading all MCP tool schemas into your main context causes token bloat (141k tokens for 47 tools).
Solution:
Benefits:
Multi-tool MCP workflows (3+ MCP tool calls needed)
Complex data processing across MCP tools
Conditional tool selection
Parallel MCP operations
Retry logic and error recovery
When you identify a multi-tool MCP workflow, use the Task tool to launch a subagent:
Task({
subagent_type: "general-purpose",
prompt: `You have access to MCP servers with the following tools:
- mcp__filesystem__readFile, writeFile, listDirectory
- mcp__database__query, insert, update
- [list the relevant tools for this task]
Task: [Describe the multi-tool workflow clearly]
Instructions:
1. Reference the cached script pattern from scripts/[relevant-script].ts
2. Write TypeScript code that:
- Imports: import { callMCPTool } from '../../lib/mcp-client.ts';
- Calls MCP tools using callMCPTool('mcp__server__tool', params)
- Processes and transforms data as needed
- Returns summary of results
3. Execute the code via Bash with MCP_CONFIG_PATH set:
MCP_CONFIG_PATH=~/.claude/subagent-mcp.json deno run --allow-read --allow-run --allow-env /tmp/script.ts
4. Return the execution results
Use the pattern from: [specify cached script that matches]
- scripts/typescript/multi-tool-workflow.ts (sequential pipeline)
- scripts/typescript/parallel-execution.ts (concurrent operations)
- scripts/typescript/error-recovery.ts (retry logic)
- scripts/typescript/file-processing.ts (batch file ops)
- scripts/typescript/conditional-logic.ts (dynamic tool selection)
- scripts/typescript/data-aggregation.ts (multi-source merging)
Expected output: [What you need back from the subagent]`
})
The skill includes 12 proven script patterns (6 TypeScript + 6 Python) in the scripts/ directory. Always reference these when launching subagents:
scripts/typescript/multi-tool-workflow.ts
scripts/typescript/parallel-execution.ts
scripts/typescript/error-recovery.ts
scripts/typescript/file-processing.ts
scripts/typescript/conditional-logic.ts
scripts/typescript/data-aggregation.ts
Same patterns available in scripts/python/:
multi_tool_workflow.pyparallel_execution.pyerror_recovery.pyfile_processing.pyconditional_logic.pydata_aggregation.pyUse this template when launching subagents:
Task({
subagent_type: "general-purpose",
prompt: `You are a subagent with access to MCP servers. Write code to complete this task.
## Available MCP Tools
[List the MCP servers/tools available - you should know these from your configuration]
- mcp__filesystem__readFile, writeFile, listDirectory
- mcp__database__query, insert
- [etc...]
## Task
[Clear description of what needs to be done]
## Instructions
1. **Reference Cached Pattern**
Use the pattern from: scripts/typescript/[most-similar-script].ts
- This script shows: [what pattern it demonstrates]
- Adapt it for: [how to modify for this task]
2. **Write TypeScript Code**
\`\`\`typescript
import { callMCPTool } from '../../lib/mcp-client.ts';
// [Step-by-step comments of what the code should do]
\`\`\`
3. **Tool Call Format**
- Format: callMCPTool('mcp__<server>__<tool>', { params })
- Example: callMCPTool('mcp__filesystem__readFile', { path: '/data/file.json' })
4. **Execute Code**
Run via Bash with MCP_CONFIG_PATH set:
\`\`\`bash
MCP_CONFIG_PATH=~/.claude/subagent-mcp.json deno run --allow-read --allow-run --allow-env /tmp/your-script.ts
\`\`\`
5. **Return Results**
Provide summary of:
- What was accomplished
- Number of records/files processed
- Any errors or warnings
- Final output data
## Expected Output
[Specify exactly what data/summary you need back]
## Error Handling
- Wrap all MCP calls in try/catch
- Log errors clearly
- [Any specific error handling needed]
`
})
"Read all JSON files in /tmp/data, aggregate the data, and store in database"
You recognize this needs:
You launch subagent:
Task({
subagent_type: "general-purpose",
prompt: `You have access to MCP servers with these tools:
- mcp__filesystem__listDirectory
- mcp__filesystem__readFile
- mcp__database__insert
Task: Read all JSON files in /tmp/data, parse them, aggregate the data, and store in database table 'aggregated_data'.
Instructions:
1. Use the pattern from scripts/typescript/file-processing.ts
- It shows: batch file operations with filtering and aggregation
- Adapt it to: read JSON files specifically and store results in DB
2. Write TypeScript code that:
- Lists files in /tmp/data
- Filters for .json extension
- Reads each JSON file
- Parses and aggregates the data
- Stores aggregated results in database
3. Import the MCP client:
import { callMCPTool } from '../../lib/mcp-client.ts';
4. Execute via:
MCP_CONFIG_PATH=~/.claude/subagent-mcp.json deno run --allow-read --allow-run --allow-env /tmp/aggregate-files.ts
5. Return: Number of files processed and records stored
Expected output: "Processed X files, stored Y records in database"`
})
scripts/typescript/file-processing.tsimport { callMCPTool } from '../../lib/mcp-client.ts';
const files = await callMCPTool('mcp__filesystem__listDirectory', {
path: '/tmp/data'
});
const jsonFiles = files.filter(f => f.name.endsWith('.json'));
const allData = [];
for (const file of jsonFiles) {
const content = await callMCPTool('mcp__filesystem__readFile', {
path: file.path
});
allData.push(...JSON.parse(content));
}
const aggregated = {
total_records: allData.length,
data: allData,
timestamp: new Date().toISOString()
};
await callMCPTool('mcp__database__insert', {
table: 'aggregated_data',
record: aggregated
});
console.log(`Processed ${jsonFiles.length} files, ${allData.length} records`);
You report to user: "✓ Successfully processed 15 JSON files from /tmp/data and stored 1,247 aggregated records in the database."
Format: mcp__<server>__<tool>
Examples:
mcp__filesystem__readFilemcp__database__querymcp__github__createPullRequestmcp__postgres__insertThe <server> name comes from the subagent's MCP configuration file (.mcp.json or ~/.claude/subagent-mcp.json).
TypeScript (Deno):
Python:
Default recommendation: Use TypeScript unless subagent explicitly needs Python libraries.
The subagent uses a local MCP client library to call tools:
TypeScript: lib/mcp-client.ts
import { callMCPTool, callMCPToolsParallel } from '../../lib/mcp-client.ts';
// Single tool call
const result = await callMCPTool('mcp__filesystem__readFile', {
path: '/data/file.json'
});
// Parallel calls
const [file1, file2, file3] = await callMCPToolsParallel([
{ tool: 'mcp__filesystem__readFile', parameters: { path: '/data/1.json' } },
{ tool: 'mcp__filesystem__readFile', parameters: { path: '/data/2.json' } },
{ tool: 'mcp__filesystem__readFile', parameters: { path: '/data/3.json' } }
]);
Python: lib/mcp_client.py
from lib.mcp_client import call_mcp_tool, call_mcp_tools_parallel
# Single tool call
result = await call_mcp_tool('mcp__filesystem__readFile', {
'path': '/data/file.json'
})
# Parallel calls
results = await call_mcp_tools_parallel([
{'tool': 'mcp__filesystem__readFile', 'parameters': {'path': '/data/1.json'}},
{'tool': 'mcp__filesystem__readFile', 'parameters': {'path': '/data/2.json'}},
{'tool': 'mcp__filesystem__readFile', 'parameters': {'path': '/data/3.json'}}
])
For simpler tasks, reference the templates in templates/:
basic-typescript.template.ts - Single tool call skeletonbasic-python.template.py - Single tool call skeletonmulti-tool.template.ts - Multiple tool compositionmulti-tool.template.py - Multiple tool compositionTell the subagent: "Use the pattern from templates/basic-typescript.template.ts"
Always instruct subagents to include error handling:
try {
const result = await callMCPTool('mcp__database__query', {
query: 'SELECT * FROM users'
});
return { success: true, data: result };
} catch (error) {
console.error('Database query failed:', error.message);
return { success: false, error: error.message };
}
Be specific about tools available
Reference cached patterns
Specify execution command
MCP_CONFIG_PATH=~/.claude/subagent-mcp.json before commanddeno run or python command--allow-read --allow-run --allow-envMCP_CONFIG_PATH=~/.claude/subagent-mcp.json deno run --allow-read --allow-run --allow-env script.tsDefine expected output clearly
Include error handling instructions
(These are instructions for the subagent, but you should know them to guide effectively)
Always import MCP client first
import { callMCPTool } from '../../lib/mcp-client.ts';
Use proper tool name format
mcp__<server>__<tool>Handle errors gracefully
Process data efficiently
Return useful summaries
If subagent task fails:
Check MCP configuration
.mcp.json?Verify tool name format
mcp__server__toolCheck MCP_CONFIG_PATH is set
MCP_CONFIG_PATH=~/.claude/subagent-mcp.jsonls -la ~/.claude/subagent-mcp.jsonCheck permissions
--allow-read --allow-run --allow-envReview generated code
Check execution output
You are Main Claude Code. When you encounter a multi-tool MCP workflow:
Key principle: You orchestrate, subagent executes. Keep your main context clean, let subagents handle the heavy MCP lifting.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.