https://github.com/stainless-api/vercel-mcp-template
Template for hosting a remote MCP server in Vercel.
https://github.com/stainless-api/vercel-mcp-template
Last synced: 10 months ago
JSON representation
Template for hosting a remote MCP server in Vercel.
- Host: GitHub
- URL: https://github.com/stainless-api/vercel-mcp-template
- Owner: stainless-api
- Created: 2025-08-04T15:08:55.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-08T21:27:45.000Z (10 months ago)
- Last Synced: 2025-08-10T00:36:58.062Z (10 months ago)
- Language: TypeScript
- Size: 28.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Vercel MCP Server Template
This template enables you to run a Stainless-generated MCP (Model Context Protocol) server as a remote MCP server on Vercel using the mcp-handler package.
## Overview
This template provides a Next.js-based serverless application that hosts your MCP tools on Vercel with bearer token authentication. The main entry point is `app/[transport]/route.ts` which handles MCP protocol requests.
## Implementation Requirements
### 1. Replace Package Imports
In `app/[transport]/route.ts`, you need to replace three placeholder imports with your Stainless-generated packages:
```typescript
// Replace these imports:
import endpoints from 'YOUR_MCP_PACKAGE/tools';
import { initServer } from 'YOUR_MCP_PACKAGE/server';
import YourSDK from 'YOUR_SDK_PACKAGE';
```
### 2. Implement Token Verification
The `verifyToken` function must be implemented to validate bearer tokens with your identity provider:
```typescript
const verifyToken = async (req: Request, bearerToken?: string): Promise => {
// TODO: Implement your IdP integration here
// Should return:
// {
// token: string, // The validated token
// clientId: string, // Client identifier
// scopes: string[] // Array of authorized scopes
// }
// if valid, or undefined if invalid
};
```
### 3. Initialize Your Client
Replace the placeholder client initialization with your actual SDK client:
```typescript
// Replace:
const client = YourSDK(
auth: authInfo.token,
)
// With your actual client initialization:
const client = new SDK({
auth: authInfo.token,
// ... other configuration
});
```