Skip to main content

MCP

Source file: examples/mcp_protocol.hen

What It Demonstrates

  • protocol = mcp
  • session-backed MCP calls
  • initialize, tools/list, and tools/call
  • decoding JSON returned inside MCP content text

Key Pattern

protocol = mcp
session = app
POST {{ MCP_ORIGIN }}
call = initialize

---

protocol = mcp
session = app
call = tools/call
tool = generateNumbers
arguments = {"seed":"0", "min": 0, "max": 100, "type": "int"}

^ & json(body.result.content[0].text).[0] == 49

Run It

hen verify ./examples/mcp_protocol.hen
hen run ./examples/mcp_protocol.hen all --non-interactive

What To Notice

  • The first step creates the MCP session; later calls reuse it by name.
  • MCP responses still use ordinary body... selectors.
  • json(...) is useful when a tool returns structured data as a JSON string inside content[0].text.

Related reference: Protocols