# Okapi install guide — Node.js

Okapi speaks the Sentry ingest wire format: this is the standard `@sentry/node` SDK, pointed at your own Okapi instance instead of Sentry's.

The DSN in this generic guide is a placeholder. Get the real DSN from Project → Settings → DSN Keys. An agent with an admin Okapi MCP credential can also call `get_dsn`. Do not invent a DSN.

Do not run the Sentry wizard or any setup that signs in to Sentry's hosted service; nothing in this setup should contact it.

## 1. Install

```bash
npm install @sentry/node
```

## 2. Initialize

### `instrument.mjs`

```javascript
import * as Sentry from "@sentry/node";

Sentry.init({
  dsn: "http://YOUR_PUBLIC_KEY@YOUR_OKAPI_HOST/YOUR_PROJECT_ID",
  environment: "production",
});
```

Okapi authenticates ingest by the DSN's public key alone — there is no secret component, so the DSN is safe to embed in application config. Initialize as early as possible in your entry point, before anything else that might throw.

Load instrument.mjs before any other module: node --import ./instrument.mjs app.mjs (Node 20.19+). A short-lived script needs await Sentry.flush(2000); a running server does not.

## 3. Send a test event

### `app.mjs`

```javascript
import * as Sentry from "@sentry/node";

Sentry.captureException(new Error("Okapi test event"));
await Sentry.flush(2000); // needed in a short-lived script
```

## 4. Verify

Open the instance's dashboard → Issues. The test event should appear within a few seconds as a new issue. If the instance's MCP server exposes a `verify_installation` tool, call that instead of checking by hand — it reports the SDK name/version and whether only a synthetic test event has arrived yet.

## More

- Structured logs (same DSN, no separate shipper) and source map uploads: https://useokapi.app/docs/sdk-setup
- Connect over MCP once the SDK is wired up: https://useokapi.app/docs/mcp-agents
