[Docs/Workaround] Document pre-fetch pattern for MCP tools in sub-agents
Problem
Sub-agents spawned via the Task tool cannot access MCP tools. This is a known limitation tracked in:
- #21560 - Plugin-defined subagents cannot access MCP tools
- #22430 - Feature Request: Pass MCP tool access to Task subagents
- #16803 -
context: forkdoesn't work
This affects the entire plugin ecosystem. Plugins like GSD (Get Shit Done) correctly specify mcp__context7__* in agent tools, but sub-agents can't use them at runtime and fall back to weaker alternatives like WebSearch.
Workaround Pattern: Pre-fetch in Orchestrator
Since orchestrators run in main context (which HAS MCP access), they can pre-fetch content before spawning sub-agents.
Pattern
BEFORE (broken):
Orchestrator → spawns Agent → Agent tries MCP → FAILS → falls back to WebSearch
AFTER (workaround):
Orchestrator (has MCP) → fetches docs via context7/etc → passes inline to Agent prompt
↓
Agent → synthesizes from provided docs (no MCP needed)
Implementation Example
In an orchestrator/skill that spawns a research agent:
## Step: Pre-fetch Documentation (MCP Workaround)
Before spawning the research agent, fetch relevant docs in the orchestrator:
1. Identify libraries from phase/project context
2. For each library:
- mcp__context7__resolve-library-id(libraryName: "{library}")
- mcp__context7__query-docs(libraryId: "{id}", query: "getting started, API reference")
3. Store results in PREFETCHED_DOCS
4. Include in agent prompt:
<prefetched_documentation>
{PREFETCHED_DOCS}
</prefetched_documentation>
Then update agent instructions:
## Tool Priority
1. Check <prefetched_documentation> in prompt first
2. WebFetch direct URLs for gaps
3. WebSearch only as last resort
Request
- Document this pattern in the official docs as a workaround until #21560/#22430 are fixed
- Consider adding a helper - e.g.,
prefetch_mcpparameter on Task tool that auto-fetches specified MCP results before spawning
Alternative Workarounds
| Approach | How | Limitation |
|----------|-----|------------|
| Pre-fetch in orchestrator | Orchestrator calls MCP, passes results to agent | Increases orchestrator complexity |
| Direct WebFetch URLs | Agent fetches known doc URLs directly | Requires hardcoded URLs |
| Research cache | Pre-fetch at project init, store on disk | May become stale |
Affected Plugins
Any plugin that:
- Defines custom agents in
~/.claude/plugins/*/agents/ - Expects those agents to use MCP tools
- Uses the Task tool to spawn specialized agents
This is a significant portion of the plugin ecosystem.
---
Related: glittercowboy/get-shit-done#383 (workaround proposal for GSD specifically)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗