Skip to content

Commit 5a32f46

Browse files
committed
finalize the implementation
1 parent ce90671 commit 5a32f46

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

src/apify-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class ApifyClient extends _ApifyClient {
7373
}
7474

7575
super({
76-
...clientOptions, // Now safe to spread without authToken
76+
...clientOptions, // safe to spread without authToken
7777
baseUrl: getApifyAPIBaseUrl(),
7878
requestInterceptors,
7979
});

src/mcp/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export class ActorsMcpServer {
402402

403403
// Validate auth token
404404
if (!authToken || !authToken.value) {
405-
const msg = 'Valid authentication token required. It must be provided either in the authToken parameter or APIFY_TOKEN environment variable.';
405+
const msg = `Valid authentication token required. It must be provided either in the Bearer Authorization header, APIFY_TOKEN environment variable or skyfire-pay-id header as Skyfire payment token.`;
406406
log.error(msg);
407407
await this.server.sendLoggingMessage({ level: 'error', data: msg });
408408
throw new McpError(

src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,16 @@ export interface ActorTool extends ToolBase {
8686

8787
export type AuthTokenType = 'apify' | 'skyfire';
8888

89+
/**
90+
* Interface representing an authentication token used throughout the MCP server.
91+
* This token is used to authenticate API calls to Apify services.
92+
*/
8993
export interface AuthToken {
94+
/** The actual token string value used for authentication */
9095
value: string;
96+
/** The type of authentication token, determining how it's processed */
9197
type: AuthTokenType;
98+
/** Optional user ID associated with the token, typically populated for 'apify' type tokens via IAM validation */
9299
userId?: string;
93100
}
94101

src/utils/progress.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { ApifyClient } from '../apify-client.js';
44
import { PROGRESS_NOTIFICATION_INTERVAL_MS } from '../const.js';
55
import type { AuthToken } from '../types.js';
66

7-
// TODO: we should write actual integration test to verify this works in production using real token.
87
export class ProgressTracker {
98
private progressToken: string | number;
109
private sendNotification: (notification: ProgressNotification) => Promise<void>;

tests/integration/internals.test.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ beforeAll(() => {
1515
log.setLevel(log.LEVELS.OFF);
1616
});
1717

18+
const authToken: AuthToken = {
19+
value: process.env.APIFY_TOKEN as string,
20+
type: 'apify',
21+
};
22+
1823
describe('MCP server internals integration tests', () => {
1924
it('should load and restore tools from a tool list', async () => {
2025
const actorsMcpServer = new ActorsMcpServer(false);
21-
const authToken: AuthToken = {
22-
value: process.env.APIFY_TOKEN as string,
23-
type: 'apify',
24-
};
2526
const initialTools = await loadToolsFromInput({
2627
enableAddingActors: true,
2728
} as Input, authToken);
@@ -60,10 +61,7 @@ describe('MCP server internals integration tests', () => {
6061
};
6162

6263
const actorsMCPServer = new ActorsMcpServer(false);
63-
const authToken: AuthToken = {
64-
value: process.env.APIFY_TOKEN as string,
65-
type: 'apify',
66-
};
64+
6765
const seeded = await loadToolsFromInput({ enableAddingActors: true } as Input, authToken);
6866
actorsMCPServer.upsertTools(seeded);
6967
actorsMCPServer.registerToolsChangedHandler(onToolsChanged);
@@ -101,10 +99,7 @@ describe('MCP server internals integration tests', () => {
10199
};
102100

103101
const actorsMCPServer = new ActorsMcpServer(false);
104-
const authToken: AuthToken = {
105-
value: process.env.APIFY_TOKEN as string,
106-
type: 'apify',
107-
};
102+
108103
const seeded = await loadToolsFromInput({ enableAddingActors: true } as Input, authToken);
109104
actorsMCPServer.upsertTools(seeded);
110105
actorsMCPServer.registerToolsChangedHandler(onToolsChanged);

0 commit comments

Comments
 (0)