MainSDK
Search⌘K
Open source · Apache-2.0 · free

Agents build.
You ship safe
and reliable.

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

npx mainsdk init
Continue with GitHub Free. No card, no form.

Pre-release: in design, nothing to install yet. See what is coming or read the planned quickstart.

~/shop-orders
GitHubAmazon BedrockAnthropicOpenAIPostgreSQLSupabaseStripeRazorpayClerkAuth0ResendTwilioWhatsAppOpenTelemetryPostHogUpstashVercelCloudflare
Why it exists

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

All 6 fixed by MainSDK

Keys in the frontend

AI-assisted commits leak secrets at about twice the human rate (GitGuardian).

Without MainSDK: Bill maxed out overnight, paywall bypassed.

With MainSDK: secret: refs only. A key in code fails the check.Saves a key rotation, a surprise bill and a post-mortem.

Every user reads every record

One flaw, CVE-2025-48757, left about 170 AI-built apps open.

Without MainSDK: Your users’ data, readable without login.

With MainSDK: Every action checked. Deny by default.Saves a breach notice to every user.

The agent deletes production

July 2025: an agent wiped about 1,206 records during a code freeze.

Without MainSDK: Production data gone, no undo.

With MainSDK: Destructive actions wait for your signed approval.Saves a restore from backup, if you have one.

Packages that don’t exist

19.7% of sampled agent code named a nonexistent package (Cloud Security Alliance).

Without MainSDK: A look-alike package ships malware.

With MainSDK: Every dependency verified before install.Saves a malware clean-up across every machine.

Diffs nobody can read

Lines per pull request up about 250% in a year (Cursor).

Without MainSDK: Approved without reading. Old flows break.

With MainSDK: Check reports what behaviour changed, not lines.Saves reading a huge diff line by line.

The enterprise deal stalls

Every enterprise buyer asks for SSO, audit logs and a security review.

Without MainSDK: Months of building before you can sell.

With MainSDK: SAML, SCIM and audit export in the SDK, free.Saves 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.

Quickstart

Three steps from an empty folder to a checked app.

terminal
$ 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
Integrations

Plug in what you already use. Change it later without touching your code.

Your agent already knows it

Every action is also an MCP tool, and AGENTS.md, llms.txt and an agent skill are written for you. Claude Code, Cursor and Codex build on the interfaces, not around them.

Agents on a leash

Planned: every agent action is attributed to the agent and the person it acts for, with a budget, a human approval for risky steps and a kill switch. Model calls can stream and return checked, typed output.

Ready for wallets and onchain

Planned: wallet sign-in, token gates and agent payments run under the same policy, audit and budgets. Chains are drivers; core carries no chain code and never holds funds.

Leave whenever you want

No lock-in by design: eject writes plain provider code in place of MainSDK calls and tells you what guarantees you give up. Recipes are proposed for email, pay, auth and db first.

Checked before it ships

Planned: 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

Planned: SAML, SCIM, passkeys, audit export and customer-managed keys 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

Straight answers before you start.

More in the docs. Using an AI assistant? Point it at llms.txt.

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. Shadow mode for the new driver and a guided job that moves stored state are planned and not specified yet. 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.

Free. Sign in with GitHub and start.

Continue with GitHub
npx mainsdk init