Skip to content

Commit a8882d7

Browse files
committed
fix: actor to tool name
1 parent 52f4b73 commit a8882d7

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

src/actors.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import { ApifyClient } from 'apify-client';
33

44
import { ACTOR_ADDITIONAL_INSTRUCTIONS, defaults, MAX_DESCRIPTION_LENGTH } from './const.js';
55
import { log } from './logger.js';
6-
import type {
7-
ActorDefinitionPruned,
8-
ActorDefinitionWithDesc,
9-
SchemaProperties,
10-
Tool,
11-
} from './types.js';
6+
import type { ActorDefinitionPruned, ActorDefinitionWithDesc, SchemaProperties, Tool } from './types.js';
127

138
export function actorNameToToolName(actorName: string): string {
149
return actorName.replace('/', '--');
@@ -59,7 +54,7 @@ export async function getActorDefinition(actorFullName: string): Promise<ActorDe
5954
return null;
6055
} catch (error) {
6156
log.error(`Failed to fetch input schema for actor: ${actorFullName} with error ${error}.`);
62-
return null;
57+
throw new Error(`Failed to fetch input schema for actor: ${actorFullName} with error ${error}.`);
6358
}
6459
}
6560

src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ export class ApifyMcpServer {
175175
case InternalTools.ADD_ACTOR_TO_TOOLS: {
176176
const parsed = AddActorToToolsArgsSchema.parse(args);
177177
await this.addToolsFromActors([parsed.actorFullName]);
178-
return { content: [{ type: 'text', text: `Actor ${args.name} was added to tools` }] };
178+
return { content: [{ type: 'text', text: `Actor ${parsed.actorFullName} was added to tools` }] };
179179
}
180180
case InternalTools.REMOVE_ACTOR_FROM_TOOLS: {
181181
const parsed = RemoveActorToolArgsSchema.parse(args);
182182
this.tools.delete(parsed.toolName);
183-
return { content: [{ type: 'text', text: `Actor ${args.name} was removed from tools` }] };
183+
return { content: [{ type: 'text', text: `Tool ${parsed.toolName} was removed` }] };
184184
}
185185
case InternalTools.DISCOVER_ACTORS: {
186186
const parsed = DiscoverActorsArgsSchema.parse(args);

src/tools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ApifyClient } from 'apify-client';
44
import { z } from 'zod';
55
import { zodToJsonSchema } from 'zod-to-json-schema';
66

7-
import { actorNameToToolName, toolNameToActorName } from './actors.js';
7+
import { toolNameToActorName } from './actors.js';
88
import { InternalTools } from './const.js';
99
import type { ActorStorePruned, PricingInfo, Tool } from './types.js';
1010

@@ -35,14 +35,14 @@ export const RemoveActorToolArgsSchema = z.object({
3535
toolName: z.string()
3636
.describe('Full name of the Actor to remove. Actor full name is always composed from `username--name`'
3737
+ 'Never use name or username only')
38-
.transform((val) => actorNameToToolName(val)),
38+
.transform((val) => toolNameToActorName(val)),
3939
});
4040

4141
export const AddActorToToolsArgsSchema = z.object({
4242
actorFullName: z.string()
4343
.describe('Full name of the Actor to add as tool. Tool name is always composed from `username--name`'
4444
+ 'Never use name or username only')
45-
.transform((val) => actorNameToToolName(val)),
45+
.transform((val) => toolNameToActorName(val)),
4646
});
4747

4848
export const GetActorDefinition = z.object({

0 commit comments

Comments
 (0)