Skip to main content
Glama
kimhailey

TypeScript MCP Server Boilerplate

by kimhailey

my-mcp-server (Vercel Β· Streamable HTTP)

Next.js App Router 와 mcp-handler μœ„μ—μ„œ λ™μž‘ν•˜λŠ” Vercel λ°°ν¬ν˜• MCP μ„œλ²„μž…λ‹ˆλ‹€. κΈ°μ‘΄ StdioServerTransport 기반 둜컬 μ„œλ²„λ₯Ό Streamable HTTP 트랜슀포트둜 μ΄μ „ν•˜μ—¬ μž„μ˜μ˜ MCP ν΄λΌμ΄μ–ΈνŠΈ(Cursor, Claude Desktop, MCP Inspector λ“±) μ—μ„œ μ›κ²©μœΌλ‘œ ν˜ΈμΆœν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ•„ν‚€ν…μ²˜

MCP Client (Cursor / Inspector)
       β”‚  Streamable HTTP
       β”‚  + x-hf-token header (선택)
       β–Ό
Next.js App Router (on Vercel)
  app/api/[transport]/route.ts
       β”‚
       β–Ό
createMcpHandler ─► McpServer
  β”œβ”€ tools: greet / calculate / time / geocode / weather / generate-image
  β”œβ”€ prompts: code-review
  └─ resources: server-info

[transport] 동적 μ„Έκ·Έλ¨ΌνŠΈλ₯Ό μ‚¬μš©ν•΄ λ§€ μš”μ²­λ§ˆλ‹€ ν•Έλ“€λŸ¬λ₯Ό μƒˆλ‘œ λ§Œλ“€κ³ , μš”μ²­ 헀더 (x-hf-token) 와 ν™˜κ²½λ³€μˆ˜(HF_TOKEN) λ₯Ό ν΄λ‘œμ €λ‘œ μΊ‘μ²˜ν•΄ generate-image 도ꡬ에 μ „λ‹¬ν•©λ‹ˆλ‹€.

Related MCP server: TypeScript MCP Server Boilerplate

ν”„λ‘œμ νŠΈ ꡬ쑰

.
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── [transport]/
β”‚   β”‚       └── route.ts   # MCP HTTP μ—”λ“œν¬μΈνŠΈ
β”‚   β”œβ”€β”€ layout.tsx
β”‚   └── page.tsx           # μ•ˆλ‚΄μš© 정적 νŽ˜μ΄μ§€
β”œβ”€β”€ next.config.mjs
β”œβ”€β”€ next-env.d.ts
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── .env.example

λΉ λ₯Έ μ‹œμž‘

1. μ˜μ‘΄μ„± μ„€μΉ˜

npm install

2. ν™˜κ²½λ³€μˆ˜ μ„€μ • (선택)

generate-image 도ꡬλ₯Ό μ‚¬μš©ν•  κ³„νšμ΄λΌλ©΄ .env.example 을 .env.local 둜 λ³΅μ‚¬ν•œ λ’€ HuggingFace 토큰을 μ±„μ›Œ λ„£μŠ΅λ‹ˆλ‹€.

cp .env.example .env.local
# 그리고 HF_TOKEN=hf_xxx... 둜 μˆ˜μ •

ν™˜κ²½λ³€μˆ˜κ°€ 없어도 ν΄λΌμ΄μ–ΈνŠΈκ°€ λ§€ μš”μ²­λ§ˆλ‹€ x-hf-token 헀더λ₯Ό 보내면 λ™μž‘ν•©λ‹ˆλ‹€.

3. 둜컬 μ‹€ν–‰

npm run dev

κΈ°λ³Έ μ—”λ“œν¬μΈνŠΈ:

4. MCP Inspector 둜 검증

npx @modelcontextprotocol/inspector@latest

Inspector UI μ—μ„œ:

  1. Transport: Streamable HTTP

  2. URL: http://localhost:3000/api/mcp

  3. (선택) Custom Headers 에 x-hf-token: hf_xxx... μΆ”κ°€

  4. Connect β†’ List Tools β†’ 각 도ꡬ 호좜 ν…ŒμŠ€νŠΈ

ν΄λΌμ΄μ–ΈνŠΈ μ—°κ²°

Cursor (./.cursor/mcp.json)

{
    "mcpServers": {
        "my-mcp-server": {
            "url": "https://<your-app>.vercel.app/api/mcp",
            "headers": {
                "x-hf-token": "hf_xxx..."
            }
        }
    }
}

url 만 있으면 5개 도ꡬ(greet/calculate/time/geocode/weather)λŠ” 정상 λ™μž‘ν•©λ‹ˆλ‹€. generate-image λ₯Ό μ‚¬μš©ν•˜λ €λ©΄ headers.x-hf-token λ˜λŠ” μ„œλ²„μΈ‘ HF_TOKEN ν™˜κ²½λ³€μˆ˜ 쀑 ν•˜λ‚˜κ°€ λ°˜λ“œμ‹œ ν•„μš”ν•©λ‹ˆλ‹€.

Streamable HTTP 미지원 ν΄λΌμ΄μ–ΈνŠΈ (mcp-remote λΈŒλ¦Ώμ§€)

{
    "mcpServers": {
        "my-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-remote",
                "https://<your-app>.vercel.app/api/mcp",
                "--header",
                "x-hf-token:hf_xxx..."
            ]
        }
    }
}

Vercel 배포

방법 1: Vercel CLI

npm i -g vercel
vercel

방법 2: GitHub 연동

  1. GitHub μ €μž₯μ†Œμ— ν‘Έμ‹œ

  2. https://vercel.com/new μ—μ„œ μ €μž₯μ†Œ 선택

  3. Framework Preset: Next.js (μžλ™ 감지)

  4. Environment Variables μ—μ„œ (선택) HF_TOKEN μΆ”κ°€

  5. Deploy

배포가 μ™„λ£Œλ˜λ©΄ https://<your-app>.vercel.app/api/mcp κ°€ MCP μ—”λ“œν¬μΈνŠΈμž…λ‹ˆλ‹€.

λ“±λ‘λœ 도ꡬ

이름

μ„€λͺ…

greet

이름과 μ–Έμ–΄(ko/en)둜 인사말 생성

calculate

두 숫자 사칙연산 (add/subtract/multiply/divide)

time

νƒ€μž„μ‘΄λ³„ ν˜„μž¬ μ‹œκ°„

geocode

Open-Meteo 둜 λ„μ‹œλͺ… β†’ μœ„κ²½λ„ 쑰회

weather

Open-Meteo 둜 μœ„κ²½λ„ β†’ ν˜„μž¬ 날씨 쑰회

generate-image

HuggingFace FLUX.1-schnell 이미지 생성 (x-hf-token λ˜λŠ” HF_TOKEN)

ν”„λ‘¬ν”„νŠΈ / λ¦¬μ†ŒμŠ€

  • ν”„λ‘¬ν”„νŠΈ code-review: μ½”λ“œλ₯Ό μž…λ ₯λ°›μ•„ μ‹œλ‹ˆμ–΄ μ—”μ§€λ‹ˆμ–΄ κ΄€μ μ˜ 체계적 리뷰 λ©”μ‹œμ§€ 생성

  • λ¦¬μ†ŒμŠ€ server-info (mcp://my-mcp-server/info): μ„œλ²„ 메타데이터(JSON)

HF_TOKEN 처리 μ •μ±…

x-hf-token 헀더 ──(있으면 μ‚¬μš©)──► HuggingFace Inference
       β”‚ (μ—†μŒ)
       β–Ό
HF_TOKEN ν™˜κ²½λ³€μˆ˜ ──(있으면 μ‚¬μš©)──► HuggingFace Inference
       β”‚ (μ—†μŒ)
       β–Ό
generate-image 도ꡬ가 λͺ…ν™•ν•œ μ—λŸ¬ λ©”μ‹œμ§€ λ°˜ν™˜

헀더가 μš°μ„ μ΄λ―€λ‘œ 동일 배포 μΈμŠ€ν„΄μŠ€λ₯Ό μ—¬λŸ¬ μ‚¬μš©μžκ°€ 각자의 ν† ν°μœΌλ‘œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

슀크립트

  • npm run dev: 둜컬 개발 μ„œλ²„

  • npm run build: ν”„λ‘œλ•μ…˜ λΉŒλ“œ

  • npm run start: λΉŒλ“œ κ²°κ³Ό μ‹€ν–‰

  • npm run lint: Next.js lint

참고 자료

λΌμ΄μ„ μŠ€

MIT

Install Server
F
license - not found
A
quality
C
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
–Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kimhailey/my-mcp-server-260528'

If you have feedback or need assistance with the MCP directory API, please join our Discord server