
Stytch Consumer Todo List
STDIOWorkers server with React website, REST API, and MCP integrating Stytch authentication
Workers server with React website, REST API, and MCP integrating Stytch authentication
This is a Workers server that composes three functions:
User and client identity is managed using Stytch. Put together, these three features show how to extend a traditional full-stack application for use by an AI agent.
This demo uses the Stytch Consumer product, which is purpose-built for Consumer SaaS authentication requirements. If you are more interested in Stytch's B2B product, see this demo instead.
Follow the steps below to get this application fully functional and running using your own Stytch credentials.
Create a Stytch account. Within the sign up flow select Consumer Authentication as the authentication type you are interested in. Once your account is set up a Project called "My first project" will be automatically created for you.
Navigate to Frontend SDKs to enable the Frontend SDK in Test
Navigate to Connected Apps to enable Dynamic Client Registration
Navigate to Project Settings to view your Project ID and API keys. You will need these values later.
In your terminal clone the project and install dependencies:
git clone https://github.com/stytchauth/mcp-stytch-consumer-todo-list.git cd mcp-stytch-consumer-todo-list npm i
Next, create an .env.local
file by running the command below which copies the contents of .env.template
.
cp .env.template .env.local
Open .env.local
in the text editor of your choice, and set the environment variables using the public_token
found on Project Settings.
# This is what a completed .env.local file will look like
VITE_STYTCH_PUBLIC_TOKEN=public-token-test-abc123-abcde-1234-0987-0000-abcd1234
Create a .dev.vars
file by running the command below which copies the contents of .dev.vars.template
cp .dev.vars.template .dev.vars
Open .dev.vars
in the text editor of your choice, and set the environment variables using the Project ID
and Secret
found on Project Settings.
// This is what a completed .dev.vars file will look like
STYTCH_PROJECT_ID=project-test-6c20cd16-73d5-44f7-852c-9a7e7b2ccf62
STYTCH_SECRET=your-stytch-secret-key
After completing all the setup steps above the application can be run with the command:
npm run dev
The application will be available at http://localhost:3000
and the MCP server will be available at http://localhost:3000/sse
.
Test your MCP server using the MCP Inspector
npx @modelcontextprotocol/inspector@latest
Click the button - you'll need to configure environment variables after the initial deployment.
Or, if you want to follow the steps by hand:
wrangler kv namespace create TODOS
wrangler.jsonc
with the ID you received:"kv_namespaces": [
{
"binding": "TODOS",
"id": "your-kv-namespace-id"
}
]
npx wrangler secret bulk .dev.vars
npm run deploy
https://mcp-stytch-consumer-todo-list.$YOUR_ACCOUNT_NAME.workers.dev
:
https://mcp-stytch-consumer-todo-list.$YOUR_ACCOUNT_NAME.workers.dev/authenticate
as an allowed Redirect URLhttps://mcp-stytch-consumer-todo-list.$YOUR_ACCOUNT_NAME.workers.dev
as an allowed Authorized Application in the Frontend SDKs configurationJoin the discussion, ask questions, and suggest new features in our Slack community!