Skip to content

dse120071750/m8m-harness-builder / skills/m8m/m8m-mcp-connection-builder

m8m-mcp-connection-builder

Verified

Author reusable MCP connection context and usage guides locally, then deliver an authorized installation to the configured M8M tenant's persistent server installer. Use for new connections or explicit version changes.

scripts/m8m_local_bundle.py

View on GitHub
"""Export reusable builder definitions or collect semantic installation context."""
import argparse
from io import BytesIO
import json
from pathlib import Path
import sys
import zipfile

sys.path.insert(0, str(Path(__file__).resolve().parent))
from m8m_delivery_common import collect, encoded, immutable, relative, sha256

FORBIDDEN = {"room_id", "thread_id", "wait_id", "task_state", "task_output", "ledger", "progress", "source_message_id"}

def reusable(value):
    if isinstance(value, dict):
        if FORBIDDEN & set(value):
            raise ValueError("Reusable definitions must not contain live Task/session state.")
        for child in value.values():
            reusable(child)
    elif isinstance(value, list):
        for child in value:
            reusable(child)

def main(argv=None):
    if hasattr(sys.stdout, "reconfigure"):
        sys.stdout.reconfigure(encoding="utf-8")
    parser = argparse.ArgumentParser(description=__doc__)
    commands = parser.add_subparsers(dest="command", required=True)
    task = commands.add_parser("task")
    for key in ("key", "title"):
        task.add_argument("--" + key, required=True)
    for key in ("goal", "master-prompt", "output-schema", "output"):
        task.add_argument("--" + key, type=Path, required=True)
    for key in ("workflow-references", "resource-requirements", "runtime-configuration"):
        task.add_argument("--" + key, type=Path)
    schedule = commands.add_parser("schedule")
    schedule.add_argument("--key", required=True)
    schedule.add_argument("--definition", type=Path, required=True)
    schedule.add_argument("--output", type=Path, required=True)
    bundle = commands.add_parser("bundle")
    bundle.add_argument("--source", type=Path, action="append", required=True)
    bundle.add_argument("--output", type=Path, required=True)
    args = parser.parse_args(argv)
    if args.command == "task":
        schema = json.loads(args.output_schema.read_bytes())
        if not isinstance(schema, (dict, bool)):
            raise ValueError("The output schema must be a JSON Schema object or boolean.")
        # The server validates the complete schema during semantic preparation;
        # exporting context requires only the standard Python library.
        value = {"schema": "m8m.task_template.v1", "template_key": args.key, "title": args.title,
            "definition": {"goal": args.goal.read_bytes().decode("utf-8"),
                "master_prompt": args.master_prompt.read_bytes().decode("utf-8"), "output_schema": schema,
                "workflows": json.loads(args.workflow_references.read_bytes()) if args.workflow_references else {}},
            "resource_requirements": json.loads(args.resource_requirements.read_bytes()) if args.resource_requirements else []}
        if args.runtime_configuration:
            value["runtime_configuration"]=json.loads(args.runtime_configuration.read_bytes())
        reusable(value)
        payload = encoded(value)
    elif args.command == "schedule":
        value = {"schema": "m8m.schedule_template.v1", "template_key": args.key, "definition": json.loads(args.definition.read_bytes())}
        reusable(value)
        if value["definition"].get("target", {}).get("kind") == "resume_session":
            raise ValueError("Create a reminder from its real server Task wait; export only reusable follow-up policy.")
        payload = encoded(value)
    else:
        members = {}
        for root in args.source:
            for path, data in collect(root).items():
                name = relative(root.name + "/" + path if root.is_dir() else path)
                if name in members:
                    raise ValueError("Bundle sources have conflicting relative names.")
                members[name] = data
        from m8m_delivery_common import MAX_BYTES, MAX_FILES
        if len(members) > MAX_FILES or sum(map(len, members.values())) > MAX_BYTES:
            raise ValueError("Combined bundle exceeds the server transport bound.")
        memory = BytesIO()
        with zipfile.ZipFile(memory, "w", compression=zipfile.ZIP_DEFLATED) as archive:
            for name, data in sorted(members.items()):
                info = zipfile.ZipInfo(name, date_time=(1980, 1, 1, 0, 0, 0))
                info.compress_type = zipfile.ZIP_DEFLATED
                archive.writestr(info, data)
        payload = memory.getvalue()
    immutable(args.output.absolute(), payload)
    print(encoded({"path": str(args.output.absolute()), "digest": sha256(payload), "bytes": len(payload)}).decode())
    return 0

if __name__ == "__main__":
    raise SystemExit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall