[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DEDVSAMY72A4SBVS1AGC8F":3,"skill-same:01M6DEDVSAMY72A4SBVS1AGC8F":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":31,"publishedAt":52,"linkOnly":53,"markdownContent":54,"markdownBody":55,"frontMatter":56,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":14,"repositoryHtmlUrl":60,"repositoryHomepageUrl":6,"ownerHtmlUrl":61,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":62,"install":63,"resources":76},"01M6DEDVSAMY72A4SBVS1AGC8F","mcp-code-orchestrate",null,"Use when one task needs the SAME tool-call shape repeated across MANY items - an xref-walk over many functions, a descriptor sweep over many SMILES, or one query across several MCP servers. Write ONE script (Python via the Bash tool) that calls the provider CLIs, native libraries, or MCP stdio, filters IN-CODE, and returns ONLY the distilled result. Reach for it past ~5 same-shape calls.","Prekzursil\u002Fagent-skills-toolchain","Prekzursil","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F54636077?v=4","01M6DACZ1PCQHD99SCR1YXG28B","Andrei Mihai Visalon","01M6DACZ670WZF535V3WYYSS4Z",0,"MIT","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-code-orchestrate\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],"mcp code orchestrate","code","orchestrate","MCP","only","across","query","call","task","functions","provider","filters","shape","use","write","sweep","tool","Bash","libraries","python","2026-11-10 10:12:30",false,"---\nname: mcp-code-orchestrate\ndescription: Use when one task needs the SAME tool-call shape repeated across MANY items - an xref-walk over many functions, a descriptor sweep over many SMILES, or one query across several MCP servers. Write ONE script (Python via the Bash tool) that calls the provider CLIs, native libraries, or MCP stdio, filters IN-CODE, and returns ONLY the distilled result. Reach for it past ~5 same-shape calls.\nlicense: MIT\n---\n\n# MCP Code Orchestrate\n\n> **The 98.7% fan-out token-cut.** When you would otherwise call the same MCP\n> tool N times and let every raw result land in the context window, write **one\n> script** that does the loop, filters\u002Faggregates **in code**, and returns only\n> the distilled answer. Anthropic's \"Code execution with MCP\" reports a single\n> example dropping from ~150,000 tokens of tool chatter to ~2,000 (≈98.7% fewer)\n> by moving the fan-out into code instead of the model loop.\n\n## The pattern in one breath\n\nDirect tool-calling is right for **one** call: ask, get the answer, done. It is\n*pathological* for **fan-out** — \"enumerate-then-filter\" across the 39-server MCP\nfleet — because:\n\n1. Every tool *definition* you load is paid for on every turn (catalogue tax).\n2. Every tool *result* (a 4 KB JSON blob × N functions \u002F molecules \u002F papers)\n   is dumped verbatim into context, and the model re-reads all of it each turn.\n3. The model is doing a mechanical loop (iterate, test a predicate, collect hits)\n   that a `for` loop does for free, deterministically, off-context.\n\nThe fix: the agent writes **one Python script** (run via the **Bash** tool) that\ncalls the *underlying* provider — its native CLI\u002Flibrary when one exists, else\nthe MCP server over stdio\u002FHTTP — loops over all the items, applies the filter in\ncode, and **prints only the distilled result** (a shortlist, a count, the 12\nhits out of 4,000). Raw payloads stay on disk \u002F in process memory; only the\nanswer enters the conversation.\n\n## Decision rule (use this \u002F don't)\n\n| Situation | Do |\n|---|---|\n| One lookup, one answer | **Call the tool directly** (or load its schema with ToolSearch). Do NOT write a script. |\n| The same call shape **> ~5 times** (a loop over functions \u002F SMILES \u002F DOIs \u002F URLs) | **Code-orchestrate** — one script, filter in code, return the distilled result. |\n| Enumerate a large set, keep only the few that match a predicate | **Code-orchestrate.** |\n| Aggregate \u002F cross-corroborate one query across several MCP servers | **Code-orchestrate** (fan out in code, merge, dedupe, rank, return top-N). |\n| You need the model to *reason* between each call (each depends on the last) | Direct calls — the loop is not mechanical. |\n\nRule of thumb: **if you can describe the loop and the keep-predicate in one\nsentence, script it.** If each step needs fresh model judgement, don't.\n\nPairs with **ToolSearch** (deferred-tool loading): ToolSearch is the complement\nfor the *single*-call case — it fetches one tool's schema on demand so the\ncatalogue stays small. Code-orchestrate handles the *many*-call case so the\n*results* stay out of context. Use both: keep the listed-tool count low\n(ToolSearch) **and** the returned-token count low (code-orchestrate).\n\n## How a script reaches a provider — three access modes\n\nPrefer them in this order (cheapest\u002Fmost-robust first):\n\n### 1. Native CLI or Python library (best — zero MCP overhead)\n\nMany MCP servers are thin wrappers over a library or CLI you can call directly:\n\n- **rdkit** MCP → `from rdkit import Chem` (the actual library).\n- **radare2** MCP → `r2pipe` \u002F `r2 -c '\u003Ccmds>' -q binary`.\n- **github** MCP → `gh api ...`.\n- **android\u002Fadb** → `adb shell ...`.\n- **paper metadata** → the upstream REST APIs (Crossref \u002F OpenAlex \u002F Unpaywall)\n  with `requests` (all key-free).\n\nNo JSON-RPC, no server spawn, full speed. Reach for this whenever it exists.\n\n### 2. MCP server over stdio (one session, many calls)\n\nWhen the only access is the MCP server, spawn it **once** and reuse the session\nfor all N calls (amortise the startup over the whole fan-out). Drop this helper\ninto your script (MCP stdio transport = newline-delimited JSON-RPC):\n\n```python\nimport json, subprocess\n\nclass MCPSession:\n    \"\"\"One stdio MCP server, initialized once, called many times.\"\"\"\n    def __init__(self, cmd, env=None):\n        self.p = subprocess.Popen(\n            cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,\n            stderr=subprocess.DEVNULL, text=True, bufsize=1, env=env)\n        self._id = 0\n        self._send({\"jsonrpc\": \"2.0\", \"id\": self._next(), \"method\": \"initialize\",\n                    \"params\": {\"protocolVersion\": \"2024-11-05\", \"capabilities\": {},\n                               \"clientInfo\": {\"name\": \"orch\", \"version\": \"1\"}}})\n        self._recv()  # initialize result\n        self._send({\"jsonrpc\": \"2.0\", \"method\": \"notifications\u002Finitialized\"})\n\n    def _next(self):\n        self._id += 1\n        return self._id\n\n    def _send(self, obj):\n        self.p.stdin.write(json.dumps(obj) + \"\\n\")\n        self.p.stdin.flush()\n\n    def _recv(self):\n        for line in self.p.stdout:\n            line = line.strip()\n            if line.startswith(\"{\"):\n                return json.loads(line)\n        return None\n\n    def call(self, tool, arguments):\n        rid = self._next()\n        self._send({\"jsonrpc\": \"2.0\", \"id\": rid, \"method\": \"tools\u002Fcall\",\n                    \"params\": {\"name\": tool, \"arguments\": arguments}})\n        while (msg := self._recv()) is not None:\n            if msg.get(\"id\") == rid:\n                return msg.get(\"result\")\n        return None\n\n    def close(self):\n        try:\n            self.p.terminate()\n        except Exception:\n            pass\n\n# Example: spawn once, loop many.\n# sess = MCPSession([\"npx\", \"-y\", \"mcp-searxng@1.8.0\"],\n#                   env={**os.environ, \"SEARXNG_URL\": \"http:\u002F\u002F127.0.0.1:8890\"})\n# hits = [sess.call(\"searxng_web_search\", {\"query\": q}) for q in queries]\n# sess.close()\n```\n\n### 3. MCP server over HTTP (already-running servers)\n\nFor HTTP-transport MCPs the fleet keeps up (e.g. basic-memory on `:8765`), POST\nJSON-RPC with `requests` — no spawn at all. The IDA GUI MCP is reachable the\nsame way (`POST http:\u002F\u002F127.0.0.1:13337\u002Fmcp`); it is **read-only-safe** to query\nin a loop but **never** tear it down.\n\n## Concrete recipes\n\nThese are runnable templates — adapt the path\u002Fpredicate, run via the Bash tool,\nand read back only what they print.\n\n### (a) RE xref-walk — find the hot functions across a whole binary\n\nGoal: of thousands of functions, return only the few that are called from many\nsites (likely shared helpers \u002F good hook anchors). Direct tool-calling would\nneed one `get_xrefs_to` round-trip per function; the script does it in one pass\nand returns the top-20.\n\n```python\nimport json, r2pipe\n\nTHRESHOLD = 15\nr2 = r2pipe.open(\"\u002Fpath\u002Fto\u002Flib.so\", flags=[\"-2\"])  # -2 silences stderr\nr2.cmd(\"aa\")                                        # or: r2.cmd(\"Po project\")\nhits = []\nfor fn in r2.cmdj(\"aflj\") or []:                    # every function, as JSON\n    xrefs = r2.cmdj(f\"axtj @ {fn['offset']}\") or []  # xrefs TO this function\n    if len(xrefs) >= THRESHOLD:\n        hits.append({\"name\": fn[\"name\"], \"addr\": hex(fn[\"offset\"]),\n                     \"callers\": len(xrefs), \"size\": fn.get(\"size\", 0)})\nr2.quit()\nhits.sort(key=lambda h: -h[\"callers\"])\nprint(f\"{len(hits)} functions with >= {THRESHOLD} callers\")\nprint(json.dumps(hits[:20], indent=2))             # only the top-20 enter context\n```\n\nIDA\u002FGhidra-MCP variant: same loop, but `MCPSession.call(\"get_xrefs_to\", {...})`\n(stdio) or a `requests.post(\":13337\u002Fmcp\", ...)` loop (HTTP) instead of `axtj`.\nCollect only the addresses whose caller-count passes the predicate.\n\n### (b) Chemistry descriptor sweep over many SMILES (Lipinski screen)\n\nGoal: from a list of candidate molecules, keep only the drug-like ones. Calling\nthe rdkit MCP once per descriptor per molecule is hundreds of round-trips; the\nlibrary does it locally and returns only the passers.\n\n```python\nimport json\nfrom rdkit import Chem\nfrom rdkit.Chem import Descriptors, Crippen\n\nsmiles = [s for s in open(\"candidates.smi\").read().split() if s]\nkept = []\nfor smi in smiles:\n    m = Chem.MolFromSmiles(smi)\n    if m is None:\n        continue\n    mw, logp = Descriptors.MolWt(m), Crippen.MolLogP(m)\n    hbd, hba, tpsa = Descriptors.NumHDonors(m), Descriptors.NumHAcceptors(m), Descriptors.TPSA(m)\n    if mw \u003C= 500 and logp \u003C= 5 and hbd \u003C= 5 and hba \u003C= 10:   # Lipinski, in code\n        kept.append({\"smiles\": smi, \"mw\": round(mw, 1), \"logp\": round(logp, 2),\n                     \"tpsa\": round(tpsa, 1)})\nprint(f\"{len(kept)}\u002F{len(smiles)} pass Lipinski Ro5\")\nprint(json.dumps(sorted(kept, key=lambda r: r[\"mw\"])[:20], indent=2))\n```\n\n(Same shape for a Tanimoto similarity sweep: build one query fingerprint, loop a\nlibrary of SMILES, keep only `sim >= cutoff`.)\n\n### (c) Paper batch-resolve \u002F screen across the paper-search fleet\n\nGoal: turn a list of DOIs into a screened, ranked shortlist. Key-free Crossref\ncovers metadata directly; escalate to the paper-search \u002F scholarly-access MCP\n(stdio, via `MCPSession`) only for the survivors that need an OA-PDF resolve.\n\n```python\nimport json, time, requests\n\ndois = [d.strip() for d in open(\"dois.txt\") if d.strip()]\nkept = []\nfor doi in dois:\n    r = requests.get(f\"https:\u002F\u002Fapi.crossref.org\u002Fworks\u002F{doi}\",\n                     headers={\"User-Agent\": \"research-harness (mailto:you@example.com)\"},\n                     timeout=20)\n    if r.status_code != 200:\n        continue\n    msg = r.json()[\"message\"]\n    year = (msg.get(\"issued\", {}).get(\"date-parts\", [[None]])[0] or [None])[0]\n    cites = msg.get(\"is-referenced-by-count\", 0)\n    if year and year >= 2020 and cites >= 10:           # recency + impact screen\n        kept.append({\"doi\": doi, \"title\": (msg.get(\"title\") or [\"\"])[0],\n                     \"year\": year, \"cites\": cites})\n    time.sleep(0.2)                                      # be polite to the API\nkept.sort(key=lambda x: -x[\"cites\"])\nprint(f\"{len(kept)}\u002F{len(dois)} pass the 2020+\u002F10-cite screen\")\nprint(json.dumps(kept, indent=2))\n```\n\nOnly the shortlist (titles + DOIs + counts) enters context — not the full\nCrossref record for every DOI.\n\n### (d) Multi-source research aggregation (fan out, merge, rank)\n\nGoal: one query, several providers, a single deduped\u002Franked result. Fan out in\ncode, merge on URL, rank by how many independent providers returned each URL\n(in-code corroboration — feeds straight into `deep-research`'s grader).\n\n```python\nimport json, os\n# ... MCPSession from mode 2 above ...\n\nquery = \"post-quantum signature scheme adoption 2026\"\nresults = {}   # url -> {\"title\":..., \"providers\": set()}\n\ndef absorb(provider, items):\n    for it in items or []:\n        url = it.get(\"url\") or it.get(\"link\")\n        if not url:\n            continue\n        row = results.setdefault(url, {\"title\": it.get(\"title\", \"\"), \"providers\": set()})\n        row[\"providers\"].add(provider)\n\nsearx = MCPSession([\"npx\", \"-y\", \"mcp-searxng@1.8.0\"],\n                   env={**os.environ, \"SEARXNG_URL\": \"http:\u002F\u002F127.0.0.1:8890\"})\nabsorb(\"searxng\", (searx.call(\"searxng_web_search\", {\"query\": query}) or {}).get(\"results\"))\nsearx.close()\n# ...absorb(\"exa\", ...), absorb(\"tavily\", ...) the same way...\n\nranked = sorted(results.items(), key=lambda kv: -len(kv[1][\"providers\"]))\nout = [{\"url\": u, \"title\": d[\"title\"], \"corroboration\": len(d[\"providers\"]),\n        \"providers\": sorted(d[\"providers\"])} for u, d in ranked[:15]]\nprint(json.dumps(out, indent=2))   # top-15 by cross-provider corroboration\n```\n\n## Output discipline (so the win is real)\n\n- **Print only the distilled result** — a shortlist, a count, the hits. Never\n  `print()` the raw per-item payloads; that re-imports the bloat you were\n  avoiding. Write raw output to a temp file if you must keep it, and report the\n  path (this is the `context-sandbox` skill's rule).\n- **End with a terminal-state line** the orchestrator can read at a glance, e.g.\n  `KEPT 12\u002F4180 functions` or `SHORTLIST 8 papers -> shortlist.json`.\n- **Make it idempotent & re-runnable** — read inputs from a file\u002Fargv, not from\n  pasted-in context, so a re-run is one Bash call, not a re-derivation.\n- **Handle the empty\u002FNone case** — a flaky provider or unparsable item should\n  `continue`, not crash the whole sweep. The point is to finish the fan-out.\n- **Long sweeps (> ~60s)** go through `longrun` in the background (AGENTS.md §4a),\n  not a blocking foreground call.\n\n## When NOT to use this\n\n- A single tool call — just call it (optionally `ToolSearch` its schema first).\n- Steps that each need the model to reason on the previous result — the loop\n  isn't mechanical, so code can't stand in for the model.\n- Writes\u002Fmutations you can't safely batch (e.g. one-shot game patches) — keep a\n  human\u002Fagent in the loop per step.\n\n## References\n\n- Anthropic Engineering — **\"Code execution with MCP: building more efficient\n  agents\"** (2025): the canonical write-up of this pattern and the ~98.7%\n  token-reduction example (≈150k → ≈2k tokens on a fan-out task).\n- Anthropic Engineering — **\"Writing effective tools for agents\"** and the\n  **Claude Agent SDK** docs (tool\u002Fobservation design; why mechanical loops\n  belong in code, not the model turn).\n- **Model Context Protocol** spec — *Transports* (stdio = newline-delimited\n  JSON-RPC; Streamable HTTP) for the `MCPSession` \u002F HTTP access modes.\n- Sibling skills: `context-sandbox` (sandbox raw payloads, surface only the\n  answer), `deep-research` (the routing\u002Fgrading harness this feeds), and\n  `ToolSearch` deferred-tool loading (the single-call complement).\n","# MCP Code Orchestrate\n\n> **The 98.7% fan-out token-cut.** When you would otherwise call the same MCP\n> tool N times and let every raw result land in the context window, write **one\n> script** that does the loop, filters\u002Faggregates **in code**, and returns only\n> the distilled answer. Anthropic's \"Code execution with MCP\" reports a single\n> example dropping from ~150,000 tokens of tool chatter to ~2,000 (≈98.7% fewer)\n> by moving the fan-out into code instead of the model loop.\n\n## The pattern in one breath\n\nDirect tool-calling is right for **one** call: ask, get the answer, done. It is\n*pathological* for **fan-out** — \"enumerate-then-filter\" across the 39-server MCP\nfleet — because:\n\n1. Every tool *definition* you load is paid for on every turn (catalogue tax).\n2. Every tool *result* (a 4 KB JSON blob × N functions \u002F molecules \u002F papers)\n   is dumped verbatim into context, and the model re-reads all of it each turn.\n3. The model is doing a mechanical loop (iterate, test a predicate, collect hits)\n   that a `for` loop does for free, deterministically, off-context.\n\nThe fix: the agent writes **one Python script** (run via the **Bash** tool) that\ncalls the *underlying* provider — its native CLI\u002Flibrary when one exists, else\nthe MCP server over stdio\u002FHTTP — loops over all the items, applies the filter in\ncode, and **prints only the distilled result** (a shortlist, a count, the 12\nhits out of 4,000). Raw payloads stay on disk \u002F in process memory; only the\nanswer enters the conversation.\n\n## Decision rule (use this \u002F don't)\n\n| Situation | Do |\n|---|---|\n| One lookup, one answer | **Call the tool directly** (or load its schema with ToolSearch). Do NOT write a script. |\n| The same call shape **> ~5 times** (a loop over functions \u002F SMILES \u002F DOIs \u002F URLs) | **Code-orchestrate** — one script, filter in code, return the distilled result. |\n| Enumerate a large set, keep only the few that match a predicate | **Code-orchestrate.** |\n| Aggregate \u002F cross-corroborate one query across several MCP servers | **Code-orchestrate** (fan out in code, merge, dedupe, rank, return top-N). |\n| You need the model to *reason* between each call (each depends on the last) | Direct calls — the loop is not mechanical. |\n\nRule of thumb: **if you can describe the loop and the keep-predicate in one\nsentence, script it.** If each step needs fresh model judgement, don't.\n\nPairs with **ToolSearch** (deferred-tool loading): ToolSearch is the complement\nfor the *single*-call case — it fetches one tool's schema on demand so the\ncatalogue stays small. Code-orchestrate handles the *many*-call case so the\n*results* stay out of context. Use both: keep the listed-tool count low\n(ToolSearch) **and** the returned-token count low (code-orchestrate).\n\n## How a script reaches a provider — three access modes\n\nPrefer them in this order (cheapest\u002Fmost-robust first):\n\n### 1. Native CLI or Python library (best — zero MCP overhead)\n\nMany MCP servers are thin wrappers over a library or CLI you can call directly:\n\n- **rdkit** MCP → `from rdkit import Chem` (the actual library).\n- **radare2** MCP → `r2pipe` \u002F `r2 -c '\u003Ccmds>' -q binary`.\n- **github** MCP → `gh api ...`.\n- **android\u002Fadb** → `adb shell ...`.\n- **paper metadata** → the upstream REST APIs (Crossref \u002F OpenAlex \u002F Unpaywall)\n  with `requests` (all key-free).\n\nNo JSON-RPC, no server spawn, full speed. Reach for this whenever it exists.\n\n### 2. MCP server over stdio (one session, many calls)\n\nWhen the only access is the MCP server, spawn it **once** and reuse the session\nfor all N calls (amortise the startup over the whole fan-out). Drop this helper\ninto your script (MCP stdio transport = newline-delimited JSON-RPC):\n\n```python\nimport json, subprocess\n\nclass MCPSession:\n    \"\"\"One stdio MCP server, initialized once, called many times.\"\"\"\n    def __init__(self, cmd, env=None):\n        self.p = subprocess.Popen(\n            cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,\n            stderr=subprocess.DEVNULL, text=True, bufsize=1, env=env)\n        self._id = 0\n        self._send({\"jsonrpc\": \"2.0\", \"id\": self._next(), \"method\": \"initialize\",\n                    \"params\": {\"protocolVersion\": \"2024-11-05\", \"capabilities\": {},\n                               \"clientInfo\": {\"name\": \"orch\", \"version\": \"1\"}}})\n        self._recv()  # initialize result\n        self._send({\"jsonrpc\": \"2.0\", \"method\": \"notifications\u002Finitialized\"})\n\n    def _next(self):\n        self._id += 1\n        return self._id\n\n    def _send(self, obj):\n        self.p.stdin.write(json.dumps(obj) + \"\\n\")\n        self.p.stdin.flush()\n\n    def _recv(self):\n        for line in self.p.stdout:\n            line = line.strip()\n            if line.startswith(\"{\"):\n                return json.loads(line)\n        return None\n\n    def call(self, tool, arguments):\n        rid = self._next()\n        self._send({\"jsonrpc\": \"2.0\", \"id\": rid, \"method\": \"tools\u002Fcall\",\n                    \"params\": {\"name\": tool, \"arguments\": arguments}})\n        while (msg := self._recv()) is not None:\n            if msg.get(\"id\") == rid:\n                return msg.get(\"result\")\n        return None\n\n    def close(self):\n        try:\n            self.p.terminate()\n        except Exception:\n            pass\n\n# Example: spawn once, loop many.\n# sess = MCPSession([\"npx\", \"-y\", \"mcp-searxng@1.8.0\"],\n#                   env={**os.environ, \"SEARXNG_URL\": \"http:\u002F\u002F127.0.0.1:8890\"})\n# hits = [sess.call(\"searxng_web_search\", {\"query\": q}) for q in queries]\n# sess.close()\n```\n\n### 3. MCP server over HTTP (already-running servers)\n\nFor HTTP-transport MCPs the fleet keeps up (e.g. basic-memory on `:8765`), POST\nJSON-RPC with `requests` — no spawn at all. The IDA GUI MCP is reachable the\nsame way (`POST http:\u002F\u002F127.0.0.1:13337\u002Fmcp`); it is **read-only-safe** to query\nin a loop but **never** tear it down.\n\n## Concrete recipes\n\nThese are runnable templates — adapt the path\u002Fpredicate, run via the Bash tool,\nand read back only what they print.\n\n### (a) RE xref-walk — find the hot functions across a whole binary\n\nGoal: of thousands of functions, return only the few that are called from many\nsites (likely shared helpers \u002F good hook anchors). Direct tool-calling would\nneed one `get_xrefs_to` round-trip per function; the script does it in one pass\nand returns the top-20.\n\n```python\nimport json, r2pipe\n\nTHRESHOLD = 15\nr2 = r2pipe.open(\"\u002Fpath\u002Fto\u002Flib.so\", flags=[\"-2\"])  # -2 silences stderr\nr2.cmd(\"aa\")                                        # or: r2.cmd(\"Po project\")\nhits = []\nfor fn in r2.cmdj(\"aflj\") or []:                    # every function, as JSON\n    xrefs = r2.cmdj(f\"axtj @ {fn['offset']}\") or []  # xrefs TO this function\n    if len(xrefs) >= THRESHOLD:\n        hits.append({\"name\": fn[\"name\"], \"addr\": hex(fn[\"offset\"]),\n                     \"callers\": len(xrefs), \"size\": fn.get(\"size\", 0)})\nr2.quit()\nhits.sort(key=lambda h: -h[\"callers\"])\nprint(f\"{len(hits)} functions with >= {THRESHOLD} callers\")\nprint(json.dumps(hits[:20], indent=2))             # only the top-20 enter context\n```\n\nIDA\u002FGhidra-MCP variant: same loop, but `MCPSession.call(\"get_xrefs_to\", {...})`\n(stdio) or a `requests.post(\":13337\u002Fmcp\", ...)` loop (HTTP) instead of `axtj`.\nCollect only the addresses whose caller-count passes the predicate.\n\n### (b) Chemistry descriptor sweep over many SMILES (Lipinski screen)\n\nGoal: from a list of candidate molecules, keep only the drug-like ones. Calling\nthe rdkit MCP once per descriptor per molecule is hundreds of round-trips; the\nlibrary does it locally and returns only the passers.\n\n```python\nimport json\nfrom rdkit import Chem\nfrom rdkit.Chem import Descriptors, Crippen\n\nsmiles = [s for s in open(\"candidates.smi\").read().split() if s]\nkept = []\nfor smi in smiles:\n    m = Chem.MolFromSmiles(smi)\n    if m is None:\n        continue\n    mw, logp = Descriptors.MolWt(m), Crippen.MolLogP(m)\n    hbd, hba, tpsa = Descriptors.NumHDonors(m), Descriptors.NumHAcceptors(m), Descriptors.TPSA(m)\n    if mw \u003C= 500 and logp \u003C= 5 and hbd \u003C= 5 and hba \u003C= 10:   # Lipinski, in code\n        kept.append({\"smiles\": smi, \"mw\": round(mw, 1), \"logp\": round(logp, 2),\n                     \"tpsa\": round(tpsa, 1)})\nprint(f\"{len(kept)}\u002F{len(smiles)} pass Lipinski Ro5\")\nprint(json.dumps(sorted(kept, key=lambda r: r[\"mw\"])[:20], indent=2))\n```\n\n(Same shape for a Tanimoto similarity sweep: build one query fingerprint, loop a\nlibrary of SMILES, keep only `sim >= cutoff`.)\n\n### (c) Paper batch-resolve \u002F screen across the paper-search fleet\n\nGoal: turn a list of DOIs into a screened, ranked shortlist. Key-free Crossref\ncovers metadata directly; escalate to the paper-search \u002F scholarly-access MCP\n(stdio, via `MCPSession`) only for the survivors that need an OA-PDF resolve.\n\n```python\nimport json, time, requests\n\ndois = [d.strip() for d in open(\"dois.txt\") if d.strip()]\nkept = []\nfor doi in dois:\n    r = requests.get(f\"https:\u002F\u002Fapi.crossref.org\u002Fworks\u002F{doi}\",\n                     headers={\"User-Agent\": \"research-harness (mailto:you@example.com)\"},\n                     timeout=20)\n    if r.status_code != 200:\n        continue\n    msg = r.json()[\"message\"]\n    year = (msg.get(\"issued\", {}).get(\"date-parts\", [[None]])[0] or [None])[0]\n    cites = msg.get(\"is-referenced-by-count\", 0)\n    if year and year >= 2020 and cites >= 10:           # recency + impact screen\n        kept.append({\"doi\": doi, \"title\": (msg.get(\"title\") or [\"\"])[0],\n                     \"year\": year, \"cites\": cites})\n    time.sleep(0.2)                                      # be polite to the API\nkept.sort(key=lambda x: -x[\"cites\"])\nprint(f\"{len(kept)}\u002F{len(dois)} pass the 2020+\u002F10-cite screen\")\nprint(json.dumps(kept, indent=2))\n```\n\nOnly the shortlist (titles + DOIs + counts) enters context — not the full\nCrossref record for every DOI.\n\n### (d) Multi-source research aggregation (fan out, merge, rank)\n\nGoal: one query, several providers, a single deduped\u002Franked result. Fan out in\ncode, merge on URL, rank by how many independent providers returned each URL\n(in-code corroboration — feeds straight into `deep-research`'s grader).\n\n```python\nimport json, os\n# ... MCPSession from mode 2 above ...\n\nquery = \"post-quantum signature scheme adoption 2026\"\nresults = {}   # url -> {\"title\":..., \"providers\": set()}\n\ndef absorb(provider, items):\n    for it in items or []:\n        url = it.get(\"url\") or it.get(\"link\")\n        if not url:\n            continue\n        row = results.setdefault(url, {\"title\": it.get(\"title\", \"\"), \"providers\": set()})\n        row[\"providers\"].add(provider)\n\nsearx = MCPSession([\"npx\", \"-y\", \"mcp-searxng@1.8.0\"],\n                   env={**os.environ, \"SEARXNG_URL\": \"http:\u002F\u002F127.0.0.1:8890\"})\nabsorb(\"searxng\", (searx.call(\"searxng_web_search\", {\"query\": query}) or {}).get(\"results\"))\nsearx.close()\n# ...absorb(\"exa\", ...), absorb(\"tavily\", ...) the same way...\n\nranked = sorted(results.items(), key=lambda kv: -len(kv[1][\"providers\"]))\nout = [{\"url\": u, \"title\": d[\"title\"], \"corroboration\": len(d[\"providers\"]),\n        \"providers\": sorted(d[\"providers\"])} for u, d in ranked[:15]]\nprint(json.dumps(out, indent=2))   # top-15 by cross-provider corroboration\n```\n\n## Output discipline (so the win is real)\n\n- **Print only the distilled result** — a shortlist, a count, the hits. Never\n  `print()` the raw per-item payloads; that re-imports the bloat you were\n  avoiding. Write raw output to a temp file if you must keep it, and report the\n  path (this is the `context-sandbox` skill's rule).\n- **End with a terminal-state line** the orchestrator can read at a glance, e.g.\n  `KEPT 12\u002F4180 functions` or `SHORTLIST 8 papers -> shortlist.json`.\n- **Make it idempotent & re-runnable** — read inputs from a file\u002Fargv, not from\n  pasted-in context, so a re-run is one Bash call, not a re-derivation.\n- **Handle the empty\u002FNone case** — a flaky provider or unparsable item should\n  `continue`, not crash the whole sweep. The point is to finish the fan-out.\n- **Long sweeps (> ~60s)** go through `longrun` in the background (AGENTS.md §4a),\n  not a blocking foreground call.\n\n## When NOT to use this\n\n- A single tool call — just call it (optionally `ToolSearch` its schema first).\n- Steps that each need the model to reason on the previous result — the loop\n  isn't mechanical, so code can't stand in for the model.\n- Writes\u002Fmutations you can't safely batch (e.g. one-shot game patches) — keep a\n  human\u002Fagent in the loop per step.\n\n## References\n\n- Anthropic Engineering — **\"Code execution with MCP: building more efficient\n  agents\"** (2025): the canonical write-up of this pattern and the ~98.7%\n  token-reduction example (≈150k → ≈2k tokens on a fan-out task).\n- Anthropic Engineering — **\"Writing effective tools for agents\"** and the\n  **Claude Agent SDK** docs (tool\u002Fobservation design; why mechanical loops\n  belong in code, not the model turn).\n- **Model Context Protocol** spec — *Transports* (stdio = newline-delimited\n  JSON-RPC; Streamable HTTP) for the `MCPSession` \u002F HTTP access modes.\n- Sibling skills: `context-sandbox` (sandbox raw payloads, surface only the\n  answer), `deep-research` (the routing\u002Fgrading harness this feeds), and\n  `ToolSearch` deferred-tool loading (the single-call complement).\n",{"name":5,"license":15,"description":7},"main","a298c929b6cbd662e1fce54302ce520d5ceea1a5","skills\u002Fmcp-code-orchestrate","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain","https:\u002F\u002Fgithub.com\u002FPrekzursil","2026-11-02 14:30:57",{"source":8,"skillName":5,"commands":64,"prompt":74,"zipAvailable":75},[65,68,71],{"tool":66,"command":67},"npx","npx skills add Prekzursil\u002Fagent-skills-toolchain --skill mcp-code-orchestrate",{"tool":69,"command":70},"bunx","bunx skills add Prekzursil\u002Fagent-skills-toolchain --skill mcp-code-orchestrate",{"tool":72,"command":73},"pnpm","pnpm dlx skills add Prekzursil\u002Fagent-skills-toolchain --skill mcp-code-orchestrate","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-code-orchestrate\u002FSKILL.md",true,[],[78,98,123,150,164,180],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":52},"01M6DF7D7478R55P46REYH4QAC","clarify-requirements","Resolve genuine pre-execution ambiguity by scanning repo context, generating 1-6 grounded options, and asking 1-3 focused questions via AskUserQuestion. NOT for mid-task use (injection risk); NOT when the goal is already unambiguous; use to disambiguate vague prompts before any file edits.","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Fworkspace-hooks\u002Fskills\u002Fclarify-requirements\u002FSKILL.md",[],[85,86,87,88,89,40,90,91,92,45,93,94,95,96,97],"clarify requirements","clarify","requirements","risk","options","prompts","goal","scanning","context","repo","injection","execution","file",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":105,"publishedAt":52},"01M6DF79CA4BHJS66J8EZDBPWJ","openmm-md","Run FREE, open-source, Windows-native GPU molecular dynamics via the openmm-md MCP (OpenMM + CUDA on the local NVIDIA GPU). Use for protein \u002F protein-ligand MD when you want a free stack or are on Windows without a Schrodinger license. Covers the full workflow (prepare, solvate, minimize, equilibrate, production, analyze, mmgbsa) AND an honest decision guide vs Schrodinger Desmond, including how to run Desmond legitimately on Linux or a cloud GPU with a real license. This is a deliberately LESSER free alternative and does NOT replace the schrodinger MCP tools. Do NOT use it to pick a free tool when a validated FEP+, WaterMap, IFD-MD, or Prime MM-GBSA result is actually required.","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Fmcp\u002Fopenmm-md-mcp\u002Fskill\u002Fopenmm-md\u002FSKILL.md",[104],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[106,107,108,109,110,111,48,112,113,114,115,116,117,118,45,119,120,121,122,35],"openmm md","how","decision","pick","linux","analyze","stack","open","NVIDIA","gpu","license","workflow","windows","free","molecular dynamics","local","do",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":135,"publishedAt":52},"01M6DF76C1MG85VEWP8VZCBNMN","visual-review","Take screenshots of web pages and UI using Playwright for visual review and iteration","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fvisual-review\u002FSKILL.md",[129,132],{"categoryNo":130,"categoryName":131,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":133,"categoryName":134,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",[136,137,138,139,140,141,142,143,144,145,107,146,147,148,149],"review","visual","visual review","pages","web","false","iteration","take","check","slides","ui","screenshot","playwright","screenshots",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":52},"01M6DF73AQVCBZKEN0YXEX9FXP","status","Diagnostic status report — shows metaswarm installation state, project setup, and potential issues","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fstatus\u002FSKILL.md",[],[152,157,158,159,160,161,162,163],"setup","report","project","installation","project setup","issues","state",{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":171,"publishedAt":52},"01M6DF6X6C2XB0P6GX76P7TTYV","start","Use when starting work on any task, when the user mentions metaswarm, or when the user wants to begin tracked development work","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fstart\u002FSKILL.md",[170],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[166,172,40,173,174,175,45,176,177,178,179],"start issue","issue","ready","work on issue","user","work","work on","development",{"skillNo":181,"name":157,"nameZh":6,"description":182,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":183,"categories":184,"keywords":185,"publishedAt":52},"01M6DF6QMJ9AJKFKHHKRT005PQ","Interactive project setup — detects your project, configures metaswarm, writes project-local files","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fsetup\u002FSKILL.md",[],[157,159,121,186,161,187],"files","interactive"]