Raw History Blame Contribute Delete
2.47 kB
"""Write every task's mcp.json for where this folder sits now and where the verifier is.
python3 bind.py --engine /absolute/path/to/mcp_stdio [--python /path/to/python3]
Each task folder's mcp.json names one MCP server, "verifier": the logging proxy (scorer/mcp_log_proxy.py) in front of
the engine, recording every tool call to logs/<id>.harness.jsonl, outside the task folder the agent works in. MCP
clients start a server from an absolute path, so run this once after unpacking, and again if the folder moves.
The file follows the common "mcpServers" layout that MCP clients read.
A task folder is a folder holding prompt.md and grade.sh; the task rows stay in scorer/data/environments.jsonl.
"""
import argparse
import json
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
def task_folders(root):
return [n for n in sorted(os.listdir(root))
if os.path.isfile(os.path.join(root, n, "prompt.md")) and os.path.isfile(os.path.join(root, n, "grade.sh"))]
def bind(root, engine, python=None, as_root=None):
"""Write mcp.json in every task folder under root. as_root: write the paths as if root sat there (for packing)."""
root = os.path.abspath(root)
named = as_root or root
python = python or (sys.executable if os.path.isabs(sys.executable) and not as_root else "python3")
proxy = os.path.join(named, "scorer", "mcp_log_proxy.py")
logs = os.path.join(named, "logs")
os.makedirs(os.path.join(root, "logs"), exist_ok=True)
n = 0
for name in task_folders(root):
config = {"mcpServers": {"verifier": {
"type": "stdio", "command": python,
"args": [proxy, "--log", os.path.join(logs, name + ".harness.jsonl"), "--forbid-under", os.path.join(named, name),
"--", engine if as_root else os.path.abspath(engine)]}}}
with open(os.path.join(root, name, "mcp.json"), "w", encoding="utf-8") as f:
json.dump(config, f, indent=2)
f.write("\n")
n += 1
return n
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--engine", required=True)
ap.add_argument("--root", default=os.path.dirname(HERE))
ap.add_argument("--python", help="the Python that runs the proxy (default: the one running this)")
a = ap.parse_args()
print("wrote mcp.json in %d task folders under %s" % (bind(a.root, a.engine, a.python), os.path.abspath(a.root)))
if __name__ == "__main__":
main()