Skip to main content
Browse documentation

Integrate an agent or tool

Add Sernixa immediately before the code that performs a meaningful action. The SDK requests a decision, waits safely when review is required, and calls your function only after an approved outcome.

Connect Codex, Claude, or Cursor

Install the CLI and use browser sign-in:

python3 -m pip install --upgrade sernixa-cli
sernixa auth login
sernixa protect

Use a CLI version that supports your host. Record the version you test. After sernixa protect installs the selected integration, review the host's trust or approval prompt and start a new agent task. Inspect the configuration before testing:

sernixa protect --status
sernixa doctor --strict

For Codex and Claude Code, confirm that the required prompt and pre-tool hooks are active. Host permissions still apply. Before relying on a particular host or tool class, observe an allowed and blocked action against a disposable fixture. Status and readiness checks report configuration and prerequisites. Use the host and the fixture to establish whether an action ran.

Run sernixa to open the persistent console. Type @ for the selectable plan-aware palette; direct commands are also available and remain enforced by the backend.

Install and configure

The TypeScript SDK supports Node.js 18 or later.

npm install @sernixa/sdk@latest
export SERNIXA_BASE_URL=https://api.sernixa.com
export SERNIXA_API_KEY="<your-organization-api-key>"

Create the client from environment variables so credentials are not embedded in source code:

import { Client } from '@sernixa/sdk'

const client = new Client()

Interactive developer tools may use the SDK browser-device flow and construct a client with the returned accessToken. Deployed services should use a separate, least-privilege organization API key. Both credential types are checked against the same backend permissions and plan entitlements.

Before the first action, verify the credential and organization:

const identity = await client.whoami()
console.log(identity.organization_id, identity.permissions)

Gate a function

Wrap the smallest function that crosses a meaningful trust boundary. Use stable, policy-friendly context and keep unnecessary data out of metadata.

const governedRead = client.intercept(async (documentId: string) => documents.read(documentId), {
  intentId: 'customer-document-read',
  riskLevel: 'LOW',
  operationClass: 'read',
  dataSensitivity: 'confidential',
  systemsTouched: ['document-store'],
})

const document = await governedRead('doc_123')

The wrapped function remains yours. Validate its return value and handle its own business errors after Sernixa allows it to run.

For Codex and Claude, Sernixa uses the verified direct request as the scope. Exact work inside that scope does not need another Sernixa approval merely because it changes state. New or unclear scope can require review, and a hard organization policy still blocks the action.

Handle every outcome

Your integration should have an intentional path for:

SituationExpected behavior
ApprovedExecute once and validate the downstream result.
Pending reviewWait within the configured timeout without performing the action.
Rejected or blockedStop and show the reason to the operator.
ExpiredStop; submit a new request only when the action is still needed.
Authentication failureStop and repair credential delivery. Do not treat it as a policy result.
Network or service failureFail safely according to the action's risk; do not silently bypass governance.

Gate an MCP-style call

Use the SDK call gate for a tool call that matches an approved plan step. Provide the plan token, one-time step proof, and step ID from that plan, or use an active binding with a matching unused step. The arguments and resource must match the approved step.

This example assumes the plan already approved this exact read. The gate's dispatch mode tells the integration who owns the upstream call.

const decision = await client.mcpCallGate({
  mcpToolsetId: 'workspace-tools',
  toolName: 'read_file',
  intentId: 'read-workspace-report',
  arguments: { path: '/workspace/report.md' },
  riskLevel: 'LOW',
  operationClass: 'read',
  dataSensitivity: 'internal',
  planToken,
  stepProof,
  stepId: stepProof.step_id,
})
  • For pending_review, hold the action and handle the approval request.
  • In caller_owned_after_allowed mode, the host owns dispatch. Proceed only after an accepted decision and verification of the signed execution contract against the proposed call.
  • In sernixa_gateway_proxy mode, the gateway already owns upstream dispatch. Check the upstream response and execution receipt. A second call could repeat the action.

Connecting an advisory MCP server lets the client query policy. Actual enforcement requires the call to pass through a configured gateway, proxy, or SDK boundary.

Production checklist

  • Use a separate, least-privilege key for each application and environment.
  • Keep a stable agent identity, intent ID, and operation taxonomy.
  • Leave argument capture off unless review genuinely requires values.
  • Test approval, rejection, block, expiry, authentication failure, and network failure.
  • Make retries idempotent for mutable actions.
  • Verify a low-risk action in the Command Center before adding high-impact operations.
  • Record the downstream result when end-to-end completion matters.

Next step

Secure the integration with Authentication and API keys, then configure Policies and controls.

For host-specific permission and sandboxing considerations, read How to Secure Codex, Claude Code and Cursor.