Skip to content

Commit 201a1c7

Browse files
authored
Move package from @vercel/mcp-adapter to mcp-handler (#74)
* .changeset/violet-squids-camp.md package.json * .changeset/violet-squids-camp.md * CHANGELOG.md * .changeset/evil-things-check.md .changeset/ripe-mails-doubt.md README.md examples/auth/route.ts package.json src/cli/index.ts
1 parent 488dfe4 commit 201a1c7

File tree

8 files changed

+69
-57
lines changed

8 files changed

+69
-57
lines changed

.changeset/evil-things-check.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
"@vercel/mcp-adapter": minor
2+
"mcp-handler": minor
33
---
44

55
Refactor packaging and make withMcpAuth stable

.changeset/ripe-mails-doubt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
"@vercel/mcp-adapter": minor
2+
"mcp-handler": minor
33
---
44

55
Add RFC 9728 OAuth Protected Resource Metadata handler

.changeset/violet-squids-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"mcp-handler": major
3+
---
4+
5+
Move package from @vercle/mcp-adapter to mcp-handler

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @vercel/mcp-adapter
1+
# mcp-handler
22

33
## 0.11.2
44

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# @vercel/mcp-adapter
1+
# mcp-handler
22

33
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.
44

55
## Installation
66

77
```bash
8-
npm install @vercel/mcp-adapter @modelcontextprotocol/sdk
8+
npm install mcp-handler @modelcontextprotocol/sdk
99
# or
10-
yarn add @vercel/mcp-adapter @modelcontextprotocol/sdk
10+
yarn add mcp-handler @modelcontextprotocol/sdk
1111
# or
12-
pnpm add @vercel/mcp-adapter @modelcontextprotocol/sdk
12+
pnpm add mcp-handler @modelcontextprotocol/sdk
1313
# or
14-
bun add @vercel/mcp-adapter @modelcontextprotocol/sdk
14+
bun add mcp-handler @modelcontextprotocol/sdk
1515
```
1616

1717
## Next.js Usage
1818

1919
```typescript
2020
// app/api/[transport]/route.ts
21-
import { createMcpHandler } from "@vercel/mcp-adapter";
21+
import { createMcpHandler } from "mcp-handler";
2222
const handler = createMcpHandler(
2323
(server) => {
2424
server.tool(
@@ -159,7 +159,7 @@ The MCP adapter supports the [MCP Authorization Specification](https://modelcont
159159

160160
```typescript
161161
// app/api/[transport]/route.ts
162-
import { createMcpHandler, withMcpAuth } from "@vercel/mcp-adapter";
162+
import { createMcpHandler, withMcpAuth } from "mcp-handler";
163163

164164
// Create your handler as normal
165165
const handler = createMcpHandler(
@@ -235,7 +235,7 @@ Create a new file at `app/.well-known/oauth-protected-resource/route.ts`:
235235
import {
236236
protectedResourceHandler,
237237
metadataCorsOptionsRequestHandler,
238-
} from "@vercel/mcp-adapter";
238+
} from "mcp-handler";
239239

240240
const handler = protectedResourceHandler({
241241
// Specify the Issuer URL of the associated Authorization Server

examples/auth/route.ts

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types";
2-
import { createMcpHandler, experimental_withMcpAuth as withMcpAuth } from "@vercel/mcp-adapter";
2+
import {
3+
createMcpHandler,
4+
experimental_withMcpAuth as withMcpAuth,
5+
} from "mcp-handler";
36
import { z } from "zod";
47

58
// Define the handler with proper parameter validation
69
const handler = createMcpHandler(
7-
server => {
10+
(server) => {
811
server.tool(
9-
'echo',
10-
'Echo a message back with authentication info',
12+
"echo",
13+
"Echo a message back with authentication info",
1114
{
12-
message: z.string().describe('The message to echo back')
15+
message: z.string().describe("The message to echo back"),
1316
},
1417
async ({ message }, extra) => {
1518
return {
1619
content: [
1720
{
18-
type: 'text',
19-
text: `Echo: ${message}${extra.authInfo?.token ? ` (from ${extra.authInfo.clientId})` : ''}`,
21+
type: "text",
22+
text: `Echo: ${message}${
23+
extra.authInfo?.token
24+
? ` (from ${extra.authInfo.clientId})`
25+
: ""
26+
}`,
2027
},
2128
],
2229
};
@@ -27,17 +34,17 @@ const handler = createMcpHandler(
2734
{
2835
capabilities: {
2936
auth: {
30-
type: 'bearer',
37+
type: "bearer",
3138
required: true,
3239
},
3340
},
3441
},
3542
// Route configuration
3643
{
37-
streamableHttpEndpoint: '/mcp',
38-
sseEndpoint: '/sse',
39-
sseMessageEndpoint: '/message',
40-
basePath: '/api/mcp',
44+
streamableHttpEndpoint: "/mcp",
45+
sseEndpoint: "/sse",
46+
sseMessageEndpoint: "/message",
47+
basePath: "/api/mcp",
4148
redisUrl: process.env.REDIS_URL,
4249
}
4350
);
@@ -46,38 +53,37 @@ const handler = createMcpHandler(
4653
* Verify the bearer token and return auth information
4754
* In a real implementation, this would validate against your auth service
4855
*/
49-
const verifyToken = async (req: Request, bearerToken?: string): Promise<AuthInfo | undefined> => {
50-
if (!bearerToken) return undefined;
51-
52-
// TODO: Replace with actual token verification logic
53-
// This is just an example implementation
54-
const isValid = bearerToken.startsWith('__TEST_VALUE__');
55-
56-
if (!isValid) return undefined;
57-
58-
return {
59-
token: bearerToken,
60-
scopes: ['read:messages', 'write:messages'],
61-
clientId: 'example-client',
62-
extra: {
63-
userId: 'user-123',
64-
// Add any additional user/client information here
65-
permissions: ['user'],
66-
timestamp: new Date().toISOString()
67-
}
68-
};
69-
}
56+
const verifyToken = async (
57+
req: Request,
58+
bearerToken?: string
59+
): Promise<AuthInfo | undefined> => {
60+
if (!bearerToken) return undefined;
61+
62+
// TODO: Replace with actual token verification logic
63+
// This is just an example implementation
64+
const isValid = bearerToken.startsWith("__TEST_VALUE__");
65+
66+
if (!isValid) return undefined;
67+
68+
return {
69+
token: bearerToken,
70+
scopes: ["read:messages", "write:messages"],
71+
clientId: "example-client",
72+
extra: {
73+
userId: "user-123",
74+
// Add any additional user/client information here
75+
permissions: ["user"],
76+
timestamp: new Date().toISOString(),
77+
},
78+
};
79+
};
7080

7181
// Create the auth handler with required scopes
72-
const authHandler = withMcpAuth(
73-
handler,
74-
verifyToken,
75-
{
76-
required: true,
77-
requiredScopes: ['read:messages'],
78-
resourceMetadataPath: '/.well-known/oauth-protected-resource'
79-
}
80-
);
82+
const authHandler = withMcpAuth(handler, verifyToken, {
83+
required: true,
84+
requiredScopes: ["read:messages"],
85+
resourceMetadataPath: "/.well-known/oauth-protected-resource",
86+
});
8187

8288
// Export the handler for both GET and POST methods
8389
export { authHandler as GET, authHandler as POST };

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"name": "@vercel/mcp-adapter",
2+
"name": "mcp-handler",
33
"version": "0.11.2",
44
"description": "Vercel MCP Adapter for Next.js and other frameworks",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"type": "commonjs",
88
"bin": {
99
"create-mcp-route": "./dist/cli/index.js",
10+
"mcp-handler": "./dist/cli/index.js",
1011
"@vercel/mcp-adapter": "./dist/cli/index.js"
1112
},
1213
"exports": {

src/cli/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import chalk from "chalk";
77

88
const program = new Command();
99

10-
const ROUTE_TEMPLATE = `import { createMcpHandler } from '@vercel/mcp-adapter';
10+
const ROUTE_TEMPLATE = `import { createMcpHandler } from 'mcp-handler';
1111
import { z } from 'zod';
1212
1313
const handler = createMcpHandler(
@@ -66,7 +66,7 @@ async function installDependencies(
6666
packageManager: "npm" | "pnpm" | "yarn" | "bun"
6767
) {
6868
const execSync = (await import("node:child_process")).execSync;
69-
const dependencies = ["@vercel/mcp-adapter", "zod"];
69+
const dependencies = ["mcp-handler", "zod"];
7070

7171
const commands = {
7272
npm: `npm install ${dependencies.join(" ")}`,
@@ -125,7 +125,7 @@ async function init() {
125125
}
126126

127127
program
128-
.name("@vercel/mcp-adapter")
128+
.name("mcp-handler")
129129
.description("Initialize MCP route handler in your Next.js project")
130130
.action(init);
131131

0 commit comments

Comments
 (0)