Skip to content

Commit badbba9

Browse files
committed
Work around schema parsing issue in Cursor
1 parent d93fb82 commit badbba9

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
},
7272
"dependencies": {
7373
"@alcyone-labs/zod-to-json-schema": "4.0.10",
74-
"@iterable/api": "0.5.0",
74+
"@iterable/api": "0.5.1",
7575
"@modelcontextprotocol/sdk": "1.18.1",
7676
"@primno/dpapi": "2.0.1",
7777
"@types/json-schema": "7.0.15",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/snippets.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ import { z } from "zod";
1515
import { createTool } from "../schema-utils.js";
1616

1717
export function createSnippetTools(client: IterableClient): Tool[] {
18+
// The union type (string | number) causes Cursor to reject the (valid) JSON schema
19+
const identifier: z.ZodString = z
20+
.string()
21+
.describe(
22+
"Snippet ID or name (stringified). Provide either a snippet name (string) or snippet ID (as a string)."
23+
);
24+
25+
function maybeConvertNumericString(value: string): string | number {
26+
return /^\d+$/.test(value) ? Number(value) : value;
27+
}
28+
1829
return [
1930
createTool({
2031
name: "get_snippets",
@@ -33,22 +44,32 @@ export function createSnippetTools(client: IterableClient): Tool[] {
3344
createTool({
3445
name: "get_snippet",
3546
description: "Get a snippet by ID (numeric) or name (string)",
36-
schema: GetSnippetParamsSchema,
37-
execute: (params) => client.getSnippet(params),
47+
schema: GetSnippetParamsSchema.extend({ identifier }),
48+
execute: ({ identifier }) =>
49+
client.getSnippet({
50+
identifier: maybeConvertNumericString(identifier),
51+
}),
3852
}),
3953

4054
createTool({
4155
name: "update_snippet",
4256
description: "Update a snippet by ID (numeric) or name (string)",
43-
schema: UpdateSnippetParamsSchema,
44-
execute: (params) => client.updateSnippet(params),
57+
schema: UpdateSnippetParamsSchema.extend({ identifier }),
58+
execute: (params) =>
59+
client.updateSnippet({
60+
...params,
61+
identifier: maybeConvertNumericString(params.identifier),
62+
}),
4563
}),
4664

4765
createTool({
4866
name: "delete_snippet",
4967
description: "Delete a snippet by ID (numeric) or name (string)",
50-
schema: DeleteSnippetParamsSchema,
51-
execute: (params) => client.deleteSnippet(params),
68+
schema: DeleteSnippetParamsSchema.extend({ identifier }),
69+
execute: ({ identifier }) =>
70+
client.deleteSnippet({
71+
identifier: maybeConvertNumericString(identifier),
72+
}),
5273
}),
5374
];
5475
}

0 commit comments

Comments
 (0)