Skip to content

Commit d4c4920

Browse files
authored
Hono MCP server (#1200)
1 parent 2d58f39 commit d4c4920

File tree

6 files changed

+1126
-0
lines changed

6 files changed

+1126
-0
lines changed

starter/hono-mcp/.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# dev
2+
.yarn/
3+
!.yarn/releases
4+
.vscode/*
5+
!.vscode/launch.json
6+
!.vscode/*.code-snippets
7+
.idea/workspace.xml
8+
.idea/usage.statistics.xml
9+
.idea/shelf
10+
11+
# deps
12+
node_modules/
13+
14+
# env
15+
.env
16+
.env.production
17+
18+
# logs
19+
logs/
20+
*.log
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
pnpm-debug.log*
25+
lerna-debug.log*
26+
27+
# misc
28+
.DS_Store
29+
.vercel
30+
31+
dist

starter/hono-mcp/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Hono Remote MCP Server Example
2+
3+
This example demonstrates how to build a Model Context Protocol (MCP) server using [Hono](https://hono.dev/), a lightweight web framework, and deploy it to Vercel. The server exposes mathematical operation tools (add, subtract, multiply, divide) that can be consumed by MCP clients.
4+
5+
## Demo
6+
7+
To connect your MCP client to the server, use: [https://hono-mcp-demo.vercel.app/mcp](https://hono-mcp-demo.vercel.app/mcp)
8+
9+
You can also visit [https://hono-mcp-demo.vercel.app](https://hono-mcp-demo.vercel.app) in your browser.
10+
11+
## What is MCP?
12+
13+
The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). This example shows how to create an MCP server that exposes tools as HTTP endpoints.
14+
15+
## Features
16+
17+
- **Math Operations**: Four basic calculator tools (add, subtract, multiply, divide)
18+
- **MCP Handler**: Uses `mcp-handler` library for easy MCP server creation
19+
- **Type Safety**: Built with TypeScript and Zod for runtime validation
20+
- **Vercel Deployment**: Optimized for serverless deployment on Vercel
21+
22+
## Prerequisites
23+
24+
- [Vercel CLI](https://vercel.com/docs/cli) installed globally
25+
26+
## Development
27+
28+
To develop locally:
29+
30+
```
31+
npm install
32+
vc dev
33+
```
34+
35+
```
36+
open http://localhost:3000
37+
```
38+
39+
## Build
40+
41+
To build locally:
42+
43+
```
44+
npm install
45+
vc build
46+
```
47+
48+
## Deployment
49+
50+
To deploy:
51+
52+
```
53+
npm install
54+
vc deploy
55+
```
56+
57+
## API Endpoints
58+
59+
- **GET `/`** - Welcome endpoint with server information
60+
- **POST `/mcp/*`** - MCP protocol endpoint for tool execution
61+
62+
## Available Tools
63+
64+
The server exposes the following MCP tools:
65+
66+
- **add** - Add two numbers
67+
- **subtract** - Subtract two numbers
68+
- **multiply** - Multiply two numbers
69+
- **divide** - Divide two numbers (with zero-division protection)
70+
71+
## Using the MCP Server
72+
73+
Once deployed, you can connect to this MCP server from any MCP-compatible client by pointing to the `/mcp` endpoint. The server handles the MCP protocol transport and tool execution automatically.

starter/hono-mcp/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "hono-mcp",
3+
"type": "module",
4+
"dependencies": {
5+
"@modelcontextprotocol/sdk": "^1.17.3",
6+
"hono": "^4.9.2",
7+
"mcp-handler": "^1.0.1",
8+
"zod": "^3"
9+
},
10+
"devDependencies": {
11+
"@types/node": "^20.11.17",
12+
"typescript": "^5.8.3"
13+
}
14+
}

0 commit comments

Comments
 (0)