Skip to content

Commit f00b0ef

Browse files
jem-computerclaude
andcommitted
feat(examples): transform hono-mcp server to Vengabus party theme
Transform the generic example server into a fun Vengabus-themed MCP server with: - Replace generic tools with party-themed tools (party capacity calculator, vengabus schedule) - Update resources to use party-themed URIs and content - Replace generic prompts with party invitations and announcements - Fix resource URI handling to strip trailing slashes - Fix TypeScript errors with proper resource template typing - Use docs:// protocol for party manual resource ๐Ÿค– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e0743c3 commit f00b0ef

File tree

1 file changed

+133
-78
lines changed

1 file changed

+133
-78
lines changed

โ€Žexamples/servers/hono-mcp/src/index.ts

Lines changed: 133 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { McpServer, type ReadResourceTemplateCallback, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'
1+
import { McpServer, ResourceTemplate, type Variables } from '@modelcontextprotocol/sdk/server/mcp.js'
22
import { StreamableHTTPTransport } from '@hono/mcp'
33
import { Hono } from 'hono'
44
import { z } from 'zod'
@@ -17,19 +17,27 @@ app.use(
1717

1818
// Your MCP server implementation
1919
const mcpServer = new McpServer({
20-
name: 'my-mcp-server',
20+
name: 'vengabus-mcp-server',
2121
version: '1.0.0',
2222
})
2323

2424
mcpServer.registerTool(
25-
'add',
25+
'calculate_party_capacity',
2626
{
27-
title: 'Addition Tool',
28-
description: 'Add two numbers',
29-
inputSchema: { a: z.number(), b: z.number() },
27+
title: 'Party Bus Capacity Calculator',
28+
description: 'Calculate how many people can fit on the Vengabus',
29+
inputSchema: {
30+
busCount: z.number().describe('Number of Vengabuses'),
31+
peoplePerBus: z.number().describe('People per bus'),
32+
},
3033
},
31-
async ({ a, b }) => ({
32-
content: [{ type: 'text', text: String(a + b) }],
34+
async ({ busCount, peoplePerBus }) => ({
35+
content: [
36+
{
37+
type: 'text',
38+
text: `๐ŸšŒ ${busCount} Vengabuses can transport ${busCount * peoplePerBus} party people! The wheels of steel are turning! ๐ŸŽ‰`,
39+
},
40+
],
3341
}),
3442
)
3543

@@ -48,7 +56,22 @@ mcpServer.registerTool(
4856
content: [
4957
{
5058
type: 'text',
51-
text: `Next Vengabus: imminent. Current user's route: New York to San Francisco. Route name: "Intercity Disco".`,
59+
text: `๐ŸšŒ BOOM BOOM BOOM BOOM! Next Vengabus: IMMINENT! ๐ŸŽ‰
60+
61+
Current Route: "Intercity Disco Express"
62+
From: New York
63+
To: IBIZA - THE MAGIC ISLAND! โœจ
64+
65+
Schedule:
66+
- Departure: When the beat drops
67+
- Via: San Francisco (quick party stop)
68+
- Arrival: When the sun comes up
69+
70+
Status: The party bus is jumping!
71+
Passengers: Maximum capacity!
72+
BPM: 142 and rising!
73+
74+
We're going to Ibiza! Back to the island! ๐Ÿ๏ธ`,
5275
},
5376
],
5477
}
@@ -58,130 +81,162 @@ mcpServer.registerTool(
5881
// Register sample resources
5982
mcpServer.registerResource(
6083
'config',
61-
'config://app',
84+
'config://vengabus',
6285
{
63-
title: 'Application Configuration',
64-
description: 'Current application configuration settings',
86+
title: 'Vengabus Fleet Configuration',
87+
description: 'Current Vengabus fleet settings and party parameters',
6588
mimeType: 'application/json',
6689
},
67-
async (uri: URL) => ({
68-
contents: [
69-
{
70-
uri: uri.href,
71-
mimeType: 'application/json',
72-
text: JSON.stringify(
73-
{
74-
version: '1.0.0',
75-
environment: 'test',
76-
features: {
77-
vengabus: true,
78-
calculator: true,
90+
async (uri: URL) => {
91+
const normalizedUri = uri.href.replace(/\/$/, '')
92+
return {
93+
contents: [
94+
{
95+
uri: normalizedUri,
96+
mimeType: 'application/json',
97+
text: JSON.stringify(
98+
{
99+
version: '1.0.0',
100+
fleet: 'intercity-disco',
101+
features: {
102+
bassBoost: true,
103+
strobeEnabled: true,
104+
maxBPM: 160,
105+
wheelsOfSteel: 'turning',
106+
},
107+
routes: ['New York to Ibiza', 'Back to the Magic Island', 'Like an Intercity Disco', 'The place to be'],
79108
},
80-
},
81-
null,
82-
2,
83-
),
84-
},
85-
],
86-
}),
109+
null,
110+
2,
111+
),
112+
},
113+
],
114+
}
115+
},
87116
)
88117

89118
mcpServer.registerResource(
90119
'readme',
91-
'file://readme.md',
120+
'docs://party-manual.md',
92121
{
93-
title: 'README',
94-
description: 'Server documentation',
122+
title: 'Vengabus Party Manual',
123+
description: 'Official guide to the Vengabus experience',
95124
mimeType: 'text/markdown',
96125
},
97-
async (uri: URL) => ({
98-
contents: [
99-
{
100-
uri: uri.href,
101-
mimeType: 'text/markdown',
102-
text: '# Test MCP Server\n\nThis is a test server for the use-mcp integration tests.\n\n## Features\n- Addition tool\n- Vengabus schedule checker\n- Sample resources\n- Sample prompts',
103-
},
104-
],
126+
() => ({
127+
128+
contents: [
129+
{
130+
uri: 'docs://party-manual.md',
131+
mimeType: 'text/markdown',
132+
text: "# ๐ŸšŒ Vengabus MCP Server\n\nBOOM BOOM BOOM BOOM! Welcome aboard the Vengabus! We like to party!\n\n## Features\n- ๐ŸŽ‰ Party capacity calculator - How many can we take to Ibiza?\n- ๐Ÿ• Vengabus schedule checker - Next stop: The Magic Island!\n- ๐ŸŽต Fleet configuration with maximum bass boost\n- ๐ŸŒŸ Party statistics tracker (BPM, passengers, energy levels)\n\n## Routes\n- New York to Ibiza (via San Francisco)\n- Back to the Magic Island\n- Like an Intercity Disco\n- The place to be\n\n## Current Status\nThe wheels of steel are turning, and traffic lights are burning!\nWe're going to Ibiza! Woah! We're going to Ibiza!\n\n*Up, up and away we go!*",
133+
}
134+
]
105135
}),
106136
)
107137

108138
// Register a resource template
109139
mcpServer.registerResource(
110140
'stats',
111-
new ResourceTemplate('data://stats/{type}', { list: undefined }),
141+
new ResourceTemplate('party://stats/{metric}', { list: undefined }),
112142
{
113-
title: 'Statistics Data',
114-
description: 'Get statistics for different types',
143+
title: 'Vengabus Party Statistics',
144+
description: 'Get party metrics (bpm, passengers, energy)',
115145
mimeType: 'application/json',
116146
},
117-
// @ts-expect-error - type is missing in the callback
118-
async (uri: URL, { type }) => ({
119-
contents: [
120-
{
121-
uri: uri.href,
122-
mimeType: 'application/json',
123-
text: JSON.stringify(
124-
{
125-
type: type,
126-
count: Math.floor(Math.random() * 100),
127-
lastUpdated: new Date().toISOString(),
128-
},
129-
null,
130-
2,
131-
),
132-
},
133-
],
134-
}),
147+
async (uri: URL, variables: Variables) => {
148+
const metric = variables.metric as string
149+
return {
150+
contents: [
151+
{
152+
uri: uri.href,
153+
mimeType: 'application/json',
154+
text: JSON.stringify(
155+
{
156+
metric: metric,
157+
value:
158+
metric === 'bpm'
159+
? 140 + Math.floor(Math.random() * 20)
160+
: metric === 'passengers'
161+
? Math.floor(Math.random() * 50) + 20
162+
: metric === 'energy'
163+
? Math.floor(Math.random() * 100)
164+
: 0,
165+
unit:
166+
metric === 'bpm'
167+
? 'beats per minute'
168+
: metric === 'passengers'
169+
? 'party people'
170+
: metric === 'energy'
171+
? 'party power %'
172+
: 'unknown',
173+
status: 'The party is jumping!',
174+
lastUpdated: new Date().toISOString(),
175+
},
176+
null,
177+
2,
178+
),
179+
},
180+
],
181+
}
182+
},
135183
)
136184

137185
// Register sample prompts
138186
mcpServer.registerPrompt(
139-
'greeting',
187+
'party_invitation',
140188
{
141-
title: 'Generate Greeting',
142-
description: 'Generate a greeting message',
189+
title: 'Vengabus Party Invitation',
190+
description: 'Generate a party invitation for the Vengabus',
143191
argsSchema: {
144-
name: z.string().describe('Name of the person to greet'),
145-
style: z.string().optional().describe('Style of greeting (formal/casual)'),
192+
name: z.string().describe('Name of the party person'),
193+
destination: z.string().optional().describe('Where the Vengabus is heading'),
146194
},
147195
},
148-
({ name, style }) => ({
196+
({ name, destination }) => ({
149197
messages: [
150198
{
151199
role: 'user',
152200
content: {
153201
type: 'text',
154-
text: `Generate a ${style || 'casual'} greeting for ${name}`,
202+
text: `Create a party invitation for ${name} to join the Vengabus${destination ? ` heading to ${destination}` : ''}`,
155203
},
156204
},
157205
{
158206
role: 'assistant',
159207
content: {
160208
type: 'text',
161-
text: style === 'formal' ? `Good day, ${name}. I hope this message finds you well.` : `Hey ${name}! How's it going?`,
209+
text: `๐ŸšŒ BOOM BOOM BOOM BOOM! Hey ${name}! ๐ŸŽ‰\n\nThe Vengabus is coming${destination ? ` and we're heading to ${destination}` : ''}!\n${destination?.toLowerCase().includes('ibiza') ? "WE'RE GOING TO IBIZA! Back to the Magic Island! ๐Ÿ๏ธ\n" : ''}\nWe like to party! We like, we like to party!\n\nThe wheels of steel are turning, and traffic lights are burning!\nSo if you like to party, get on and move your body!\n\n๐Ÿ“ Route: ${destination || 'New York โ†’ San Francisco โ†’ IBIZA!'}\n๐ŸŽต Departure: When everybody's jumping\n๐Ÿ‘— Dress code: Beach party ready\n๐ŸŽŸ๏ธ Ticket: Just bring your party spirit!\n\nHey now, hey now, hear what we say now - happiness is just around the corner!\n\n*The Vengabus is coming... and everybody's jumping!*`,
162210
},
163211
},
164212
],
165213
}),
166214
)
167215

168216
mcpServer.registerPrompt(
169-
'code_review',
217+
'party_announcement',
170218
{
171-
title: 'Code Review Template',
172-
description: 'Template for code review requests',
219+
title: 'Party Bus Announcement',
220+
description: 'Generate party-themed announcements for various occasions',
173221
argsSchema: {
174-
language: z.string().describe('Programming language'),
175-
focus: z.string().optional().describe('What to focus on (performance/security/style)'),
222+
event: z.string().describe('Type of event (deployment, release, milestone, etc.)'),
223+
details: z.string().optional().describe('Additional details about the event'),
176224
},
177225
},
178-
({ language, focus }) => ({
226+
({ event, details }) => ({
179227
messages: [
180228
{
181229
role: 'user',
182230
content: {
183231
type: 'text',
184-
text: `Please review the following ${language} code${focus ? ` with a focus on ${focus}` : ''}:`,
232+
text: `Create a party bus announcement for a ${event}${details ? `: ${details}` : ''}`,
233+
},
234+
},
235+
{
236+
role: 'assistant',
237+
content: {
238+
type: 'text',
239+
text: `๐ŸšŒ ATTENTION PARTY PEOPLE! ๐ŸŽ‰\n\n${event.toUpperCase()} ANNOUNCEMENT!\n\nThe party bus is making a special stop for this ${event}!\n${details ? `\n๐Ÿ“ข Details: ${details}\n` : ''}\n๐ŸŽŠ Status: Maximum celebration mode activated!\n๐Ÿ• Time: Right now!\n๐Ÿ“ Location: Wherever the party takes us!\n\nAll aboard for this incredible ${event}! The wheels are turning and we're ready to celebrate!\n\n*Honk honk! Let's party!* ๐ŸŽบ`,
185240
},
186241
},
187242
],

0 commit comments

Comments
ย (0)