← stitchkitDocumentation

Documentation

The guide walks through building an app with stitchkit, from the first contract to deployment. Every page is pulled straight from the repository at build time, so it never drifts from the source.

  • Getting startedstitchkit turns one contract into an HTTP API, MCP tools, AI-agent tools and a typed client. This page gets a working app running; the rest of the guide goes deep on each piece.
  • ContractsA contract describes a set of operations once — method, path, schemas, scope, which transports each is exposed on. From it stitchkit derives the HTTP route, the MCP tool, the agent tool and the typed
  • HTTP serverstitchkit serves contracts on Bun.serve() directly — no Hono, no Elysia, no Express. You bind a contract to handlers with implement(), then mount the result on createServer().
  • Typed clientFrom a contract, createClient builds a fully-typed client — one method per endpoint, arguments and result inferred from the schemas. There is no codegen step: the types come straight from the contract
  • Realtimestitchkit's realtime layer is Socket.IO — polling fallback, heartbeats, acks, a mature client. stitchkit does not ship its own WebSocket engine; it ships thin, typed wrappers over Socket.IO and a brid
  • Auth & errorsstitchkit carries no domain model — it does not know what a user is. What it provides is the control flow: a scope on every endpoint, one hook that enforces it, and one error model shared by every tra
  • MCP & AI agentsThe same contract that drives the HTTP API also drives AI tooling. An endpoint exposed on MCP becomes a Model Context Protocol tool — callable from Claude, Cursor and other MCP clients. An endpoint ex
  • CLIThe same contract that drives the HTTP API, MCP tools and agent tools also drives a command-line program. createCli turns contract methods into commands — myapp generate "a fox" --wait, myapp models l
  • Multi-tenant / resource-scoped pathsA walkthrough of one mainstream scenario end-to-end: a SaaS API scoped by a path segment — /tenants/:tenantId/widgets/... — where the same tenantId gates access in auth and is injected into tool calls
  • ObservabilityA request reaches your app through one of two surfaces — an HTTP route or a tool call (MCP / agent). Observability is the same question on both: what happened, how long did it take, who made it, did i
  • Testing & deploymentstitchkit's own test suite runs on bun:test. The contract makes most of an API testable without a live socket.
  • Upgrading stitchkitHow to move a consuming project from one stitchkit version to another — including across many versions at once (a project frozen on an old version, then jumped forward). The process is mechanical: sti
  • API referenceEvery public export of stitchkit, grouped by entrypoint. Each entry links to the guide page that explains it in context. Types are marked type; everything else is a value (a function, a class, a const