Skip to main content
@phake/mcp is a TypeScript library for building Model Context Protocol (MCP) servers. It runs on Cloudflare Workers and Node.js, and gives you type-safe tool definitions, OAuth 2.1 authentication, and encrypted token storage out of the box.

Quick Start

Scaffold and deploy your first MCP server in minutes.

Define Tools

Create type-safe tools with Zod schemas and handler functions.

Authentication

Add OAuth, Bearer, API Key, or custom auth to your server.

API Reference

Full reference for createMCPServer, defineTool, and more.

Get started in 3 steps

1

Install the package

Add @phake/mcp to your project or scaffold a new one with a single command.
npm install @phake/mcp
# or scaffold a new project
bun create @phake/mcp my-mcp-app
2

Define your tools

Use defineTool to create typed, validated tools backed by Zod schemas.
import { z } from "zod";
import { defineTool } from "@phake/mcp";

const greetTool = defineTool({
  name: "greet",
  description: "Returns a greeting for the given name",
  inputSchema: z.object({ name: z.string() }),
  handler: async (args) => ({ message: `Hello, ${args.name}!` }),
});
3

Create and export your server

Wrap your tools in createMCPServer and export the result as your Worker default.
import { createMCPServer } from "@phake/mcp";

const server = createMCPServer({ tools: [greetTool] });
export default server;
Use the scaffold CLI to get a working project with your chosen template in seconds: bun create @phake/mcp my-app --template cloudflare-workers --install