Skip to content

Commit a2b1600

Browse files
authored
chore: remove hyperdrive create tool (#137)
Co-authored-by: [email protected] <[email protected]>
1 parent 25ef3ae commit a2b1600

File tree

2 files changed

+96
-87
lines changed

2 files changed

+96
-87
lines changed

apps/workers-bindings/evals/hyperdrive.eval.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,42 @@ import { describeEval } from 'vitest-evals'
33

44
import { checkFactuality } from '@repo/eval-tools/src/scorers'
55
import { eachModel } from '@repo/eval-tools/src/test-models'
6+
import { HYPERDRIVE_TOOLS } from '@repo/mcp-common/src/tools/hyperdrive'
67

78
import { initializeClient, runTask } from './utils' // Assuming utils.ts will exist here
89

9-
const HYPERDRIVE_NAME = 'neon-test-hyperdrive'
10-
const HYPERDRIVE_DATABASE = 'neondb'
11-
const HYPERDRIVE_HOST = 'ep-late-cell-a4fm3g5p-pooler.us-east-1.aws.neon.tech'
12-
const HYPERDRIVE_PORT = 5432
13-
const HYPERDRIVE_USER = 'neondb_owner'
14-
const HYPERDRIVE_PASSWORD = 'my-test-password'
10+
// TODO: Add test for creating hyperdrive config with the following params once we can securely pass parameters to the tool. See: https://github.com/modelcontextprotocol/modelcontextprotocol/pull/382
11+
// const HYPERDRIVE_NAME = 'neon-test-hyperdrive'
12+
// const HYPERDRIVE_DATABASE = 'neondb'
13+
// const HYPERDRIVE_HOST = 'ep-late-cell-a4fm3g5p-pooler.us-east-1.aws.neon.tech'
14+
// const HYPERDRIVE_PORT = 5432
15+
// const HYPERDRIVE_USER = 'neondb_owner'
16+
// const HYPERDRIVE_PASSWORD = 'my-test-password'
1517

1618
eachModel('$modelName', ({ model }) => {
1719
describeEval('Hyperdrive Tool Evaluations', {
1820
data: async () => [
1921
{
20-
input: `Create a new Hyperdrive configuration with the name "${HYPERDRIVE_NAME}" and the database "${HYPERDRIVE_DATABASE}" and the host "${HYPERDRIVE_HOST}" and the port "${HYPERDRIVE_PORT}" and the user "${HYPERDRIVE_USER}" and the password "${HYPERDRIVE_PASSWORD}".`,
21-
expected:
22-
'The hyperdrive_configs_create tool should be called to create a new hyperdrive configuration.',
22+
input: `List my hyperdrive configurations.`,
23+
expected: `The ${HYPERDRIVE_TOOLS.hyperdrive_configs_list} tool should be called to list my hyperdrive configurations.`,
2324
},
2425
],
2526
task: async (input: string) => {
2627
const client = await initializeClient(/* Pass necessary mocks/config */)
2728
const { promptOutput, toolCalls } = await runTask(client, model, input)
2829

29-
const toolCall = toolCalls.find((call) => call.toolName === 'hyperdrive_config_create')
30-
expect(toolCall, 'Tool hyperdrive_configs_create was not called').toBeDefined()
30+
const toolCall = toolCalls.find(
31+
(call) => call.toolName === HYPERDRIVE_TOOLS.hyperdrive_configs_list
32+
)
33+
expect(
34+
toolCall,
35+
`Tool ${HYPERDRIVE_TOOLS.hyperdrive_configs_list} was not called`
36+
).toBeDefined()
3137

3238
return promptOutput
3339
},
3440
scorers: [checkFactuality],
3541
threshold: 1,
36-
timeout: 60000, // 60 seconds
42+
timeout: 60000,
3743
})
3844
})

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

Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ import {
1919
HyperdriveOriginUserSchema,
2020
} from '../types/hyperdrive'
2121

22+
export const HYPERDRIVE_TOOLS = {
23+
hyperdrive_configs_list: 'hyperdrive_configs_list',
24+
hyperdrive_config_create: 'hyperdrive_config_create',
25+
hyperdrive_config_delete: 'hyperdrive_config_delete',
26+
hyperdrive_config_get: 'hyperdrive_config_get',
27+
hyperdrive_config_edit: 'hyperdrive_config_edit',
28+
}
29+
2230
/**
2331
* Registers Hyperdrive tools with the Cloudflare MCP Agent.
2432
* @param agent The Cloudflare MCP Agent instance.
@@ -28,7 +36,7 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
2836
* Tool to list Hyperdrive configurations.
2937
*/
3038
agent.server.tool(
31-
'hyperdrive_configs_list',
39+
HYPERDRIVE_TOOLS.hyperdrive_configs_list,
3240
'List Hyperdrive configurations in your Cloudflare account',
3341
{
3442
page: HyperdriveListParamPageSchema.nullable(),
@@ -77,81 +85,82 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
7785
}
7886
)
7987

88+
// TODO: Once elicitation is available in MCP as a way to securely pass parameters, re-enable this tool. See: https://github.com/modelcontextprotocol/modelcontextprotocol/pull/382
8089
/**
8190
* Tool to create a Hyperdrive configuration.
8291
*/
83-
agent.server.tool(
84-
'hyperdrive_config_create',
85-
'Create a new Hyperdrive configuration in your Cloudflare account',
86-
{
87-
name: HyperdriveConfigNameSchema,
88-
database: HyperdriveOriginDatabaseSchema,
89-
host: HyperdriveOriginHostSchema,
90-
port: HyperdriveOriginPortSchema,
91-
scheme: HyperdriveOriginSchemeSchema,
92-
user: HyperdriveOriginUserSchema,
93-
password: HyperdriveOriginPasswordSchema,
94-
caching_disabled: HyperdriveCachingDisabledSchema.nullable(),
95-
caching_max_age: HyperdriveCachingMaxAgeSchema.nullable(),
96-
caching_stale_while_revalidate: HyperdriveCachingStaleWhileRevalidateSchema.nullable(),
97-
},
98-
async ({
99-
name,
100-
database,
101-
host,
102-
port,
103-
scheme,
104-
user,
105-
password,
106-
caching_disabled = undefined,
107-
caching_max_age = undefined,
108-
caching_stale_while_revalidate = undefined,
109-
}) => {
110-
const account_id = await agent.getActiveAccountId()
111-
if (!account_id) {
112-
return MISSING_ACCOUNT_ID_RESPONSE
113-
}
114-
try {
115-
const origin = { database, host, port, scheme, user, password }
116-
const caching: Record<string, any> = {}
117-
if (caching_disabled !== undefined) caching.disabled = caching_disabled
118-
if (caching_max_age !== undefined) caching.max_age = caching_max_age
119-
if (caching_stale_while_revalidate !== undefined)
120-
caching.stale_while_revalidate = caching_stale_while_revalidate
92+
// agent.server.tool(
93+
// HYPERDRIVE_TOOLS.hyperdrive_config_create,
94+
// 'Create a new Hyperdrive configuration in your Cloudflare account',
95+
// {
96+
// name: HyperdriveConfigNameSchema,
97+
// database: HyperdriveOriginDatabaseSchema,
98+
// host: HyperdriveOriginHostSchema,
99+
// port: HyperdriveOriginPortSchema,
100+
// scheme: HyperdriveOriginSchemeSchema,
101+
// user: HyperdriveOriginUserSchema,
102+
// password: HyperdriveOriginPasswordSchema,
103+
// caching_disabled: HyperdriveCachingDisabledSchema.nullable(),
104+
// caching_max_age: HyperdriveCachingMaxAgeSchema.nullable(),
105+
// caching_stale_while_revalidate: HyperdriveCachingStaleWhileRevalidateSchema.nullable(),
106+
// },
107+
// async ({
108+
// name,
109+
// database,
110+
// host,
111+
// port,
112+
// scheme,
113+
// user,
114+
// password,
115+
// caching_disabled = undefined,
116+
// caching_max_age = undefined,
117+
// caching_stale_while_revalidate = undefined,
118+
// }) => {
119+
// const account_id = await agent.getActiveAccountId()
120+
// if (!account_id) {
121+
// return MISSING_ACCOUNT_ID_RESPONSE
122+
// }
123+
// try {
124+
// const origin = { database, host, port, scheme, user, password }
125+
// const caching: Record<string, any> = {}
126+
// if (caching_disabled !== undefined) caching.disabled = caching_disabled
127+
// if (caching_max_age !== undefined) caching.max_age = caching_max_age
128+
// if (caching_stale_while_revalidate !== undefined)
129+
// caching.stale_while_revalidate = caching_stale_while_revalidate
121130

122-
const client = getCloudflareClient(agent.props.accessToken)
123-
const hyperdriveConfig = await client.hyperdrive.configs.create({
124-
account_id,
125-
name,
126-
origin,
127-
...(Object.keys(caching).length > 0 && { caching }),
128-
})
129-
return {
130-
content: [
131-
{
132-
type: 'text',
133-
text: JSON.stringify(hyperdriveConfig),
134-
},
135-
],
136-
}
137-
} catch (error) {
138-
return {
139-
content: [
140-
{
141-
type: 'text',
142-
text: `Error creating Hyperdrive config: ${error instanceof Error ? error.message : String(error)}`,
143-
},
144-
],
145-
}
146-
}
147-
}
148-
)
131+
// const client = getCloudflareClient(agent.props.accessToken)
132+
// const hyperdriveConfig = await client.hyperdrive.configs.create({
133+
// account_id,
134+
// name,
135+
// origin,
136+
// ...(Object.keys(caching).length > 0 && { caching }),
137+
// })
138+
// return {
139+
// content: [
140+
// {
141+
// type: 'text',
142+
// text: JSON.stringify(hyperdriveConfig),
143+
// },
144+
// ],
145+
// }
146+
// } catch (error) {
147+
// return {
148+
// content: [
149+
// {
150+
// type: 'text',
151+
// text: `Error creating Hyperdrive config: ${error instanceof Error ? error.message : String(error)}`,
152+
// },
153+
// ],
154+
// }
155+
// }
156+
// }
157+
// )
149158

150159
/**
151160
* Tool to delete a Hyperdrive configuration.
152161
*/
153162
agent.server.tool(
154-
'hyperdrive_config_delete',
163+
HYPERDRIVE_TOOLS.hyperdrive_config_delete,
155164
'Delete a Hyperdrive configuration in your Cloudflare account',
156165
{
157166
hyperdrive_id: HyperdriveConfigIdSchema,
@@ -189,7 +198,7 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
189198
* Tool to get a specific Hyperdrive configuration.
190199
*/
191200
agent.server.tool(
192-
'hyperdrive_config_get',
201+
HYPERDRIVE_TOOLS.hyperdrive_config_get,
193202
'Get details of a specific Hyperdrive configuration in your Cloudflare account',
194203
{
195204
hyperdrive_id: HyperdriveConfigIdSchema,
@@ -229,7 +238,7 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
229238
* Tool to edit (PATCH) a Hyperdrive configuration.
230239
*/
231240
agent.server.tool(
232-
'hyperdrive_config_edit',
241+
HYPERDRIVE_TOOLS.hyperdrive_config_edit,
233242
'Edit (patch) a Hyperdrive configuration in your Cloudflare account',
234243
{
235244
hyperdrive_id: HyperdriveConfigIdSchema,
@@ -239,7 +248,6 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
239248
port: HyperdriveOriginPortSchema.optional().nullable(),
240249
scheme: HyperdriveOriginSchemeSchema.optional().nullable(),
241250
user: HyperdriveOriginUserSchema.optional().nullable(),
242-
password: HyperdriveOriginPasswordSchema.optional().nullable(),
243251
caching_disabled: HyperdriveCachingDisabledSchema.optional().nullable(),
244252
caching_max_age: HyperdriveCachingMaxAgeSchema.optional().nullable(),
245253
caching_stale_while_revalidate:
@@ -253,7 +261,6 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
253261
port,
254262
scheme,
255263
user,
256-
password,
257264
caching_disabled,
258265
caching_max_age,
259266
caching_stale_while_revalidate,
@@ -269,7 +276,6 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
269276
if (port) originPatch.port = port
270277
if (scheme) originPatch.scheme = scheme
271278
if (user) originPatch.user = user
272-
if (password) originPatch.password = password
273279

274280
const cachingPatch: Record<string, any> = {}
275281
if (caching_disabled) cachingPatch.disabled = caching_disabled
@@ -318,7 +324,4 @@ export function registerHyperdriveTools(agent: CloudflareMcpAgent) {
318324
}
319325
}
320326
)
321-
322-
// Note: client.hyperdrive.configs.update (PUT) was requested but doesn't exist in the SDK.
323-
// The SDK provides client.hyperdrive.configs.edit (PATCH) which is implemented above.
324327
}

0 commit comments

Comments
 (0)