Skip to main content
1

Install the package

Add @phake/mcp to your project:
2

Create the KV namespace

Run the following command to create a KV namespace for token storage:
Copy the namespace ID printed in the output — you’ll need it in the next step.
3

Bind KV in your Wrangler config

Add the KV namespace binding to your Wrangler configuration file. Use the namespace ID from the previous step.
4

Generate an encryption key

Tokens at rest are encrypted with AES-256-GCM. Generate a 32-byte key using one of the following commands:
Save the output — you’ll use it in the next step.
5

Set the encryption key

Set RS_TOKENS_ENC_KEY in your environment.Production — add it as a Wrangler secret so it’s encrypted at rest:
Local development — add it to .dev.vars in your project root:
.dev.vars
Never commit .dev.vars or your encryption key to version control.
6

Create your Worker

Create your main Worker file. Import createMCPServer from @phake/mcp, define your tools, and export the server as the default export:
src/index.ts
Use defineTool to create type-safe tools with Zod input/output schemas. See the tool definition docs for the full field reference.
7

Deploy

Deploy your Worker to Cloudflare:
Your MCP server will be available at your Worker’s URL (e.g., https://your-worker.your-subdomain.workers.dev/mcp).