Now, let's make your Person App Agentic. This means, we expose your CRUD app directly into LLMs. We do this via a protocol called MCP.
You can learn more about building and deploying your own agent here using the Roll Dice example: https://aiagents.ausbizconsulting.com.au/builders-toolkit
In this exercise, you will need
Step 1:
Study the Roll Dice MCP Server Repository: https://github.com/gocallum/rolldice-mcpserver
Key points to note
1// app/api/[transport]/route.ts2import { createMcpHandler } from "mcp-handler";3import { rollDice, rollDiceTool } from "@/lib/dice";4
5const handler = createMcpHandler(6 (server) => {7 server.tool(8 rollDiceTool.name,9 rollDiceTool.description,10 rollDiceTool.schema,11 async ({ sides }) => {12 // Use the shared dice rolling logic13 const result = rollDice(sides);14 return {15 content: [result],16 };17 }18 );19 },20 {21 // Optional server options22 },23 {24 // No Redis config - disable Redis requirement25 basePath: "/api", // this needs to match where the [transport] is located.26 maxDuration: 60,27 verboseLogs: true,28 }29);30export { handler as GET, handler as POST };So: this file is the HTTP/SSE bridge between your MCP client and your “dice rolling” business logic.
1const handler = createMcpHandler(2 (server) => {3 // register tools here4 },5 {6 // Optional server options7 },8 {9 basePath: "/api",10 maxDuration: 60,11 verboseLogs: true,12 }13);createMcpHandler is doing a few things for you:
You then export that handler as both HTTP methods:
1export { handler as GET, handler as POST };So Next.js sees:
The [transport] segment is used by mcp-handler to support different transports (e.g. SSE vs HTTP) under the same API structure.
Step 2:
You can test this out with rolldice server hosted on the Ausbiz Consulting website.
Change the URL to your own hosted, either locally, or hosted on Vercel. This will help you get familiar with the URL pattern.
1{2 "servers": {3 "rolldice": {4 "type": "http",5 "url": "https://rolldice.ausbizconsulting.com.au/api/mcp"6 }7 }8}This is the real “MCP heart”:
1(server) => {2 server.tool(3 rollDiceTool.name,4 rollDiceTool.description,5 rollDiceTool.schema,6 async ({ sides }) => {7 const result = rollDice(sides);8 return {9 content: [result],10 };11 }12 );13}Think of server.tool as:
“Register a tool with this MCP server so that the client can discover and call it.”
The parameters:
1{2 type: "object",3 properties: {4 sides: { type: "number", minimum: 1 }5 },6 required: ["sides"]7}Inside the implementation:
1const result = rollDice(sides);2return {3 content: [result],4};You’ve got two options objects after the callback.
1{2 // Optional server options3}You’re not setting anything here, but this is typically where you’d configure things like:
Since it’s empty, default behavior is used.
1{2 // No Redis config - disable Redis requirement3 basePath: "/api", // this needs to match where the [transport] is located.4 maxDuration: 60,5 verboseLogs: true,6}These are more about how the handler runs inside Next.js:
From the perspective of an MCP client (e.g. a ChatGPT or Claude MCP config):
Create a file called mcp-prd.md in the root folder, or in a sub-folder eg /docs
1Use the Github MCP server to learn the code from https://github.com/gocallum/rolldice-mcpserver/2
3Note that this uses mcp-handler package. 4
5Use the same pattern in the rolldice mcp server to create mcp-handler that leverages my existing server actions that perform crud operations. 6
7Once you are done, update my .vscode/mcp.json to include my mcp-server 8
9{10 "servers": {11 "person-app-mcp": {12 "type": "http",13 "url": "http://localhost:3000/api/mcp"14 }15 }16}17
18And then help me to test.Now get Claude Sonnet 4.5 or higher to generate the code and test.