Skip to content

Commit 9ab340c

Browse files
authored
docs: add Nuxt usage in the readme (#104)
1 parent eda4ae2 commit 9ab340c

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# mcp-handler
22

3-
A Vercel adapter for the Model Context Protocol (MCP), enabling real-time communication between your applications and AI models. Currently supports Next.js with more framework adapters coming soon.
3+
A Vercel adapter for the Model Context Protocol (MCP), enabling real-time communication between your applications and AI models. Currently supports Next.js and Nuxt with more framework adapters coming soon.
44

55
## Installation
66

@@ -50,11 +50,12 @@ const handler = createMcpHandler(
5050
export { handler as GET, handler as POST };
5151
```
5252

53-
## Advanced Routing
53+
### Advanced Routing
54+
5455
```typescript
5556
// app/dynamic/[p]/[transport]/route.ts
5657

57-
import { createMcpHandler } from "@vercel/mcp-adapter";
58+
import { createMcpHandler } from "mcp-handler";
5859
import type { NextRequest } from "next/server";
5960
import { z } from "zod";
6061

@@ -96,8 +97,36 @@ const handler = async (
9697
)(req);
9798
};
9899
export { handler as GET, handler as POST, handler as DELETE };
100+
```
101+
102+
## Nuxt Usage
103+
104+
```typescript
105+
// server/api/mcp/[transport].ts
106+
107+
import { createMcpHandler } from "mcp-handler";
108+
import { getHeader, defineEventHandler, fromWebHandler } from "h3";
109+
import { z } from "zod";
99110

111+
const handler = createMcpHandler((server) => {
112+
server.tool(
113+
"roll_dice",
114+
"Rolls an N-sided die",
115+
{
116+
sides: z.number().int().min(2)
117+
},
118+
async ({ sides }) => {
119+
const value = 1 + Math.floor(Math.random() * sides)
120+
return {
121+
content: [{ type: "text", text: `🎲 You rolled a ${value}!` }]
122+
}
123+
}
124+
)
125+
}, {
126+
// Optional server options
127+
});
100128

129+
export default fromWebHandler(handler);
101130
```
102131

103132
## Connecting to your MCP server via stdio

0 commit comments

Comments
 (0)