Skip to content

Dont use empty object in tool calls & update agents deps #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test-and-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Syncpack lint
run: pnpm syncpack lint
- name: Run linter
run: pnpm check:turbo
- name: Run linter (formatting)
Expand Down
4 changes: 2 additions & 2 deletions .syncpackrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const config = {
{
label: 'Sentry types that are compatible with toucan-js',
dependencies: ['@sentry/types', '@sentry/tracing'],
pinVersion: '7.76.0',
pinVersion: '8.9.2',
},
{
label: 'toucan-js that is compatible with pinned sentry types',
dependencies: ['toucan-js'],
pinVersion: '3.3.1',
pinVersion: '4.1.1',
},
{
label: 'pin vitest compatible with @cloudflare/vitest-pool-workers',
Expand Down
6 changes: 3 additions & 3 deletions apps/docs-autorag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"test": "vitest run"
},
"dependencies": {
"@cloudflare/workers-oauth-provider": "0.0.2",
"@cloudflare/workers-oauth-provider": "0.0.3",
"@hono/zod-validator": "0.4.3",
"@modelcontextprotocol/sdk": "1.9.0",
"@modelcontextprotocol/sdk": "1.10.2",
"@repo/mcp-common": "workspace:*",
"@repo/mcp-observability": "workspace:*",
"agents": "0.0.62",
"agents": "0.0.67",
"cloudflare": "4.2.0",
"hono": "4.7.6",
"mime": "4.0.6",
Expand Down
9 changes: 3 additions & 6 deletions apps/sandbox-container/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@
"eval:ci": "start-server-and-test --expect 404 eval:server http://localhost:8976 'vitest run --testTimeout=60000 --config vitest.config.evals.ts'"
},
"dependencies": {
"@cloudflare/workers-oauth-provider": "0.0.2",
"@cloudflare/workers-oauth-provider": "0.0.3",
"@hono/node-server": "1.13.8",
"@hono/zod-validator": "0.4.3",
"@modelcontextprotocol/sdk": "1.9.0",
"@modelcontextprotocol/sdk": "1.10.2",
"@n8n/json-schema-to-zod": "1.1.0",
"@repo/eval-tools": "workspace:*",
"@repo/mcp-common": "workspace:*",
"@repo/mcp-observability": "workspace:*",
"@types/node": "22.14.1",
"agents": "0.0.62",
"agents": "0.0.67",
"cron-schedule": "5.0.4",
"esbuild": "0.25.1",
"hono": "4.7.6",
"mime": "4.0.6",
"octokit": "4.1.2",
"partyserver": "0.0.65",
"simple-git-hooks": "2.12.1",
"tsx": "4.19.3",
"vitest-evals": "0.1.4",
"workers-mcp": "0.1.0-3",
"zod": "3.24.2"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions apps/workers-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"wrangler": "4.10.0"
},
"dependencies": {
"@cloudflare/workers-oauth-provider": "0.0.2",
"@modelcontextprotocol/sdk": "1.9.0",
"@cloudflare/workers-oauth-provider": "0.0.3",
"@modelcontextprotocol/sdk": "1.10.2",
"@n8n/json-schema-to-zod": "1.1.0",
"@repo/mcp-common": "workspace:*",
"@repo/mcp-observability": "workspace:*",
"agents": "0.0.62",
"agents": "0.0.67",
"hono": "4.7.6",
"zod": "3.24.2"
}
Expand Down
6 changes: 3 additions & 3 deletions apps/workers-observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"test": "vitest run"
},
"dependencies": {
"@cloudflare/workers-oauth-provider": "0.0.2",
"@cloudflare/workers-oauth-provider": "0.0.3",
"@hono/zod-validator": "0.4.3",
"@modelcontextprotocol/sdk": "1.9.0",
"@modelcontextprotocol/sdk": "1.10.2",
"@repo/mcp-common": "workspace:*",
"@repo/mcp-observability": "workspace:*",
"agents": "0.0.62",
"agents": "0.0.67",
"cloudflare": "4.2.0",
"hono": "4.7.6",
"zod": "3.24.2"
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,5 @@
"overrides": {
"esbuild": "0.25.1"
}
},
"dependencies": {
"workers-observability": "link:apps/workers-observability"
}
}
8 changes: 4 additions & 4 deletions packages/mcp-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"test:coverage": "run-vitest-coverage"
},
"dependencies": {
"@cloudflare/workers-oauth-provider": "0.0.2",
"@cloudflare/workers-oauth-provider": "0.0.3",
"@hono/zod-validator": "0.4.3",
"@modelcontextprotocol/sdk": "1.9.0",
"@modelcontextprotocol/sdk": "1.10.2",
"@repo/mcp-observability": "workspace:*",
"agents": "0.0.62",
"agents": "0.0.67",
"cloudflare": "4.2.0",
"hono": "4.7.6",
"toucan-js": "^4.1.1",
"toucan-js": "4.1.1",
"zod": "3.24.2"
},
"devDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion packages/mcp-common/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { MetricsTracker, SessionStart, ToolCall } from '../../mcp-observability/
import { McpError } from './mcp-error'

import type { ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js'
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js'
import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js'
import type { SentryClient } from './sentry'

export class CloudflareMCPServer extends McpServer {
Expand Down Expand Up @@ -54,7 +56,10 @@ export class CloudflareMCPServer extends McpServer {
this.tool = (name: string, ...rest: unknown[]): ReturnType<typeof this.tool> => {
const toolCb = rest[rest.length - 1] as ToolCallback<ZodRawShape | undefined>
const replacementToolCb: ToolCallback<ZodRawShape | undefined> = (arg1, arg2) => {
const toolCall = toolCb(arg1 as { [x: string]: any } & { signal: AbortSignal }, arg2)
const toolCall = toolCb(
arg1 as { [x: string]: any } & RequestHandlerExtra<ServerRequest, ServerNotification>,
arg2
)
// There are 4 cases to track:
try {
if (isPromise(toolCall)) {
Expand Down
71 changes: 33 additions & 38 deletions packages/mcp-common/src/tools/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,43 @@ import { type CloudflareMcpAgent } from '../types/cloudflare-mcp-agent'

export function registerAccountTools(agent: CloudflareMcpAgent) {
// Tool to list all accounts
agent.server.tool(
'accounts_list',
'List all accounts in your Cloudflare account',
{},
async () => {
try {
const results = await handleAccountsList({
client: getCloudflareClient(agent.props.accessToken),
agent.server.tool('accounts_list', 'List all accounts in your Cloudflare account', async () => {
try {
const results = await handleAccountsList({
client: getCloudflareClient(agent.props.accessToken),
})
// Sort accounts by created_on date (newest first)
const accounts = results
// order by created_on desc ( newest first )
.sort((a, b) => {
if (!a.created_on) return 1
if (!b.created_on) return -1
return new Date(b.created_on).getTime() - new Date(a.created_on).getTime()
})
// Sort accounts by created_on date (newest first)
const accounts = results
// order by created_on desc ( newest first )
.sort((a, b) => {
if (!a.created_on) return 1
if (!b.created_on) return -1
return new Date(b.created_on).getTime() - new Date(a.created_on).getTime()
})

return {
content: [
{
type: 'text',
text: JSON.stringify({
accounts,
count: accounts.length,
}),
},
],
}
} catch (e) {
agent.server.recordError(e)
return {
content: [
{
type: 'text',
text: `Error listing accounts: ${e instanceof Error && e.message}`,
},
],
}
return {
content: [
{
type: 'text',
text: JSON.stringify({
accounts,
count: accounts.length,
}),
},
],
}
} catch (e) {
agent.server.recordError(e)
return {
content: [
{
type: 'text',
text: `Error listing accounts: ${e instanceof Error && e.message}`,
},
],
}
}
)
})

const activeAccountIdParam = z
.string()
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-common/src/tools/r2_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ export function registerR2BucketTools(agent: CloudflareMcpAgent) {
// }
// )

// agent.server.tool('r2_metrics_list', 'List metrics for an R2 bucket', {}, async () => {
// agent.server.tool('r2_metrics_list', 'List metrics for an R2 bucket', async () => {
// const account_id = agent.getActiveAccountId()
// if (!account_id) {
// return MISSING_ACCOUNT_ID_RESPONSE
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-common/src/tools/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const workerNameParam = z.string().describe('The name of the worker script to re

export function registerWorkersTools(agent: CloudflareMcpAgent) {
// Tool to list all workers
agent.server.tool('workers_list', 'List all Workers in your Cloudflare account', {}, async () => {
agent.server.tool('workers_list', 'List all Workers in your Cloudflare account', async () => {
const accountId = agent.getActiveAccountId()
if (!accountId) {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"bin": "bin"
},
"dependencies": {
"@modelcontextprotocol/sdk": "1.9.0",
"@modelcontextprotocol/sdk": "1.10.2",
"wrangler": "4.10.0",
"zod": "3.24.2",
"@types/node": "22.14.1"
Expand Down
Loading