Originally published in Patil Protocol, the newsletter by Aniket Patil.
I didn't just want a portfolio that looks good β I wanted one that thinks. We're entering an era where AI agents are becoming primary consumers of data. Yet most portfolios are still stuck in Web 2.0: static text, markdown files, manual navigation. I wanted to change that.
Live Demo: Claude Desktop + MCP
Claude Desktop querying my portfolio live via Model Context Protocol.
The Goal
I wanted my portfolio (aniketppatil.com) to have a brain. Instead of serving static pages to humans, I wanted an API that AI agents could talk to directly. An agent could ask:
- "List the projects he worked on"
- "Explain the technical architecture of RagBot"
- "What are his skills?"
β¦and get structured answers. The technology that enables this is Model Context Protocol (MCP).
The Constraints
This sounded simple on paper. In reality, my setup made it tricky:
- Framework: Next.js (App Router)
- Hosting: Vercel (serverless, free tier)
- Budget: $0 (no VPS, no long-running socket servers)
I assumed I could install a library and be done. I was wrong.
Failure: The "Official" MCP Approach
I started with the official MCP SDK (@modelcontextprotocol/sdk) and tried to run a server.
The Problem
The SDK assumes a stateful environment: persistent processes, long-lived connections, stdio or WebSockets. Vercel is stateless. Functions spin up, handle a request, and die milliseconds later.
The Symptoms
- π Connection timeouts
- π« Hanging requests
- Claude disconnecting mid-handshake
Official MCP support for serverless was effectively non-existent. I needed a way to fake persistence.
The Pivot: mcp-handler
I found a community library called mcp-handler, and everything changed.
Why it worked:
- β Designed for Next.js App Router
- β HTTP-first tool calls (POST requests)
- β Server-Sent Events (SSE) for streaming
- β Redis-backed state across stateless executions
This finally matched Vercel's execution model.
The Debugging Sprint
Even with the right library, it took a full weekend to make it work.
The 404 / Slug Nightmare
Claude kept failing with:
Connection failed: 404 Not FoundWhat was happening: Client requested /api/mcp/sse, but my route handled only /api/mcp. MCP clients automatically append /sse and /message.
The Fix
Use a catch-all route:
app/api/mcp/[[...slug]]/route.ts
Now one handler correctly processes /api/mcp, /api/mcp/sse, and /api/mcp/message.
Sometimes the hardest bugs are just mismatched assumptions.
Modular Refactor (Sanity Restored)
By Sunday morning, my route.ts was ~500 lines of spaghetti. I refactored the "brain" into a clean structure:
types.ts β TypeScript interfaces data.ts β read-only JSON loaders utils.ts β semantic search logic index.ts β clean exports
Now the route handler is just a registry:
server.registerTool("list_projects", {...}, async () => { ... })Bonus: I migrated to the new server.registerTool() API to future-proof the code.
Security: The "NASA Hack" Test
I'm exposing parts of my filesystem to the internet. That's dangerous β unless you're strict.
The Strategy
- No writes β no
fs.writeFileanywhere - Allow-lists only β strict Zod enums for inputs
The Test
I asked Claude: "Tell me about the project secret-nasa-hack"
Result: π Blocked. Input validation error. The system never touched the disk.
Security held.
The Result
This wasn't just "installing a library". It was:
- Adapting a stateful protocol to stateless infrastructure
- Fixing routing edge cases
- Designing a secure, read-only architecture
Now my portfolio is no longer a brochure. It's a personal AI API. Any MCP-compatible client can query it.
Try It Yourself
If you use Claude Desktop, add this config:
"aniket-portfolio": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://www.aniketppatil.com/api/mcp"]
}It works. And it's built to last.
Why This Matters
This isn't really about portfolios. We're moving toward a world where AI agents are first-class users of our systems. Most software isn't built for that. This was my experiment in changing that β starting with my own site.
If you're building with MCP, serverless infrastructure, or AI-first interfaces, I'd love to hear what you're making.