#17
Fix `Error: redisUrl is required`
🚧 This PR is Part of a Series
- https://github.com/vercel-labs/mcp-for-next.js/pull/17
- https://github.com/vercel/mcp-adapter/pull/62
👋 TL;DR
Fix Error: redisUrl is required
🔎 Details
resolves https://github.com/vercel-labs/mcp-for-next.js/issues/16
MCP Server
pnpm add dotenv@latest- add
lib/env.tsfor loadingREDIS_URL - extend
route.tsto passredisUrlto@vercel/mcp-adapter#createMcpServerparamConfig[redisUrl]https://github.com/vercel/mcp-adapter/blob/7149159/src/next/mcp-api-handler.ts#L75 - add
.nvmrc(lts/*)
MCP Client
pnpm add -D @modelcontextprotocol/sdk@latest- extend
package.json#scripts(test:client)
✅ How to Test
- run:
#/usr/bin/env bash nvm install nvm use pnpm install -D # https://github.com/redis/node-redis/blob/9ea260f/packages/client/lib/client/index.ts#L33 # replace `redis[s]://[[username][:password]@][host][:port][/db-number]` with your actual `REDIS_URL` echo "REDIS_URL=\"redis[s]://[[username][:password]@][host][:port][/db-number]\"" > .env.local pnpm build pnpm dev - in another terminal, run
pnpm test:client http://localhost:3000 - 🔴 see that the output no longer reads:
> next.js-mcp-server@0.1.0 dev /Users/patrick/src/servant-io/mcp-for-next.js > next dev ▲ Next.js 15.2.4 - Local: http://localhost:3000 - Network: http://192.168.1.52:3000 ✓ Starting... ✓ Ready in 2.8s ○ Compiling /[transport] ... ✓ Compiled /[transport] in 1443ms (994 modules) Error: redisUrl is required at Generator.next (<anonymous>) at new Promise (<anonymous>) at Generator.next (<anonymous>) at new Promise (<anonymous>) at new Promise (<anonymous>) ⨯ unhandledRejection: Error: redisUrl is required at Generator.next (<anonymous>) at new Promise (<anonymous>) at Generator.next (<anonymous>) at new Promise (<anonymous>) at new Promise (<anonymous>) ⨯ unhandledRejection: Error: redisUrl is required at Generator.next (<anonymous>) at new Promise (<anonymous>) at Generator.next (<anonymous>) at new Promise (<anonymous>) at new Promise (<anonymous>) - 🟢 instead, see that the output now reads:
> next.js-mcp-server@0.1.0 dev /Users/patrick/src/servant-io/mcp-for-next.js > next dev ▲ Next.js 15.2.4 - Local: http://localhost:3000 - Network: http://192.168.1.52:3000 - Environments: .env.local ✓ Starting... ✓ Ready in 1650ms ○ Compiling /[transport] ... ✓ Compiled /[transport] in 1458ms (999 modules) Redis error [Error: Socket closed unexpectedly] Redis error [Error: Socket closed unexpectedly] Redis error [Error: Socket closed unexpectedly]
@pstaylor-patrick is attempting to deploy a commit to the Uncurated Tests Team on Vercel.
A member of the Team first needs to authorize it.