class LittleGhost::Harnesses::ToolServer

Serves Tool instances to a harness over the Model Context Protocol’s Streamable HTTP transport on a Unix socket, so a coding-agent tool can call the same tools as the Agent that delegated to it.

registry = LittleGhost::ToolRegistry.new([HelpCenterLookupTool], binding:)
server = LittleGhost::Harnesses::ToolServer.new(
  tools: registry,
  socket_path: "/run/harness-tools/tools.sock",
  context:
).start
# The harness reaches the socket through a relay at http://127.0.0.1:3133/mcp.
server.close

Each call runs Tool#execute with context, so the Run’s cancellation and deadline stop it, and returns the tool’s content as text with isError set for failed calls. The server answers initialize, ping, tools/list, and tools/call with JSON responses and accepts notifications; it does not open server-to-client streams.

Calls run Tool#execute directly: Agent callbacks such as :before_tool, tool instrumentation, and the exclusive-tool lock, which the delegating Harnesses::Tool already holds, do not apply. Serve only tools whose safeguards live in the tool itself.

Anyone who can connect to the socket can call every served tool, so keep socket_path in a directory that only the harness can reach. start raises ToolError when another server is already listening there. Harnesses::Tool#serve_tools starts one server per delegated task.