Skills with context: fork still inject all MCP tool definitions into subagent, ignoring allowed-tools

Status Closed — not planned
Maintainer reply ✓ Yes — localden
Activity 6 comments · opened Mar 28, 2026 · closed May 23, 2026
💡 Likely answer: A maintainer (localden, collaborator) responded on this thread — see the highlighted reply below.

Problem

When a skill uses context: fork with a smaller model (e.g., model: haiku), the subagent's system prompt includes all MCP tool definitions from the parent session — even when allowed-tools explicitly restricts the skill to only basic tools like Bash, Read, Edit, etc.

This causes "Prompt is too long" errors when the user has many MCP servers connected (e.g., PostHog, Stripe, Notion, Vercel, Sentry, etc. — 200+ tools), as the tool definitions alone can exceed Haiku's context window.

Reproduction

  1. Connect several MCP servers (cloud-hosted ones like PostHog, Stripe, Notion add up fast)
  2. Create a skill with this frontmatter:

```yaml
---
name: my-skill
context: fork
model: haiku
allowed-tools:

  • Bash
  • Read
  • Edit
  • Write
  • Glob
  • Grep

---
```

  1. Invoke the skill via /my-skill
  2. Result: "Prompt is too long" — the subagent can't start because MCP tool definitions overflow Haiku's context

Expected behavior

allowed-tools should control which tool definitions are injected into the subagent's system prompt, not just which tools the subagent is allowed to call. If a skill only needs Bash, Read, Edit, Write, Glob, Grep, MCP tool definitions should be excluded from the prompt entirely.

Alternatively, a new frontmatter field like exclude-mcp-tools: true or inherit-mcp: false would let skill authors opt out of MCP tool injection.

Workaround

Change model: haiku to model: sonnet (larger context window). This works but wastes tokens and costs more for skills that don't need MCP tools at all.

Environment

  • Claude Code CLI (macOS)
  • ~200 MCP tools connected via claude.ai integrations + local MCP servers
  • Skill using context: fork + model: haiku

View original on GitHub ↗

6 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/39562
  2. https://github.com/anthropics/claude-code/issues/37793
  3. https://github.com/anthropics/claude-code/issues/38928

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

fabb · 6 months ago
ray-amjad · 6 months ago

Thank you. But I hope they have a long-term fix. I'm still having the same problem 2 weeks later.

aak204 · 6 months ago

Yeah, injecting the entire schema while only allowing a few tools to be called is a massive waste of context. Until this is fixed upstream, you can use toolc to physically truncate what the agent sees. It's a proxy I wrote that compiles multiple servers down to a strict endpoint. If the tool isn't in the compiled proxy, it never even reaches the prompt.
Repo: https://github.com/aak204/Tool-Catalog-Compiler

localden collaborator · 4 months ago

Thanks for the report. This is the same issue as #37793 (subagent inherits all MCP tool defs, prompt too long). Consolidating tracking there.

github-actions[bot] · 3 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.