{
  "name": "trenchit",
  "title": "TRENCHIT — the TRENCH-8 factory",
  "version": "1.0.0",
  "description": "Design a TRENCH-8 processor, mint it, pay its clock and read its flip-flops back. Every tool is synchronous, takes one object and returns one. Nothing throws.",
  "site": "https://trenchit.app",
  "shape": "mcp-tools",
  "conventions": {
    "errors": "Nothing throws. A call that cannot be answered returns {\"ok\":false,\"error\":\"…\"}.",
    "arguments": "Every tool takes one object. The JavaScript surface also accepts positional arguments: power(1, 42) is power({id:1, byte:42}).",
    "determinism": "Two agents that run the same calls against the same chip get the same answer, byte for byte.",
    "state": "The factory is local to one browser. Chip records live in localStorage under \"trenchit.chips\", each chip's RAM under \"trenchit.state\"."
  },
  "transport": {
    "now": {
      "kind": "in-page",
      "global": "window.trenchit",
      "note": "Load the site's scripts and call the functions directly. There is no server and no network hop."
    },
    "planned": {
      "kind": "json-rpc",
      "status": "pending",
      "endpoint": "",
      "note": "Nothing is deployed. When the factory ships, these same tools exist over RPC and this endpoint is filled in."
    }
  },
  "deployment": {
    "status": "built · not deployed",
    "pending": true,
    "network": "",
    "chainId": 0,
    "rpc": "",
    "explorer": "",
    "factory": "",
    "gateArray": "",
    "token": "",
    "market": "",
    "note": "Every empty string above is pending. No address has been invented to fill one."
  },
  "tools": [
    {
      "name": "spec",
      "title": "Read the machine",
      "description": "The instruction set, the netlist counts, the shipped programs and the terms a mint accepts, in one object.",
      "call": "trenchit.spec()",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "returns": "{ok, version, isa, netlist:{gates,flops,nets,ram,rom}, programs, mint, clock, deployment}",
      "example": "trenchit.spec()",
      "onChain": "eth_call — the gate array answers for itself"
    },
    {
      "name": "programs",
      "title": "List the ROM images",
      "description": "Every program the factory ships: its key, its assembly source and the words it assembles to.",
      "call": "trenchit.programs()",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "returns": "[{key,label,blurb,source,words,count,loops,halts}]",
      "example": "trenchit.programs()",
      "onChain": "static — the images ship with the factory"
    },
    {
      "name": "assemble",
      "title": "Assemble TRENCH-8",
      "description": "Assemble TRENCH-8 assembly. Errors come back with a line number instead of a stack trace.",
      "call": "trenchit.assemble(source)",
      "inputSchema": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "maxLength": 65536,
            "description": "TRENCH-8 assembly. One instruction per line; ';' starts a comment."
          }
        },
        "required": [
          "source"
        ],
        "additionalProperties": false
      },
      "returns": "{ok, words:[…], listing:[…], errors:[{line,col,msg}]}",
      "example": "trenchit.assemble(\"ldi r0, #0x2a\\nout r0\\njmp 0x000\")",
      "onChain": "off chain — a ROM image is calldata, not a call"
    },
    {
      "name": "mint",
      "title": "Mint a chip",
      "description": "A name, a ticker, a program and the emission terms. The agent gets back the chip record and the card it will render as.",
      "call": "trenchit.mint({name, ticker, …})",
      "inputSchema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "description": "What the chip is called."
          },
          "ticker": {
            "type": "string",
            "pattern": "^[A-Za-z0-9]{2,10}$",
            "description": "Unique across the local factory. Uppercased."
          },
          "program": {
            "type": "string",
            "enum": [
              "echo",
              "trench",
              "sweep",
              "counter"
            ],
            "description": "A key from trenchit.programs(). Defaults to the first shipped image."
          },
          "pair": {
            "type": "string",
            "enum": [
              "ETH",
              "WETH",
              "USDC"
            ],
            "description": "What the token trades against."
          },
          "liquidityBps": {
            "type": "integer",
            "minimum": 100,
            "maximum": 9000,
            "description": "Share of supply into liquidity, in basis points."
          },
          "emissionSpan": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650,
            "description": "Days the mining reserve takes to leave, at a full clock."
          },
          "logo": {
            "type": "string",
            "maxLength": 1000000,
            "pattern": "^data:image/(png|jpeg|jpg|gif|webp);base64,",
            "description": "Optional raster data URL. Never uploaded anywhere."
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "maxProperties": 6,
            "description": "Optional http(s) links, keyed by a short name."
          }
        },
        "required": [
          "name",
          "ticker"
        ],
        "additionalProperties": false
      },
      "returns": "{ok, chip:{id,name,ticker,program,pair,liquidityBps,emissionSpan,logo,links,born,cycle,sponsorBytes,out,halted}}",
      "example": "trenchit.mint({name:\"Ditch\", ticker:\"DITCH\", program:\"trench\"})",
      "onChain": "a transaction — the factory mints the NFT and launches the token"
    },
    {
      "name": "chips",
      "title": "List the factory",
      "description": "Every chip in the local factory, in mint order.",
      "call": "trenchit.chips()",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "returns": "[chip…]",
      "example": "trenchit.chips()",
      "onChain": "eth_call — or the mint log, which is cheaper"
    },
    {
      "name": "chip",
      "title": "Read one record",
      "description": "One chip record by id, terms and all.",
      "call": "trenchit.chip(id)",
      "inputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1,
            "description": "The chip id returned by mint."
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      },
      "returns": "chip | {ok:false, error}",
      "example": "trenchit.chip(1)",
      "onChain": "eth_call — one storage read"
    },
    {
      "name": "power",
      "title": "Pay for one cycle",
      "description": "One call, one cycle, one byte. The answer is the machine's state after the tick, not a transaction hash and a shrug.",
      "call": "trenchit.power(id, byte)",
      "inputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1,
            "description": "The chip to advance."
          },
          "byte": {
            "type": "integer",
            "minimum": 0,
            "maximum": 255,
            "default": 0,
            "description": "The byte the tick carries. The program reads it with 'in'."
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      },
      "returns": "{ok, id, cycle, pc, out, flags:{c,z}, halted, stall, sponsor, byte}",
      "example": "trenchit.power(1, 42)",
      "onChain": "a transaction — one tick, one block, one cycle"
    },
    {
      "name": "read",
      "title": "Read the flops",
      "description": "Registers, program counter, stack pointer, flags, output port, the used half of RAM. Deterministic, so two agents reading the same chip agree.",
      "call": "trenchit.read(id)",
      "inputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1,
            "description": "The chip to read."
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      },
      "returns": "{ok, id, cycle, pc, sp, out, regs:[16], flags:{c,z}, ram:{size,used,cells}, halted, stall}",
      "example": "trenchit.read(1)",
      "onChain": "eth_call — free, and anyone can re-execute it"
    },
    {
      "name": "svg",
      "title": "Draw the card",
      "description": "The chip card as a standalone SVG string, drawn from the machine's own storage bits. Pass a draft object to preview an unminted chip.",
      "call": "trenchit.svg(id)",
      "inputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1,
            "description": "A minted chip. Leave it out and the rest of the object is treated as a draft."
          },
          "name": {
            "type": "string",
            "maxLength": 32
          },
          "ticker": {
            "type": "string",
            "pattern": "^[A-Za-z0-9]{2,10}$"
          },
          "program": {
            "type": "string"
          },
          "pair": {
            "type": "string",
            "enum": [
              "ETH",
              "WETH",
              "USDC"
            ]
          },
          "liquidityBps": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000
          },
          "emissionSpan": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650
          },
          "logo": {
            "type": "string",
            "maxLength": 1000000
          }
        },
        "additionalProperties": false
      },
      "returns": "\"<svg …>…</svg>\"",
      "example": "trenchit.svg({name:\"Ditch\", ticker:\"DITCH\"})",
      "onChain": "tokenURI — the card is built on chain from the same bits"
    }
  ]
}