---
title: "MainSDK: agents build, you ship safe and reliable"
url: https://mainsdk.dev/
description: "MainSDK is the open-source app runtime for apps built by AI coding agents: swappable drivers, one main.yaml and a check before every deploy. Free, Apache-2.0."
---

# MainSDK

MainSDK is the open-source app runtime for apps built by AI coding agents: standard interfaces with swappable drivers, one main.yaml manifest, and checks that keep agent-written code safe, reliable and compliant by default.

**Agents build. You ship safe and reliable.**

Status: MainSDK is pre-release. It is in design, no package is published, and the docs describe the planned product. The TypeScript public beta is milestone 0.5; version 1.0 follows an independent audit.

Open source · Apache-2.0 · free

One SDK gives your app sign-in, access, data, AI and payments behind standard interfaces, and checks all of it before every deploy.

```sh
npx mainsdk init        # npm
pnpm dlx mainsdk init   # pnpm
bunx mainsdk init       # bun
```

Free. No card, no form. [Continue with GitHub](https://mainsdk.dev/sign-in).

What the first run looks like:

```text
$ npx mainsdk init
>_ found Next.js 16 · TypeScript
>_ main.yaml  auth: github · ai: bedrock
>_ types generated for every interface
$ npx mainsdk check
  auth    github      pass
  ai      bedrock     pass  no keys in code
  access  12 actions  pass
■ ready to ship · Main 27 · signed
```

## Why it exists

Your agent gets to a working demo fast. What breaks is everything a demo never tests.

| Without MainSDK | Evidence | With MainSDK | Saves |
| --- | --- | --- | --- |
| **Keys in the frontend.** Bill maxed out overnight, paywall bypassed. | AI-assisted commits leak secrets at about twice the human rate (GitGuardian). | `secret:` refs only. A key in code fails the check. | A key rotation, a surprise bill and a post-mortem. |
| **Every user reads every record.** Your users' data, readable without login. | One flaw, CVE-2025-48757, left about 170 AI-built apps open. | Every action checked. Deny by default. | A breach notice to every user. |
| **The agent deletes production.** Production data gone, no undo. | July 2025: an agent wiped about 1,206 records during a code freeze. | Destructive actions wait for your signed approval. | A restore from backup, if you have one. |
| **Packages that don't exist.** A look-alike package ships malware. | 19.7% of sampled agent code named a nonexistent package (Cloud Security Alliance). | Every dependency verified before install. | A malware clean-up across every machine. |
| **Diffs nobody can read.** Approved without reading. Old flows break. | Lines per pull request up about 250% in a year (Cursor). | Check reports what behaviour changed, not lines. | Reading a huge diff line by line. |
| **The enterprise deal stalls.** Months of building before you can sell. | Every enterprise buyer asks for SSO, audit logs and a security review. | SAML, SCIM and audit export in the SDK, free. | Months of building SSO and audit logs. |

Sources: GitGuardian, CVE-2025-48757, public reports of the July 2025 Replit incident, Cloud Security Alliance, Cursor. Links in the [docs](https://mainsdk.dev/docs).

## Quickstart: three steps from an empty folder to a checked app

1. **Install.** One command finds your framework, writes `main.yaml` and tells your agent the rules.

   ```text
   $ npx mainsdk init
   >_ found Next.js 16 · TypeScript · pnpm
   >_ wrote main.yaml
   >_ added mainsdk to package.json
   >_ typed every interface: auth, access, data, ai, pay
   >_ AGENTS.md lists every action as an MCP tool
   ```

2. **Declare.** Sign in with GitHub, AI on Bedrock, data on Postgres. One line each.

   ```yaml
   # main.yaml: the whole app, declared
   app: shop-orders
   auth:
     driver: github        # passkeys and SSO one line away
   ai:
     driver: bedrock       # IAM role, no keys in code
   data:
     driver: postgres
   access:
     driver: cedar
   ```

3. **Check and ship.** The same check runs on your laptop and in CI. Pass, and you ship.

   ```text
   $ npx mainsdk check
     auth     github       pass
     ai       bedrock      pass  no stored keys
     data     postgres     pass  personal fields labelled
     access   12 actions   pass  every action has a permission
     network  4 hosts      pass  deny by default
   ■ ready to ship · runs the same in CI
   ```

## Integrations

Plug in what you already use. Change it later without touching your code: switching a provider changes one line in `main.yaml`, and your code stays the same.

| Capability | Interface | Drivers |
| --- | --- | --- |
| Sign-in | [`auth`](https://mainsdk.dev/docs/interfaces/auth) | GitHub, Clerk, Auth0, Supabase Auth |
| AI | [`ai`](https://mainsdk.dev/docs/interfaces/ai) | Amazon Bedrock, Anthropic, OpenAI, an AI gateway |
| Data | [`db`](https://mainsdk.dev/docs/interfaces/db), [`kv`](https://mainsdk.dev/docs/interfaces/kv), [`search`](https://mainsdk.dev/docs/interfaces/search) | Postgres, Neon, Supabase, Upstash Redis, Redis, Typesense, Meilisearch, Algolia, pgvector |
| Payments | [`pay`](https://mainsdk.dev/docs/interfaces/pay) | Stripe, Razorpay, Paddle |
| Messaging | [`email`](https://mainsdk.dev/docs/interfaces/email), [`notify`](https://mainsdk.dev/docs/interfaces/notify), [`broadcast`](https://mainsdk.dev/docs/interfaces/broadcast) | Resend, Amazon SES, Twilio, WhatsApp, Firebase, Apple Push, Expo Push, Pusher |
| Observability | [`log`](https://mainsdk.dev/docs/interfaces/log), [`analytics`](https://mainsdk.dev/docs/interfaces/analytics) | OpenTelemetry, PostHog, Plausible, Google Analytics |
| Secrets | [`secrets`](https://mainsdk.dev/docs/interfaces/secrets) | Vault, AWS Secrets Manager, Google Secret Manager |

Example: move AI from Bedrock to Anthropic.

```yaml
ai:
  driver: anthropic
```

```ts
// your code, unchanged
const summary = await ai.generate({ prompt });
```

Free in your app. Anything not listed: build a driver with the driver kit, or call the provider directly through `raw()`.

## What you get

- **Your agent already knows it.** Every action is also an MCP tool, and AGENTS.md is written for you. Claude Code, Cursor and Codex build on the interfaces, not around them.
- **Checked before it ships.** `mainsdk check` runs locally and in CI. A missing permission or a key in code fails the check, not production.
- **Enterprise-ready on day one.** SAML, SCIM, passkeys, audit export and customer-managed keys are in the SDK, free.
- **Free where it runs.** Everything inside your app is Apache-2.0. An app protecting itself is never a paid feature.

## Questions

### What is MainSDK?

MainSDK is the open-source app runtime for apps built by AI coding agents. Your app calls standard interfaces for sign-in, access, data, AI, payments and more, and a driver connects each one to the provider you choose in one main.yaml file. The mainsdk check command verifies every change before it ships. MainSDK is made by HubXero and is free under Apache-2.0.

### Is MainSDK free?

Yes. Everything that runs inside your app is free and open source under Apache-2.0: the SDK, the CLI, every check and guarantee, every driver, the MCP server and the policy engine. MainSDK Cloud has paid plans for hosted history, team workflow and company-wide governance. An app protecting itself is never a paid feature.

### Is MainSDK production-ready?

No, not yet. MainSDK is pre-release: it is in design, and no package is published. Work runs in milestones from 0.1 Foundation to 0.5 Pilot ready, which is the public beta of the TypeScript SDK. Version 1.0 follows an independent audit. Until then, read the docs as the planned design and watch the GitHub repository for releases.

### How is MainSDK different from a security scanner?

A scanner reports problems after the code exists; MainSDK puts the safeguards inside the building blocks your agent uses. Keys stay out of code because interfaces take secret references, and every action checks permissions by default. The check then verifies rules, intent and outcomes before a change reaches main, and sends failures back to the agent with the fix. MainSDK bundles open-source scanners and runs alongside yours.

### Does MainSDK work with Next.js?

Yes. Next.js is a first target, with an App Router adapter that covers route handlers, server actions and the proxy. Hono, Express and Node workers have adapters too, and Prisma or Drizzle plug in as the data layer. You need TypeScript and Node.js 22 or later. The adapters are planned for milestone 0.2, before the public beta.

### Which AI providers does MainSDK support?

The ai interface has drivers for Amazon Bedrock, Anthropic and OpenAI, plus an AI gateway driver and a local fake for tests. You pick one in main.yaml and can switch later without changing code. Every call keeps provider keys out of code, redacts personal data before the model sees it, refuses providers that train on or keep prompts, and enforces spend limits per user.

### Which AI coding agents work with MainSDK?

Any agent that speaks the Model Context Protocol (MCP) works with MainSDK, including Claude Code, Cursor, Codex and GitHub Copilot. mainsdk init writes AGENTS.md rules for your agent, and the MCP server exposes your app's actions as tools. Apps started in Lovable, Bolt, v0 or Replit come over through mainsdk check and the migration skill.

### Can I use MainSDK on an app I already built?

Yes. Run mainsdk check on an existing TypeScript app to see what to fix, then use mainsdk adopt and the migration skill to move it onto MainSDK one pull request at a time, with no rewrite. This is the intended first step for apps built with Lovable, Bolt, v0 or Cursor, and the goal is a useful result in under five minutes.

### Can I switch providers without rewriting code?

Yes. Your code calls an interface such as pay or email, and the provider is one line in main.yaml. Moving from Stripe to Razorpay, or from Amazon Bedrock to Anthropic, changes that line, not your code. You can run the new driver in shadow mode first, and a guided job moves stored state. Anything not covered can call the provider directly through raw().

### Does my app go down if MainSDK Cloud goes down?

No. MainSDK is designed never to sit in the request path: policy decisions run inside your app, no user request waits on MainSDK Cloud, and telemetry never blocks. If the Cloud is slow or unreachable, your app keeps its last good policy, packs and config and keeps serving. Plan limits affect only the Cloud, never your running app.

More answers: [llms.txt](https://mainsdk.dev/llms.txt) and the [docs](https://mainsdk.dev/docs).

## Start

Free. Sign in with GitHub and start: `npx mainsdk init`.

- Docs: https://mainsdk.dev/docs
- Source: https://github.com/hubxero/mainsdk

A HubXero product. Third-party logos belong to their owners.
