Skip to content

Commit 37f4a3f

Browse files
committed
Dont use empty object in tool calls
1 parent 367b67e commit 37f4a3f

File tree

4 files changed

+37
-43
lines changed

4 files changed

+37
-43
lines changed

apps/sandbox-container/server/containerMcp.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export class ContainerMcpAgent extends McpAgent<Env, {}, Props> {
6565
this.server.tool(
6666
'container_initialize',
6767
'Start or reset the container',
68-
{},
6968
// @ts-ignore
7069
async ({}) => {
7170
return {
@@ -74,7 +73,7 @@ export class ContainerMcpAgent extends McpAgent<Env, {}, Props> {
7473
}
7574
)
7675

77-
this.server.tool('container_ping', 'Ping the container for liveliness', {}, async ({}) => {
76+
this.server.tool('container_ping', 'Ping the container for liveliness', async ({}) => {
7877
return {
7978
content: [{ type: 'text', text: await this.container_ping() }],
8079
}
@@ -112,7 +111,7 @@ export class ContainerMcpAgent extends McpAgent<Env, {}, Props> {
112111
}
113112
}
114113
)
115-
this.server.tool('container_files_list', 'List working directory file tree', {}, async ({}) => {
114+
this.server.tool('container_files_list', 'List working directory file tree', async ({}) => {
116115
// This approach relies on resources, which aren't handled well by Claude right now. Until that's sorted, we can just use file read, since it lists all files in a directory if a directory is passed to it.
117116
//const files = await this.container_ls()
118117

packages/mcp-common/src/tools/account.ts

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,43 @@ import { type CloudflareMcpAgent } from '../types/cloudflare-mcp-agent'
66

77
export function registerAccountTools(agent: CloudflareMcpAgent) {
88
// Tool to list all accounts
9-
agent.server.tool(
10-
'accounts_list',
11-
'List all accounts in your Cloudflare account',
12-
{},
13-
async () => {
14-
try {
15-
const results = await handleAccountsList({
16-
client: getCloudflareClient(agent.props.accessToken),
9+
agent.server.tool('accounts_list', 'List all accounts in your Cloudflare account', async () => {
10+
try {
11+
const results = await handleAccountsList({
12+
client: getCloudflareClient(agent.props.accessToken),
13+
})
14+
// Sort accounts by created_on date (newest first)
15+
const accounts = results
16+
// order by created_on desc ( newest first )
17+
.sort((a, b) => {
18+
if (!a.created_on) return 1
19+
if (!b.created_on) return -1
20+
return new Date(b.created_on).getTime() - new Date(a.created_on).getTime()
1721
})
18-
// Sort accounts by created_on date (newest first)
19-
const accounts = results
20-
// order by created_on desc ( newest first )
21-
.sort((a, b) => {
22-
if (!a.created_on) return 1
23-
if (!b.created_on) return -1
24-
return new Date(b.created_on).getTime() - new Date(a.created_on).getTime()
25-
})
2622

27-
return {
28-
content: [
29-
{
30-
type: 'text',
31-
text: JSON.stringify({
32-
accounts,
33-
count: accounts.length,
34-
}),
35-
},
36-
],
37-
}
38-
} catch (e) {
39-
agent.server.recordError(e)
40-
return {
41-
content: [
42-
{
43-
type: 'text',
44-
text: `Error listing accounts: ${e instanceof Error && e.message}`,
45-
},
46-
],
47-
}
23+
return {
24+
content: [
25+
{
26+
type: 'text',
27+
text: JSON.stringify({
28+
accounts,
29+
count: accounts.length,
30+
}),
31+
},
32+
],
33+
}
34+
} catch (e) {
35+
agent.server.recordError(e)
36+
return {
37+
content: [
38+
{
39+
type: 'text',
40+
text: `Error listing accounts: ${e instanceof Error && e.message}`,
41+
},
42+
],
4843
}
4944
}
50-
)
45+
})
5146

5247
const activeAccountIdParam = z
5348
.string()

packages/mcp-common/src/tools/r2_bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ export function registerR2BucketTools(agent: CloudflareMcpAgent) {
688688
// }
689689
// )
690690

691-
// agent.server.tool('r2_metrics_list', 'List metrics for an R2 bucket', {}, async () => {
691+
// agent.server.tool('r2_metrics_list', 'List metrics for an R2 bucket', async () => {
692692
// const account_id = agent.getActiveAccountId()
693693
// if (!account_id) {
694694
// return MISSING_ACCOUNT_ID_RESPONSE

packages/mcp-common/src/tools/worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const workerNameParam = z.string().describe('The name of the worker script to re
1515

1616
export function registerWorkersTools(agent: CloudflareMcpAgent) {
1717
// Tool to list all workers
18-
agent.server.tool('workers_list', 'List all Workers in your Cloudflare account', {}, async () => {
18+
agent.server.tool('workers_list', 'List all Workers in your Cloudflare account', async () => {
1919
const accountId = agent.getActiveAccountId()
2020
if (!accountId) {
2121
return {

0 commit comments

Comments
 (0)