Skip to content

Gateway as MCP server: agents and sessions as tools over Streamable HTTP #73

Closed

Description

@melvincarvalho

Audited both reference implementations (2026-06-11):

  • openclaw serves MCP via openclaw mcp serve — official SDK, stdio only, conversation-bridge tools: conversations_list, conversation_get, messages_read, messages_send, events_poll/wait, attachments_fetch, permissions_list_open/respond.
  • JSS serves MCP over stateless Streamable HTTP (POST /mcp, JSON-RPC 2.0, spec 2025-03-26, no session header) with a ~50-line protocol layer — proof the transport is nearly free.

jsclaw already has an inward-facing MCP server (container/mcp-server.js, IPC tools for Claude Code agents). This issue is the outward-facing one: the gateway grows POST /mcp so any MCP client — Claude Code/Desktop, openclaw, IDEs, another jsclaw — drives jsclaw agents as ordinary tools.

Design

  • Transport: JSS's style — stateless Streamable HTTP on the existing gateway HTTP server; initialize / notifications/initialized / tools/list / tools/call / ping; single-shot JSON responses; auth = gateway token as Bearer (header), same credential as the WS surface.
  • Tool vocabulary: mirror openclaw's bridge names where concepts map, so hosts configured for their bridge work against ours:
    • conversations_list → SessionStore.list (sessions ARE conversations since Sessions as first-class: list/reset/patch, many per agent #57)
    • conversation_get → session row + recent transcript (chat.history machinery)
    • messages_send → chat.send into a session key (returns the reply — blocking is fine for v1)
    • messages_read → chat.history
    • jsclaw-natural additions: agents_list, skills_list
  • Results: {content: [{type: "text", text}], isError} — JSS's helpers shape, spec-standard.
  • Mostly delegation: the gateway dispatch already implements every underlying operation; the MCP layer is routing + envelopes (~150 lines + tests).

Why

  • Composability: every jsclaw deployment becomes a tool any AI host can call
  • Sub-agents (Sub-agent spawning: agents that start agents #61) get an implementation path for free: one jsclaw calling another's messages_send is sub-agency
  • Pairs with the client side (agent-micro#9): call out + be called = first-class node in the MCP mesh

Deferred

stdio transport for the gateway server, events_poll/wait, permissions_* (needs #58 approvals), attachments, SSE streaming responses.

Activity

  1. added a commit that references this issue on Jun 11, 2026
  2. melvincarvalho commented on Jun 11, 2026

    @melvincarvalho
    ContributorAuthor

    Shipped in #74 + #75: POST /mcp on the gateway — JSON-RPC 2.0, spec 2025-03-26, stateless single-shot JSON (JSS's transport style), Bearer/query token auth. Tools speak openclaw's bridge vocabulary (conversations_list, messages_send, messages_read) plus agents_list/skills_list, all pure delegation to the existing dispatch — runner-agnostic by construction. The first live call exposed and fixed a real defect: chat.send awaited runner-process exit (up to 30 min) instead of the first terminal output (#75). Verified live: a curl drove the resident agent end-to-end over MCP in 1.5s. Deferred: stdio transport, events_poll/wait, permissions_* (#58), SSE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions