Package net.targetr.rc.mcp


package net.targetr.rc.mcp
Model Context Protocol (MCP) access to connected RCWeb browsers.

McpHandler implements the stateless MCP 2025-11-25 Streamable HTTP endpoint at /api/mcp, routed by RootResponder. JSON-RPC requests use JSON POST bodies; supported methods are initialize, ping, tools/list and tools/call. The endpoint does not provide an SSE stream.

The list_clients tool lists connected browsers in a supplied room. The execute_javascript tool sends ES5 JavaScript to one exact client ID in that room. Room codes provide access to these operations; there is no account or bearer-token requirement and no tool for enumerating rooms.

Execution writes once to the selected live WebSocket, without offline queuing or retries. Injected reply(value) and fail(message) functions POST results to /api/mcp-result with a random, one-use token. The original request waits for that result outside room locks. Reply deadlines default to 10 seconds and allow at most 30 seconds, including send time; blocked socket writes can exceed the deadline. At most 64 executions may be outstanding per handler. JSON request and callback bodies are limited to 256 KiB. A timeout releases the pending result but does not cancel browser execution, so its outcome may remain unknown.

Author:
Dr Michael Gardiner
  • Classes
    Class
    Description
    Minimal, stateless MCP 2025-11-25 Streamable HTTP endpoint at /api/mcp.