Skip to content
Radient LogoRadient Documentation

Harness SDK

The Radient Harness SDK provides a TypeScript MCP client, a server-side Backend for Frontend (BFF) helper, style-isolated React UI panels and hooks, and a local push notification relay for Radient Hosted MCP.

#Packages and installation

All packages ship under the @radient-ml/* scope (Node.js >=20; React >=18 peer dependency for @radient-ml/sdk-react):

PackageRole
@radient-ml/sdkOAuth 2.1 + Streamable HTTP client (RadientClient, OAuth21Client, FileTokenStore), SSE PushRouter, built-in harness adapters, server BFF (@radient-ml/sdk/server), and browser-safe types (@radient-ml/sdk/browser).
@radient-ml/sdk-reactTemplate UI panels (RadientProvider, TeamBridgePanel, AlertsFeed, VaultPicker, McpSettingsPanel), headless hooks, and @layer radient-sdk stylesheet (@radient-ml/sdk-react/styles.css).
@radient-ml/mcp-relayLocal CLI daemon (radient-mcp-relay) that maintains a GET /mcp SSE stream and routes logical route_id pushes through a local 0600 config file.

Install the SDK and React packages in your application:

bash
pnpm add @radient-ml/sdk @radient-ml/sdk-react

Install the local push relay CLI (globally or as a project dependency):

bash
pnpm add @radient-ml/mcp-relay

#Architecture invariants

  • Strictly MCP-native: RadientClient talks exclusively to https://api.radienthq.com/mcp (POST, GET, DELETE) and the OAuth 2.1 endpoints (/.well-known/oauth-protected-resource/mcp, /.well-known/oauth-authorization-server, /v1/auth/oauth/register, /v1/auth/oauth/token, /v1/auth/oauth/revoke). It makes zero /v1/ data calls with radient_mcp tokens.
  • Server-side BFF for browsers: Because https://api.radienthq.com/mcp rejects browser Origin and Cookie headers, browser apps mount createRadientBffHandler from @radient-ml/sdk/server on their own backend. OAuth tokens remain server-side, browser headers are never forwarded to /mcp, and @radient-ml/sdk-react talks only to your same-origin BFF routes (default /api/radient).
  • Local-only route_id mapping: Radient servers store only opaque logical route_id keys (^[a-z0-9_-]{1,32}$). Local binaries, session IDs, and loopback addresses stay strictly in local 0600 config or your local server process, and PushRouter refuses unmapped route_id events.

#Server client and OAuth 2.1

Use OAuth21Client and FileTokenStore to run OAuth 2.1 Authorization Code + PKCE (S256) with RFC 8707 resource binding, atomic 0600 token persistence, single-flight refresh with backoff on transient 503 responses, and RFC 7009 self-revocation:

ts
import {
  FileTokenStore,
  OAuth21Client,
  RadientClient,
} from "@radient-ml/sdk";

const tokenStore = new FileTokenStore("~/.radient/tokens.json");

const oauth = new OAuth21Client({
  clientId: "https://my-harness.example/oauth.json",
  scopes: ["mcp:read", "bridge:read", "bridge:write"],
  tokenStore,
});

// Interactive login (first run, or when tokenStore has no valid grant):
// const plan = await oauth.createAuthorizationRequest({
//   redirectUri: "http://127.0.0.1:43111/callback",
// });
// Redirect user to plan.authorizationUrl, then exchange the callback code:
// await oauth.exchangeAuthorizationCode({
//   code,
//   codeVerifier: plan.pkce.codeVerifier,
//   redirectUri: plan.redirectUri,
// });

const radient = new RadientClient({
  auth: { type: "oauth2", oauthClient: oauth },
});

const info = await radient.discover();
const tenantId = info.defaultTenantId ?? info.organizations[0]?.id;

const { channels } = await radient.bridge.listChannels({ tenantId });
if (channels[0]) {
  await radient.bridge.sendMessage(channels[0].id, {
    tenantId,
    body: "Deploy verified.",
    clientRef: crypto.randomUUID(),
  });
}

await radient.close();

RadientClient wraps all 25 Radient Hosted MCP tools (discover(), settings, bridge, integrations, vault, hub, pass, tunnels), MCP resources (resources), and prompts (prompts). Call radient.disconnect() to tear down the session and revoke the OAuth grant via RFC 7009; call oauth.getRetentionStatus() to inspect the 30-day sliding / 180-day absolute retention window.

#Server BFF and React template UI

#Mount the server BFF

Mount createRadientBffHandler from @radient-ml/sdk/server behind your app's own session authentication. Always specify exact allowedOrigins (wildcards like "*" are rejected) so cross-site POSTs are blocked:

ts
import { createServer } from "node:http";
import { FileTokenStore, RadientClient } from "@radient-ml/sdk";
import {
  createNodeBffListener,
  createRadientBffHandler,
} from "@radient-ml/sdk/server";

const radient = new RadientClient({
  auth: {
    type: "oauth2",
    clientId: process.env.RADIENT_OAUTH_CLIENT_ID ?? "radient-mcp-relay",
    tokenStore: new FileTokenStore("~/.radient/tokens.json"),
  },
});

const bffHandler = createRadientBffHandler({
  // Resolve the signed-in user's server-side RadientClient per request.
  getClient: () => radient,
  allowedOrigins: ["http://127.0.0.1:5173"],
  onRequestScope: async (scope) => {
    if (!radient.oauth) return undefined;
    const plan = await radient.oauth.createAuthorizationRequest({
      redirectUri: "http://127.0.0.1:4100/oauth/callback",
      scopes: ["mcp:read", scope],
    });
    // Store plan.state and plan.pkce.codeVerifier in your server session before returning.
    return { authorizeUrl: plan.authorizationUrl };
  },
});

const listener = createNodeBffListener(bffHandler);

createServer((req, res) => {
  if (req.url?.startsWith("/api/radient")) {
    void listener(req, res);
    return;
  }
  res.writeHead(404).end();
}).listen(4100, "127.0.0.1");

createRadientBffHandler returns a standard Fetch (request: Request) => Promise<Response> handler, so you can mount it directly in Next.js App Router, Hono, or any Fetch-compatible server runtime without createNodeBffListener.

#Render template UI panels or headless hooks

Import @radient-ml/sdk-react/styles.css once at your app entry point. Its rules live inside @layer radient-sdk with zero Tailwind Preflight reset, so it will not override your existing styles. Wrap panels in <RadientProvider /> pointing at your same-origin BFF prefix:

tsx
import {
  AlertsFeed,
  McpSettingsPanel,
  RadientProvider,
  TeamBridgePanel,
  VaultPicker,
} from "@radient-ml/sdk-react";
import { isSafeRadientConsoleUrl } from "@radient-ml/sdk/browser";
import "@radient-ml/sdk-react/styles.css";

export function WorkspacePanels() {
  return (
    <RadientProvider
      bffUrl="/api/radient"
      theme="dark"
      onRequestScope={(scope, ctx) => {
        if (
          ctx?.authorizeUrl &&
          isSafeRadientConsoleUrl(ctx.authorizeUrl, "/oauth/authorize")
        ) {
          window.open(ctx.authorizeUrl, "_blank", "noopener,noreferrer");
        }
      }}
    >
      <TeamBridgePanel />
      <AlertsFeed />
      <VaultPicker hideWhenUnavailable={false} />
      <McpSettingsPanel />
    </RadientProvider>
  );
}

Every component respects live permissions and MCP policies: TeamBridgePanel renders via_mcp attribution, VaultPicker displays metadata only and validates Console handoff URLs, and McpSettingsPanel exposes connection state, instant self-disconnect, constrained channel subscriptions, and a link to Console MCP settings.

If you prefer to build custom UI, use the headless hooks exported from @radient-ml/sdk-react inside <RadientProvider />:

  • useRadient: context, active tenantId, discover, SSE state, and push event subscriptions
  • useBridgeChannels, useBridgeMessages, useBridgeSearch: Team Bridge channels, threads, sending, and search
  • useAlerts: Team Integrations alerts and claim/release actions
  • useVaultCatalog: conditional Vault metadata and verified Console handoff links
  • useMcpConnection, useMcpSettings: connection status, self-disconnect, and channel subscription updates

#Push relay and routing

Configure logical route_id rules under MCP → Push routing & session targets in the Radient console (see MCP notifications), then map those route_id keys locally with PushRouter or radient-mcp-relay.

#Programmatic routing with PushRouter

PushRouter maintains the GET https://api.radienthq.com/mcp SSE stream, checks : keepalive heartbeats, persists Last-Event-ID checkpoints, deduplicates events, surfaces notifications/radient/resync_required, and refuses any unmapped route_id:

ts
import {
  AntigravityAdapter,
  FileTokenStore,
  PushRouter,
  RadientClient,
} from "@radient-ml/sdk";

const radient = new RadientClient({
  auth: {
    type: "oauth2",
    clientId: "radient-mcp-relay",
    scopes: ["mcp:read", "bridge:read", "bridge:write", "integrations:read"],
    tokenStore: new FileTokenStore("~/.radient/tokens.json"),
  },
});

const router = new PushRouter(radient, {
  checkpointPath: "~/.radient/push-cursor.json",
  onUnmappedRoute: ({ routeId, event }) => {
    console.warn(`Refused unmapped route_id "${routeId}" (${event.eventId})`);
  },
  onResyncRequired: () => {
    console.warn("Replay window exceeded; refresh state with read tools.");
  },
});

router.registerRoute(
  "chief_of_staff",
  new AntigravityAdapter({
    lsAddress: process.env.ANTIGRAVITY_LS_ADDRESS!,
    csrfToken: process.env.ANTIGRAVITY_CSRF_TOKEN!,
    coalesceMs: 5000,
    onError: (err) => console.error("[chief_of_staff]", err),
  }),
);

await router.start();

#Built-in push adapters

AdapterPurpose and security boundary
AntigravityAdapterAccepts lsAddress (such as ANTIGRAVITY_LS_ADDRESS) and csrfToken (ANTIGRAVITY_CSRF_TOKEN), rewrites exact localhost:<port> to literal 127.0.0.1 with zero DNS lookup, enforces literal loopback (127.0.0.1 or [::1]), and coalesces bursts per (conversationId, routeId) (coalesceMs, default 5000 ms).
LocalOperatorAdapterPOSTs { sessionId, routeId, routeLabel, event } to a pinned Local Operator endpointUrl and sessionId (literal loopback by default; optional allowRemoteHttps: true for HTTPS).
CommandAdapterInvokes a local binary via execFile with shell: false (no shell interpolation), a mandatory allowedBinaries allowlist, an isolated minimal child environment (envAllowlist opt-in), and bounded JSON on stdin.
LocalWebhookAdapterPOSTs HMAC-SHA256-signed payloads (X-Radient-Timestamp, X-Radient-Delivery-Id, X-Radient-Signature-256) strictly to literal loopback (127.0.0.1 or [::1]) with redirect: "error".
CallbackAdapterRuns an in-process async (event, context) => Promise<void> | void handler for custom Node.js harnesses.

#Local relay CLI

If you want a ready-to-run local daemon without writing Node.js glue code, use radient-mcp-relay from @radient-ml/mcp-relay:

bash
radient-mcp-relay init      # creates 0600 ~/.radient/relay.json template
radient-mcp-relay login     # OAuth 2.1 PKCE loopback sign-in (0600 tokens)
radient-mcp-relay start     # runs SSE PushRouter from local route_id config
radient-mcp-relay status    # checks config mode, routes, retention & cursor
radient-mcp-relay logout    # RFC 7009 revoke + deletes local token file

Edit ~/.radient/relay.json (which must remain mode 0600) to map each Console route_id to an antigravity, local-operator, command, or local-webhook target, then run radient-mcp-relay start. Pass --live to radient-mcp-relay status to verify live discovery with radient_discover.