Discover and call the server
Call a remote MCP server from an app
mcpServer({ url, bearer?, capabilities?, clearance?, replies?, timeout? })
declares a remote server as a receiver whose one target, rpc, sends it a
request. Place it in the tree. Its performer holds the credential and owns
egress, so app code never sees the bearer.
send(server, request) makes the task’s args from discover(),
toolsList() or toolCall(tool, args). The submit commits atomically with
the mutation’s writes, and the continuation named by then receives the
task’s Result. Keep the request’s id for the continuation:
toolResultOf(result, id) checks that the answer belongs to it and returns
either a completed tool result or input_required. listedTools(result, id) reads a tools/list answer. Pass a listed tool to toolCall so the
request carries the routing headers its input schema declares.
When the server asks for input, collect the user’s answers and submit
resume(request, result, inputResponses) with a new once. The retry has a
fresh JSON-RPC ID, carries that round’s answers and echoes the server’s
opaque state.
A send is performed once. A lost reply settles the task Unknown, and a
task past within settles Expired. label bounds what the server
receives. Results sit at the join of the sender’s commit label and the
receiving label. timeout bounds
one send, 30 seconds by default and at most 15 minutes.
For typed calls into another Bijection app, use its client
(bijection client ts) rather than MCP.
Connect directly over HTTP
From a Node host or a browser that can reach the endpoint, useconnectMcp({ url, token }) from @bijectionhq/library-mcp. The token
callback supplies the current access token for the endpoint. Its
discover() and listTools(cursor?) methods discover the server, and
callTool(tool, args) calls a tool that listTools returned. Supply an
offline JSON Schema 2020-12 validator as validateSchema to check remote tool arguments and structured results. The
lower-level request(mcpRequest(method, parameters)) sends other MCP
requests.
The optional input callback receives each input-required result and the
server URL. Use it to present form questions, get consent before opening
URL-mode interactions, and decide when to retry a state-only result.
subscribe(filter, signal) yields the acknowledgment and the notifications
that follow. Abort the signal to close the stream.