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.
# Interactive — prompts for template name
bun create @phake/mcp

# Non-interactive — specify template and install dependencies
bun create @phake/mcp my-mcp-app --template cloudflare-workers --install

Available templates

TemplateDescription
cloudflare-workersCloudflare Workers + Hono (default)
cloudflare-workers-googleCloudflare Workers + Google OAuth
node-honoNode.js + Bun + Hono
If you run bun create @phake/mcp without a --template flag, an interactive prompt appears and defaults to cloudflare-workers.

CLI options

OptionDescription
-t, --templateTemplate name
-i, --installAuto-install dependencies after scaffolding
-p, --pmPackage manager to use: npm, bun, yarn, or pnpm

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.
npm install @phake/mcp
# or
bun add @phake/mcp
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.
import { z } from "zod";
import { defineTool } from "@phake/mcp";

const greetTool = defineTool({
  name: "greet",
  title: "Greet User",
  description: "Returns a greeting for the given name",
  inputSchema: z.object({
    name: z.string().describe("Name to greet"),
  }),
  outputSchema: z.object({
    message: z.string().describe("The greeting message"),
  }),
  handler: async (args) => {
    return { message: `Hello, ${args.name}!` };
  },
});
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.
import { createMCPServer } from "@phake/mcp";

const server = createMCPServer({
  tools: [greetTool],
});

export default server;
4

Deploy

For Cloudflare Workers, deploy with Wrangler:
wrangler deploy
For Node.js, start the server with Bun or Node:
bun run src/index.ts
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.