Run a chain of 20 tool calls as one code block
When to use: A task needs many tool calls (fetch N issues, enrich each, post summary).
Prerequisites
- pctx installed and configured — brew install portofcontext/tap/pctx; pctx config add <upstream-mcp>
Flow
-
Register upstreams with credentialspctx config add github --env GITHUB_TOKEN=... and add sentry --env SENTRY_TOKEN=....✓ Copied→ Upstreams listed
-
Ask agent to write Code ModeIn pctx Code Mode, write a function that fetches the 10 newest Sentry issues, for each finds the releasing commit via github, and returns a summary array.✓ Copied→ Code block + single execution result
-
Inspect the resultSummarize the array in English and flag any issue whose releasing commit was by a specific author.✓ Copied→ Final answer grounded in the data
Outcome: 10x fewer tool-call round-trips, major token savings, same result.
Pitfalls
- Sandboxed code errors are opaque if you don't surface stderr — Wrap the code in try/catch and print caught errors so the LLM can self-correct
- Network allowlist too tight — legitimate calls blocked — Start broad, narrow based on actual host usage from logs