1
Install the package
Add
@phake/mcp to your project:- npm
- bun
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 Local development — add it to
RS_TOKENS_ENC_KEY in your environment.Production — add it as a Wrangler secret so it’s encrypted at rest:.dev.vars in your project root:.dev.vars
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
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).