Skip to content

Commit c6a69e4

Browse files
authored
fix: Add idempotentHint annotations to various tools. For Actors, the destructiveHint is set to true as an Actor can perform any type of operation at Apify platform (#381)
1 parent 6329c4c commit c6a69e4

15 files changed

+31
-5
lines changed

src/mcp/proxy.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export async function getMCPServerTools(
2727
description: tool.description || '',
2828
inputSchema: tool.inputSchema,
2929
ajvValidate: fixedAjvCompile(ajv, tool.inputSchema),
30+
// Preserve annotations from the proxied tool
31+
annotations: tool.annotations,
3032
};
3133

3234
compiledTools.push(mcpTool);

src/tools/actor.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,11 @@ Actor description: ${definition.description}`;
202202
: undefined,
203203
annotations: {
204204
title: definition.actorFullName,
205-
destructiveHint: false,
205+
readOnlyHint: false,
206+
destructiveHint: true,
206207
openWorldHint: true,
207208
},
208-
// Allow long running tasks for Actor tools, make it optional for now
209+
// Allow long-running tasks for Actor tools, make it optional for now
209210
execution: {
210211
taskSupport: 'optional',
211212
},
@@ -220,7 +221,7 @@ async function getMCPServersAsTools(
220221
): Promise<ToolEntry[]> {
221222
/**
222223
* This is case for the Skyfire request without any Apify token, we do not support
223-
* standby Actors in this case so we can skip MCP servers since they would fail anyway (they are standby Actors).
224+
* standby Actors in this case, so we can skip MCP servers since they would fail anyway (they are standby Actors).
224225
*/
225226
if (apifyToken === null || apifyToken === undefined) {
226227
return [];
@@ -387,15 +388,17 @@ Step 2: Call Actor (step="call")
387388
EXAMPLES:
388389
- user_input: Get instagram posts using apify/instagram-scraper`,
389390
inputSchema: z.toJSONSchema(callActorArgs) as ToolInputSchema,
390-
// For now we are not adding the strucuted output schema since this tool is quite complex and has multiple possible ends states
391+
// For now we are not adding the structured output schema since this tool is quite complex and has multiple possible ends states
391392
ajvValidate: compileSchema({
392393
...z.toJSONSchema(callActorArgs),
393394
// Additional props true to allow skyfire-pay-id
394395
additionalProperties: true,
395396
}),
396397
annotations: {
397398
title: 'Call Actor',
398-
destructiveHint: false,
399+
readOnlyHint: false,
400+
destructiveHint: true,
401+
idempotentHint: false,
399402
openWorldHint: true,
400403
},
401404
call: async (toolArgs: InternalToolArgs) => {

src/tools/dataset.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ USAGE EXAMPLES:
6060
annotations: {
6161
title: 'Get dataset',
6262
readOnlyHint: true,
63+
idempotentHint: true,
6364
openWorldHint: false,
6465
},
6566
call: async (toolArgs: InternalToolArgs) => {
@@ -101,6 +102,7 @@ USAGE EXAMPLES:
101102
annotations: {
102103
title: 'Get dataset items',
103104
readOnlyHint: true,
105+
idempotentHint: true,
104106
openWorldHint: false,
105107
},
106108
call: async (toolArgs: InternalToolArgs) => {
@@ -169,6 +171,7 @@ USAGE EXAMPLES:
169171
annotations: {
170172
title: 'Get dataset schema',
171173
readOnlyHint: true,
174+
idempotentHint: true,
172175
openWorldHint: false,
173176
},
174177
call: async (toolArgs: InternalToolArgs) => {

src/tools/dataset_collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ USAGE EXAMPLES:
4444
annotations: {
4545
title: 'Get user datasets list',
4646
readOnlyHint: true,
47+
idempotentHint: true,
4748
openWorldHint: false,
4849
},
4950
call: async (toolArgs: InternalToolArgs) => {

src/tools/fetch-actor-details.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ USAGE EXAMPLES:
3434
annotations: {
3535
title: 'Fetch Actor details',
3636
readOnlyHint: true,
37+
idempotentHint: true,
3738
openWorldHint: false,
3839
},
3940
call: async (toolArgs: InternalToolArgs) => {

src/tools/fetch-apify-docs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ USAGE EXAMPLES:
3636
annotations: {
3737
title: 'Fetch Apify docs',
3838
readOnlyHint: true,
39+
idempotentHint: true,
3940
openWorldHint: false,
4041
},
4142
call: async (toolArgs: InternalToolArgs) => {

src/tools/get-actor-output.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Note: This tool is automatically included if the Apify MCP Server is configured
9191
annotations: {
9292
title: 'Get Actor output',
9393
readOnlyHint: true,
94+
idempotentHint: true,
9495
openWorldHint: false,
9596
},
9697
call: async (toolArgs: InternalToolArgs) => {

src/tools/get-html-skeleton.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ USAGE EXAMPLES:
5454
annotations: {
5555
title: 'Get HTML skeleton',
5656
readOnlyHint: true,
57+
idempotentHint: true,
5758
openWorldHint: true,
5859
},
5960
call: async (toolArgs: InternalToolArgs) => {

src/tools/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ USAGE EXAMPLES:
2828
ajvValidate: compileSchema(z.toJSONSchema(addToolArgsSchema)),
2929
annotations: {
3030
title: 'Add tool',
31+
readOnlyHint: false,
3132
destructiveHint: false,
33+
idempotentHint: true,
3234
openWorldHint: true,
3335
},
3436
// TODO: I don't like that we are passing apifyMcpServer and mcpServer to the tool

src/tools/key_value_store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ USAGE EXAMPLES:
3131
annotations: {
3232
title: 'Get key-value store',
3333
readOnlyHint: true,
34+
idempotentHint: true,
3435
openWorldHint: false,
3536
},
3637
call: async (toolArgs: InternalToolArgs) => {
@@ -76,6 +77,7 @@ USAGE EXAMPLES:
7677
annotations: {
7778
title: 'Get key-value store keys',
7879
readOnlyHint: true,
80+
idempotentHint: true,
7981
openWorldHint: false,
8082
},
8183
call: async (toolArgs: InternalToolArgs) => {
@@ -119,6 +121,7 @@ USAGE EXAMPLES:
119121
annotations: {
120122
title: 'Get key-value store record',
121123
readOnlyHint: true,
124+
idempotentHint: true,
122125
openWorldHint: false,
123126
},
124127
call: async (toolArgs: InternalToolArgs) => {

0 commit comments

Comments
 (0)