Getting Started

Installation

Create a project, run the dev server, and edit your first tool.

When you finish this page, you will have a local dev server, a working hello tool, and a preview of its View.

Agent-readable docs: append .md to any doc URL, or read /llms.txt.

Create a project

npx bitmcp create my-app
cd my-app

The scaffold includes:

my-app/
  bitmcp.config.ts
  package.json
  src/tools/hello/
    tool.ts
    view.tsx
    preview.ts

Install dependencies

pnpm install

Start the dev server

pnpm dev

Open the preview URL from the terminal. The local Apps host is a View editor: it loads a fixture from preview.ts, calls your tool with that input, and renders the View in a sandbox iframe.

Set a preview fixture

hello/preview.ts
export default { name: "World" };

Save and confirm the preview reloads with that input. See Preview fixtures for named cases.

Edit the hello tool

Change the return value in tool.ts and the displayed text in view.tsx. Save both files and confirm the preview reloads.

Verify preview and health

curl http://127.0.0.1:3000/health

Expect { "ok": true }. Call the hello tool from the preview UI.

Troubleshooting

IDE shows JSX errors (TS17004)

If your editor reports Cannot use JSX unless the '--jsx' flag is provided:

  1. Use bitmcp 0.1.1 or newer. Version 0.1.0 scaffolded a tsconfig that pointed at an unpublished package.
  2. Run pnpm install so bitmcp/tsconfig/react.json resolves from node_modules.
  3. Confirm tsconfig.json extends bitmcp/tsconfig/react.json (include the .json suffix).

The scaffold duplicates jsx and noEmit locally so Views typecheck even before install finishes. After install, the shared preset provides the full app config.

To upgrade an existing 0.1.0 project, bump bitmcp to ^0.1.2, remove any @bitmcp/typescript-config devDependency, and set:

tsconfig.json
{
  "extends": "bitmcp/tsconfig/react.json",
  "compilerOptions": { "jsx": "react-jsx", "noEmit": true },
  "include": ["src", "bitmcp.config.ts", ".bitmcp"]
}

Production checklist

Before shipping to production:

  1. Generate BITMCP_STATE_KEY: openssl rand -hex 32
  2. Set http.allowedHosts in bitmcp.config.ts to your public hostname
  3. Set platform secrets (BITMCP_STATE_KEY, and MCP_URL when OAuth is enabled)
  4. Run pnpm build locally to catch errors early
  5. Deploy — Vercel, Cloudflare, or Node
  6. Hit GET /health on your production URL
  7. Connect an MCP client and call a tool
  8. If OAuth is enabled, confirm /.well-known/oauth-authorization-server resolves
  9. Publish your server card with the correct MCP_URL

Environment variables

VariableWhen neededHow to setExample
BITMCP_ROOTCLI cwd differs from project rootShell or .env/path/to/my-app
BITMCP_STATE_KEYProduction HTTP with confirm or ctx.askPlatform secret or shellopenssl rand -hex 32
MCP_TRANSPORTOverride default transportShellstdio or http
MCP_PORTCustom HTTP portShell or --port3000
MCP_HOSTCustom bind addressShell0.0.0.0
MCP_PATHCustom MCP pathShell/mcp
MCP_URLOAuth enabled in productionPlatform secret or shellhttps://mcp.example.com/mcp
NODE_ENVProduction modePlatform or shellproduction

NODE_ENV=production requires BITMCP_STATE_KEY unless overridden in config.

bitmcp.config.ts

bitmcp.config.ts
import { defineConfig } from "bitmcp";

export default defineConfig({
  name: "bitmcp-app",
  version: "0.0.1",
});
FieldDescription
nameServer name (defaults to package.json name)
versionServer version (defaults to package.json version)
deploy"node" (default), "vercel", or "cloudflare"
http.allowedHostsHostnames allowed in production
authOAuth or API key provider

Full config options: Package exports.

Reference

Scripts

ScriptCommandPurpose
devpnpm devHTTP plus local Apps preview. Rebuilds Views with esbuild
buildpnpm buildBuild server bundle and hashed Views
startpnpm startProduction Streamable HTTP

Use bitmcp dev --stdio when a desktop host should spawn the server on stdio.

CLI

CommandDescription
bitmcp createScaffold a new project from the built-in template
bitmcp devesbuild watch for Views, HTTP, and a local Apps preview
bitmcp startProduction Streamable HTTP from dist/server.js
bitmcp buildHashed inlined View HTML plus dist/server.js
FlagApplies toDescription
--stdiodevUse stdio instead of HTTP plus preview
--port Ndev, startListen port
--tunneldevExpose localhost via cloudflared for remote MCP clients
--csp-widgetdevShow CSP allowlist editor in the preview host

--tunnel requires cloudflared on your PATH.