> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an MCP client

Use a client that supports MCP 2026-07-28 and Streamable HTTP. Give it the
endpoint URL and sign in for that exact resource with a credential the
server accepts. [Authenticate MCP requests](https://docs.bijection.com/mcp/authentication.md)

## Discover and call the server

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection mcp login https://notes.example.com/mcp
bijection mcp request https://notes.example.com/mcp server/discover
bijection mcp request https://notes.example.com/mcp tools/list
```

## 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.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, mutation, secret, t } from "@bijectionhq/bijection";
import { mcpServer, send, toolCall, toolResultOf } from "@bijectionhq/library-mcp";

export const docsToken = secret();
export const docs = mcpServer({ url: "https://mcp.example.com/mcp", bearer: docsToken });

export const answered = mutation(
  { args: { id: t.string, result: t.result(docs.rpc) } },
  async (ctx, { id, result }) => {
    const reply = toolResultOf(result, id);
    if (reply.resultType === "input_required") return null; // ask the user, then resume
    // reply.content and reply.structuredContent hold the tool's answer
    return null;
  },
);

export const ask = mutation({ args: { q: t.string } }, async (ctx, { q }) => {
  const request = toolCall("search", { q });
  await ctx.submit(docs.rpc, send(docs, request), {
    once: ["docs", q],
    within: { minutes: 1 },
    then: answered.with({ id: request.id }),
  });
  return null;
});

export default app({ remote: { docsToken, docs, answered, ask } });
```

`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, use
`connectMcp({ 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.