Run a chain of 20 tool calls as one code block
何时使用: A task needs many tool calls (fetch N issues, enrich each, post summary).
前置条件
- pctx installed and configured — brew install portofcontext/tap/pctx; pctx config add <upstream-mcp>
步骤
-
Register upstreams with credentialspctx config add github --env GITHUB_TOKEN=... and add sentry --env SENTRY_TOKEN=....✓ 已复制→ 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.✓ 已复制→ Code block + single execution result
-
Inspect the resultSummarize the array in English and flag any issue whose releasing commit was by a specific author.✓ 已复制→ Final answer grounded in the data
结果: 10x fewer tool-call round-trips, major token savings, same result.
注意事项
- 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