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.
Bind KV in your Wrangler config
Add the KV namespace binding to your Wrangler configuration file. Use the namespace ID from the previous step.
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.
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
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