Skip to content

Commit 227823f

Browse files
committed
fix: tests
1 parent d1fe5a5 commit 227823f

File tree

5 files changed

+28
-33
lines changed

5 files changed

+28
-33
lines changed

src/mcp/server.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ export class ActorsMcpServer {
5353
private sigintHandler: (() => Promise<void>) | undefined;
5454

5555
constructor(options: ActorsMcpServerOptions, setupSigintHandler = true) {
56-
this.options = {
57-
enableDefaultActors: options.enableDefaultActors ?? false, // Default to true for backward compatibility
58-
...options,
59-
};
56+
this.options = options;
6057
this.server = new Server(
6158
{
6259
name: SERVER_NAME,

src/mcp/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createHash } from 'node:crypto';
22
import { parse } from 'node:querystring';
33

4-
import { McpOptions, processInput } from '../input.js';
4+
import { type McpOptions, processInput } from '../input.js';
55
import { loadToolsFromInput } from '../utils/tools-loader.js';
66
import { MAX_TOOL_NAME_LENGTH, SERVER_ID_LENGTH } from './const.js';
77

src/tools/build.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,23 @@ export function processActorDefinition(
6262
limit: number,
6363
fullActorSchema: boolean,
6464
): ActorDefinitionPruned {
65+
let input;
66+
if (definition?.input && 'type' in definition.input && 'properties' in definition.input) {
67+
input = {
68+
...definition.input,
69+
type: definition.input.type as string,
70+
properties: definition.input.properties as Record<string, ISchemaProperties>,
71+
};
72+
if (!fullActorSchema) {
73+
input = separateAdvancedInputs(input);
74+
}
75+
}
6576
return {
6677
id: actor.id,
6778
actorFullName: `${actor.username}/${actor.name}`,
6879
buildTag: definition?.buildTag || '',
6980
readme: truncateActorReadme(definition.readme || '', limit),
70-
input: definition?.input && 'type' in definition.input && 'properties' in definition.input
71-
? (!fullActorSchema
72-
? {
73-
...definition.input,
74-
type: definition.input.type as string,
75-
properties: definition.input.properties as Record<string, ISchemaProperties>,
76-
}
77-
: separateAdvancedInputs({
78-
...definition.input,
79-
type: definition.input.type as string,
80-
properties: definition.input.properties as Record<string, ISchemaProperties>,
81-
})
82-
)
83-
: undefined,
81+
input,
8482
description: actor.description || '',
8583
defaultRunOptions: actor.defaultRunOptions,
8684
webServerMcpPath: 'webServerMcpPath' in definition ? definition.webServerMcpPath as string : undefined,

tests/helpers.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/
55
import { expect } from 'vitest';
66

77
import { HelperTools } from '../src/const.js';
8-
import type { ToolCategory } from '../src/types.js';
9-
10-
export interface McpClientOptions {
11-
actors?: string[];
12-
enableAddingActors?: boolean;
13-
tools?: ToolCategory[]; // Tool categories to include
14-
}
8+
import type { McpOptions } from '../src/input.js';
159

1610
export async function createMcpSseClient(
1711
serverUrl: string,
18-
options?: McpClientOptions,
12+
options?: Partial<McpOptions>,
1913
): Promise<Client> {
2014
if (!process.env.APIFY_TOKEN) {
2115
throw new Error('APIFY_TOKEN environment variable is not set.');
2216
}
2317
const url = new URL(serverUrl);
24-
const { actors, enableAddingActors, tools } = options || {};
18+
const { actors, enableAddingActors, tools, fullActorSchema } = options || {};
2519
if (actors) {
2620
url.searchParams.append('actors', actors.join(','));
2721
}
@@ -31,6 +25,9 @@ export async function createMcpSseClient(
3125
if (tools && tools.length > 0) {
3226
url.searchParams.append('tools', tools.join(','));
3327
}
28+
if (fullActorSchema !== undefined) {
29+
url.searchParams.append('fullActorSchema', fullActorSchema.toString());
30+
}
3431

3532
const transport = new SSEClientTransport(
3633
url,
@@ -54,13 +51,13 @@ export async function createMcpSseClient(
5451

5552
export async function createMcpStreamableClient(
5653
serverUrl: string,
57-
options?: McpClientOptions,
54+
options?: Partial<McpOptions>,
5855
): Promise<Client> {
5956
if (!process.env.APIFY_TOKEN) {
6057
throw new Error('APIFY_TOKEN environment variable is not set.');
6158
}
6259
const url = new URL(serverUrl);
63-
const { actors, enableAddingActors, tools } = options || {};
60+
const { actors, enableAddingActors, tools, fullActorSchema } = options || {};
6461
if (actors) {
6562
url.searchParams.append('actors', actors.join(','));
6663
}
@@ -70,6 +67,9 @@ export async function createMcpStreamableClient(
7067
if (tools && tools.length > 0) {
7168
url.searchParams.append('tools', tools.join(','));
7269
}
70+
if (fullActorSchema !== undefined) {
71+
url.searchParams.append('fullActorSchema', fullActorSchema.toString());
72+
}
7373

7474
const transport = new StreamableHTTPClientTransport(
7575
url,

tests/integration/suite.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function createIntegrationTestsSuite(
7373
beforeAll(beforeAllFn);
7474
}
7575
if (afterAllFn) {
76-
afterAll(afterAllFn);
76+
afterAll(afterAllFn, 60000);
7777
}
7878
if (beforeEachFn) {
7979
beforeEach(beforeEachFn);
@@ -487,7 +487,7 @@ export function createIntegrationTestsSuite(
487487
});
488488

489489
it(`should make ${ADVANCED_INPUT_KEY} in Actor properties available`, async () => {
490-
const client = await createClientFn({ enableAddingActors: true, fullActorSchema: true });
490+
const client = await createClientFn({ enableAddingActors: true, fullActorSchema: false });
491491
await client.callTool({ name: HelperTools.ACTOR_ADD, arguments: { actor: 'compass/crawler-google-places' } });
492492
// Get input type for actor 'compass-slash-crawler-google-places'
493493
const tools = await client.listTools();
@@ -508,7 +508,7 @@ export function createIntegrationTestsSuite(
508508
});
509509

510510
it(`should not create ${ADVANCED_INPUT_KEY} if is disabled`, async () => {
511-
const client = await createClientFn({ enableAddingActors: true, fullActorSchema: false });
511+
const client = await createClientFn({ enableAddingActors: true, fullActorSchema: true });
512512
await client.callTool({ name: HelperTools.ACTOR_ADD, arguments: { actor: 'compass/crawler-google-places' } });
513513
const tools = await client.listTools();
514514
const googlePlacesTool = tools.tools.find((tool) => tool.name === 'compass-slash-crawler-google-places');

0 commit comments

Comments
 (0)