Skip to content

Wire SDK

For teams building agents, harnesses, or AI infrastructure who want Wire container connectivity as a first-class part of the product. Three methods. Your user authorizes in their browser; you get back a scoped MCP endpoint and API key to hand to your agent.

You don’t run the storage. You don’t build the import flow. You don’t manage user data. Wire owns the connect screen, the auth, and the connection lifecycle. Your agent keeps speaking MCP, now with whatever the user has brought along.

Terminal window
npm install @usewire/sdk

Runs on Node 18+, Cloudflare Workers, Deno, and Bun. connect() assumes your agent runs outside the user’s browser (CLI, IDE plugin, server-side worker) and can show them a code to type on the consent screen.

In a pure browser app, getStatus and disconnect work against an existing apiKey, but a browser-native connect() is not yet supported.

Before the SDK can connect on behalf of your users, register your app from the Apps entry in your account menu in the Wire dashboard. You’ll get an appId (your slug) that the SDK uses to identify itself.

import { WireClient } from '@usewire/sdk';
const client = new WireClient({ appId: 'my-app' });
const connection = await client.connect({ label: 'my-laptop' });
// Hand these to your agent's MCP client:
const mcp = new MCPClient({
url: connection.mcpUrl,
headers: { 'x-api-key': connection.apiKey },
});

connect() shows the user a short code and opens their browser. The user types the code on the connect screen, picks a container, and connect() resolves with the result.

If you need to drive the prompt yourself (custom UI, no stdout):

const connection = await client.connect({
onUserPrompt: ({ code, url }) => {
myUi.show(`Code: ${code}`);
myBrowser.open(url);
},
});
interface Connection {
mcpUrl: string;
apiUrl: string;
apiKey: string;
containerId: string;
containerName: string;
orgSlug: string | null;
expiresAt: Date | null; // ephemeral containers only
appId: string;
credentialId: string;
deviceKey: DeviceKey;
connectedAt: Date;
label?: string;
}

The SDK persists nothing. Keep whatever fields you want from the result, however you want.

deviceKey identifies the install across reconnects. Persist it if you want the same user and machine to appear as the same install instead of a fresh one every time:

// First run
const conn = await client.connect();
saveSomewhere(conn.deviceKey);
// Later
const client2 = new WireClient({
appId: 'my-app',
deviceKey: loadSomewhere(),
});
const conn2 = await client2.connect();

Local file, OS keychain, secrets manager, your call.

await client.disconnect(connection.apiKey);
await client.getStatus(connection.apiKey);

disconnect revokes the apiKey but keeps the install identity, so reconnect from the same deviceKey still works.

Rejected promises throw WireSdkError with a code and HTTP status when applicable.

github.com/usewire/wire-sdk · @usewire/sdk on npm · MIT licensed.