chore: fix prettier formatting and update example server dependencies
- Fix formatting issues in cf-agents, hono-mcp, and test files - Update dependencies in example servers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b909730ae2
commit
e0743c35e4
6 changed files with 329 additions and 32 deletions
|
|
@ -12,7 +12,7 @@
|
|||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.13.0",
|
||||
"@modelcontextprotocol/sdk": "^1.13.3",
|
||||
"zod": "^3.25.67"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
13
examples/servers/cf-agents/pnpm-lock.yaml
generated
13
examples/servers/cf-agents/pnpm-lock.yaml
generated
|
|
@ -9,8 +9,8 @@ importers:
|
|||
.:
|
||||
dependencies:
|
||||
'@modelcontextprotocol/sdk':
|
||||
specifier: ^1.13.0
|
||||
version: 1.13.2
|
||||
specifier: ^1.13.3
|
||||
version: 1.13.3
|
||||
zod:
|
||||
specifier: ^3.25.67
|
||||
version: 3.25.67
|
||||
|
|
@ -443,8 +443,8 @@ packages:
|
|||
'@jridgewell/trace-mapping@0.3.9':
|
||||
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
|
||||
|
||||
'@modelcontextprotocol/sdk@1.13.2':
|
||||
resolution: {integrity: sha512-Vx7qOcmoKkR3qhaQ9qf3GxiVKCEu+zfJddHv6x3dY/9P6+uIwJnmuAur5aB+4FDXf41rRrDnOEGkviX5oYZ67w==}
|
||||
'@modelcontextprotocol/sdk@1.13.3':
|
||||
resolution: {integrity: sha512-bGwA78F/U5G2jrnsdRkPY3IwIwZeWUEfb5o764b79lb0rJmMT76TLwKhdNZOWakOQtedYefwIR4emisEMvInKA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
'@opentelemetry/api@1.9.0':
|
||||
|
|
@ -1314,13 +1314,14 @@ snapshots:
|
|||
'@jridgewell/resolve-uri': 3.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.5.2
|
||||
|
||||
'@modelcontextprotocol/sdk@1.13.2':
|
||||
'@modelcontextprotocol/sdk@1.13.3':
|
||||
dependencies:
|
||||
ajv: 6.12.6
|
||||
content-type: 1.0.5
|
||||
cors: 2.8.5
|
||||
cross-spawn: 7.0.6
|
||||
eventsource: 3.0.7
|
||||
eventsource-parser: 3.0.3
|
||||
express: 5.1.0
|
||||
express-rate-limit: 7.5.1(express@5.1.0)
|
||||
pkce-challenge: 5.0.0
|
||||
|
|
@ -1349,7 +1350,7 @@ snapshots:
|
|||
|
||||
agents@0.0.100(@cloudflare/workers-types@4.20250628.0)(react@19.1.0):
|
||||
dependencies:
|
||||
'@modelcontextprotocol/sdk': 1.13.2
|
||||
'@modelcontextprotocol/sdk': 1.13.3
|
||||
ai: 4.3.16(react@19.1.0)(zod@3.25.67)
|
||||
cron-schedule: 5.0.4
|
||||
nanoid: 5.1.5
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { McpAgent } from 'agents/mcp'
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
||||
import { z } from 'zod'
|
||||
import OAuthProvider, { OAuthHelpers } from '@cloudflare/workers-oauth-provider'
|
||||
import OAuthProvider, { type OAuthHelpers } from '@cloudflare/workers-oauth-provider'
|
||||
import { Hono } from 'hono'
|
||||
|
||||
// Define our MCP agent with tools
|
||||
|
|
@ -53,6 +53,95 @@ export class MyMCP extends McpAgent {
|
|||
return { content: [{ type: 'text', text: String(result) }] }
|
||||
},
|
||||
)
|
||||
|
||||
// Register sample resources using the agents framework API
|
||||
this.server.resource('calc://history', 'Calculation History', async () => ({
|
||||
contents: [
|
||||
{
|
||||
uri: 'calc://history',
|
||||
mimeType: 'application/json',
|
||||
text: JSON.stringify(
|
||||
{
|
||||
calculations: [
|
||||
{ operation: 'add', a: 5, b: 3, result: 8, timestamp: '2024-01-01T10:00:00Z' },
|
||||
{ operation: 'multiply', a: 4, b: 7, result: 28, timestamp: '2024-01-01T10:01:00Z' },
|
||||
],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
],
|
||||
}))
|
||||
|
||||
this.server.resource('calc://settings', 'Calculator Settings', async () => ({
|
||||
contents: [
|
||||
{
|
||||
uri: 'calc://settings',
|
||||
mimeType: 'application/json',
|
||||
text: JSON.stringify(
|
||||
{
|
||||
precision: 2,
|
||||
allowNegative: true,
|
||||
maxValue: 1000000,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
],
|
||||
}))
|
||||
|
||||
// Register a dynamic resource
|
||||
this.server.resource('calc://stats', 'Calculation Statistics', async () => ({
|
||||
contents: [
|
||||
{
|
||||
uri: 'calc://stats',
|
||||
mimeType: 'application/json',
|
||||
text: JSON.stringify(
|
||||
{
|
||||
totalCalculations: Math.floor(Math.random() * 100),
|
||||
lastUpdated: new Date().toISOString(),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
],
|
||||
}))
|
||||
|
||||
// Register sample prompts using the agents framework API
|
||||
this.server.prompt(
|
||||
'math_problem',
|
||||
'Generate a math problem',
|
||||
{
|
||||
difficulty: z.string(),
|
||||
topic: z.string().optional(),
|
||||
},
|
||||
async ({ difficulty, topic }) => ({
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: {
|
||||
type: 'text',
|
||||
text: `Generate a ${difficulty} math problem${topic ? ` about ${topic}` : ''}`,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
this.server.prompt('explain_calculation', 'Explain a calculation', { operation: z.string() }, async ({ operation }) => ({
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: {
|
||||
type: 'text',
|
||||
text: `Please explain how to perform ${operation} step by step with examples`,
|
||||
},
|
||||
},
|
||||
],
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@hono/mcp": "^0.1.0",
|
||||
"@modelcontextprotocol/sdk": "^1.13.1",
|
||||
"@modelcontextprotocol/sdk": "^1.13.3",
|
||||
"wrangler": "^4.21.0",
|
||||
"zod": "^3.25.67"
|
||||
}
|
||||
|
|
|
|||
17
examples/servers/hono-mcp/pnpm-lock.yaml
generated
17
examples/servers/hono-mcp/pnpm-lock.yaml
generated
|
|
@ -14,10 +14,10 @@ importers:
|
|||
devDependencies:
|
||||
'@hono/mcp':
|
||||
specifier: ^0.1.0
|
||||
version: 0.1.0(@modelcontextprotocol/sdk@1.13.1)(hono@4.8.2)
|
||||
version: 0.1.0(@modelcontextprotocol/sdk@1.13.3)(hono@4.8.2)
|
||||
'@modelcontextprotocol/sdk':
|
||||
specifier: ^1.13.1
|
||||
version: 1.13.1
|
||||
specifier: ^1.13.3
|
||||
version: 1.13.3
|
||||
wrangler:
|
||||
specifier: ^4.21.0
|
||||
version: 4.21.0
|
||||
|
|
@ -352,8 +352,8 @@ packages:
|
|||
'@jridgewell/trace-mapping@0.3.9':
|
||||
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
|
||||
|
||||
'@modelcontextprotocol/sdk@1.13.1':
|
||||
resolution: {integrity: sha512-8q6+9aF0yA39/qWT/uaIj6zTpC+Qu07DnN/lb9mjoquCJsAh6l3HyYqc9O3t2j7GilseOQOQimLg7W3By6jqvg==}
|
||||
'@modelcontextprotocol/sdk@1.13.3':
|
||||
resolution: {integrity: sha512-bGwA78F/U5G2jrnsdRkPY3IwIwZeWUEfb5o764b79lb0rJmMT76TLwKhdNZOWakOQtedYefwIR4emisEMvInKA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
accepts@2.0.0:
|
||||
|
|
@ -972,9 +972,9 @@ snapshots:
|
|||
|
||||
'@fastify/busboy@2.1.1': {}
|
||||
|
||||
'@hono/mcp@0.1.0(@modelcontextprotocol/sdk@1.13.1)(hono@4.8.2)':
|
||||
'@hono/mcp@0.1.0(@modelcontextprotocol/sdk@1.13.3)(hono@4.8.2)':
|
||||
dependencies:
|
||||
'@modelcontextprotocol/sdk': 1.13.1
|
||||
'@modelcontextprotocol/sdk': 1.13.3
|
||||
hono: 4.8.2
|
||||
|
||||
'@img/sharp-darwin-arm64@0.33.5':
|
||||
|
|
@ -1061,13 +1061,14 @@ snapshots:
|
|||
'@jridgewell/resolve-uri': 3.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.5.0
|
||||
|
||||
'@modelcontextprotocol/sdk@1.13.1':
|
||||
'@modelcontextprotocol/sdk@1.13.3':
|
||||
dependencies:
|
||||
ajv: 6.12.6
|
||||
content-type: 1.0.5
|
||||
cors: 2.8.5
|
||||
cross-spawn: 7.0.6
|
||||
eventsource: 3.0.7
|
||||
eventsource-parser: 3.0.2
|
||||
express: 5.1.0
|
||||
express-rate-limit: 7.5.1(express@5.1.0)
|
||||
pkce-challenge: 5.0.0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
||||
import { McpServer, type ReadResourceTemplateCallback, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'
|
||||
import { StreamableHTTPTransport } from '@hono/mcp'
|
||||
import { Hono } from 'hono'
|
||||
import { z } from 'zod'
|
||||
|
|
@ -42,7 +42,8 @@ mcpServer.registerTool(
|
|||
inputSchema: {},
|
||||
},
|
||||
async () => {
|
||||
await scheduler.wait(100 + Math.random() * 100)
|
||||
// Simulate some async work
|
||||
await new Promise((resolve) => setTimeout(resolve, 100 + Math.random() * 100))
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
|
|
@ -54,6 +55,139 @@ mcpServer.registerTool(
|
|||
},
|
||||
)
|
||||
|
||||
// Register sample resources
|
||||
mcpServer.registerResource(
|
||||
'config',
|
||||
'config://app',
|
||||
{
|
||||
title: 'Application Configuration',
|
||||
description: 'Current application configuration settings',
|
||||
mimeType: 'application/json',
|
||||
},
|
||||
async (uri: URL) => ({
|
||||
contents: [
|
||||
{
|
||||
uri: uri.href,
|
||||
mimeType: 'application/json',
|
||||
text: JSON.stringify(
|
||||
{
|
||||
version: '1.0.0',
|
||||
environment: 'test',
|
||||
features: {
|
||||
vengabus: true,
|
||||
calculator: true,
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
mcpServer.registerResource(
|
||||
'readme',
|
||||
'file://readme.md',
|
||||
{
|
||||
title: 'README',
|
||||
description: 'Server documentation',
|
||||
mimeType: 'text/markdown',
|
||||
},
|
||||
async (uri: URL) => ({
|
||||
contents: [
|
||||
{
|
||||
uri: uri.href,
|
||||
mimeType: 'text/markdown',
|
||||
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',
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
// Register a resource template
|
||||
mcpServer.registerResource(
|
||||
'stats',
|
||||
new ResourceTemplate('data://stats/{type}', { list: undefined }),
|
||||
{
|
||||
title: 'Statistics Data',
|
||||
description: 'Get statistics for different types',
|
||||
mimeType: 'application/json',
|
||||
},
|
||||
// @ts-expect-error - type is missing in the callback
|
||||
async (uri: URL, { type }) => ({
|
||||
contents: [
|
||||
{
|
||||
uri: uri.href,
|
||||
mimeType: 'application/json',
|
||||
text: JSON.stringify(
|
||||
{
|
||||
type: type,
|
||||
count: Math.floor(Math.random() * 100),
|
||||
lastUpdated: new Date().toISOString(),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
// Register sample prompts
|
||||
mcpServer.registerPrompt(
|
||||
'greeting',
|
||||
{
|
||||
title: 'Generate Greeting',
|
||||
description: 'Generate a greeting message',
|
||||
argsSchema: {
|
||||
name: z.string().describe('Name of the person to greet'),
|
||||
style: z.string().optional().describe('Style of greeting (formal/casual)'),
|
||||
},
|
||||
},
|
||||
({ name, style }) => ({
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: {
|
||||
type: 'text',
|
||||
text: `Generate a ${style || 'casual'} greeting for ${name}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
content: {
|
||||
type: 'text',
|
||||
text: style === 'formal' ? `Good day, ${name}. I hope this message finds you well.` : `Hey ${name}! How's it going?`,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
mcpServer.registerPrompt(
|
||||
'code_review',
|
||||
{
|
||||
title: 'Code Review Template',
|
||||
description: 'Template for code review requests',
|
||||
argsSchema: {
|
||||
language: z.string().describe('Programming language'),
|
||||
focus: z.string().optional().describe('What to focus on (performance/security/style)'),
|
||||
},
|
||||
},
|
||||
({ language, focus }) => ({
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: {
|
||||
type: 'text',
|
||||
text: `Please review the following ${language} code${focus ? ` with a focus on ${focus}` : ''}:`,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
app.post('/mcp', async (c) => {
|
||||
const transport = new StreamableHTTPTransport()
|
||||
await mcpServer.connect(transport)
|
||||
|
|
|
|||
Loading…
Reference in a new issue