Skip to main content

Scaffold a new project

The fastest way to get started is the scaffold CLI. It creates a new project from a template and optionally installs dependencies.

Available templates

If you run bun create @phake/mcp without a --template flag, an interactive prompt appears and defaults to cloudflare-workers.

CLI options


Manual setup

If you prefer to add @phake/mcp to an existing project, follow these steps.
1

Install the package

Add @phake/mcp to your project using your preferred package manager.
2

Define a tool

Use defineTool to create a type-safe tool. Provide a Zod schema for the input and a handler function that returns a result.
3

Create the server

Pass your tools to createMCPServer. For a Cloudflare Workers deployment, set adapter to "worker" and export the server as the module default.
4

Deploy

For Cloudflare Workers, deploy with Wrangler:
For Node.js, start the server with Bun or Node:
Cloudflare Workers deployments require a KV namespace for token storage and an AES-256-GCM encryption key. See the Cloudflare Workers guide for the full setup walkthrough.