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:
Jem 2025-07-02 17:59:24 -07:00
commit e0743c35e4
3 changed files with 329 additions and 32 deletions

View file

@ -12,7 +12,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.13.0",
"@modelcontextprotocol/sdk": "^1.13.3",
"zod": "^3.25.67"
},
"devDependencies": {

View file

@ -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

View file

@ -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`,
},
},
],
}))
}
}