Skip to content

Commit ab4c177

Browse files
committed
initial
1 parent 2dd5c40 commit ab4c177

File tree

5 files changed

+532
-366
lines changed

5 files changed

+532
-366
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Run an MCP Server on Vercel
22

3+
**Uses [Vercel MCP Adapter](https://github.com/vercel/vercel/mcp-adapter/tree/main)**
4+
35
## Usage
46

57
Update `api/server.ts` with your tools, prompts, and resources following the [MCP TypeScript SDK documentation](https://github.com/modelcontextprotocol/typescript-sdk/tree/main?tab=readme-ov-file#server).
@@ -8,9 +10,9 @@ Update `api/server.ts` with your tools, prompts, and resources following the [MC
810

911
## Notes for running on Vercel
1012

11-
- Requires a Redis attached to the project under `process.env.REDIS_URL`
13+
- To use the SSE transport, requires a Redis attached to the project under `process.env.REDIS_URL`
1214
- Make sure you have [Fluid compute](https://vercel.com/docs/functions/fluid-compute) enabled for efficient execution
13-
- After enabling Fluid compute, open `vercel.json` and adjust max duration to 800 if you using a Vercel Pro or Enterprise account
15+
- After enabling Fluid compute, open `app/server.ts` and adjust `maxDuration` to 800 if you using a Vercel Pro or Enterprise account
1416
- [Deploy the MCP template](https://vercel.com/templates/other/model-context-protocol-mcp-with-vercel-functions)
1517

1618
## Sample Client

api/server.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
import { z } from "zod";
2-
import { initializeMcpApiHandler } from "../lib/mcp-api-handler";
2+
import createMcpApiHandler from "@vercel/mcp-adapter/next";
33

4-
const handler = initializeMcpApiHandler(
5-
(server) => {
6-
// Add more tools, resources, and prompts here
7-
server.tool("echo", { message: z.string() }, async ({ message }) => ({
8-
content: [{ type: "text", text: `Tool echo: ${message}` }],
9-
}));
10-
},
11-
{
12-
capabilities: {
13-
tools: {
14-
echo: {
15-
description: "Echo a message",
16-
},
17-
},
18-
},
19-
}
20-
);
4+
const handler = createMcpApiHandler((server) => {
5+
server.tool("echo", { message: z.string() }, async ({ message }) => ({
6+
content: [{ type: "text", text: `Tool echo: ${message}` }],
7+
}));
8+
});
219

22-
export default handler;
10+
export { handler as GET, handler as POST, handler as DELETE };

lib/mcp-api-handler.ts

Lines changed: 0 additions & 329 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
"license": "ISC",
1212
"packageManager": "[email protected]+sha512.c85cd21b6da10332156b1ca2aa79c0a61ee7ad2eb0453b88ab299289e9e8ca93e6091232b25c07cbf61f6df77128d9c849e5c9ac6e44854dbd211c49f3a67adc",
1313
"dependencies": {
14-
"@modelcontextprotocol/sdk": "^1.10.2",
15-
"content-type": "^1.0.5",
16-
"raw-body": "^3.0.0",
17-
"redis": "^4.7.0",
14+
"@vercel/mcp-adapter": "^0.2.1",
1815
"zod": "^3.24.2"
1916
},
2017
"devDependencies": {

0 commit comments

Comments
 (0)