createApp
Library escape hatch for tests and custom servers.
The CLI and file conventions use createApp.fromDir() internally. You rarely need this in application code.
import { createApp } from "bitmcp";
const app = createApp({
name: "my-server",
version: "0.0.1",
tools: [myTool],
});
await app.stdio();
await app.http({ port: 3000 });
const response = await app.fetch(request);app.fetch is the primitive for Vercel, Cloudflare, and any Fetch runtime. See Deploy.
createApp.fromDir
const app = await createApp.fromDir("/path/to/project");Loads tools from src/tools/ using the same discovery rules as the compiler.
BitmcpApp methods
| Method | Description |
|---|---|
stdio() | Start stdio transport |
http(options?) | Start Streamable HTTP on Node |
fetch(request) | Web-standard handler |
Embed
bitmcp build emits GET, POST, OPTIONS, and default.fetch from dist/server.js. For an existing Next or Hono app:
import app from "../dist/server.js";
export const GET = (request: Request) => app.fetch(request);
export const POST = GET;
export const OPTIONS = GET;When to use
- Unit and integration tests
- Embedding bitmcp in a custom Fetch server
- Prototyping before adding file-based tools
For new projects, start with npx create-bitmcp and the file-based happy path.