Skip to content

Commit 688337c

Browse files
committed
fix: smithery, review comments
1 parent 4cd7c4a commit 688337c

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"node": ">=18.0.0"
88
},
99
"main": "dist/index.js",
10-
"module": "./src/index.ts",
10+
"module": "./src/smithery.ts",
1111
"exports": {
1212
".": "./dist/index.js",
1313
"./internals": "./dist/index-internals.js",

src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@
44
The ActorsMcpServer should be the only class exported from the package
55
*/
66
export { ActorsMcpServer } from './mcp/server.js';
7-
8-
// Uncomment the following lines if you want run the server using: npx @smithery/cli build && npx @smithery/cli dev
9-
// export { serverConfigSchemaSmithery as configSchema } from './types.js';
10-
// export { default as smithery } from './smithery.js';
11-

src/mcp/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ActorsMcpServer {
104104
*/
105105
public blockListToolsUntil(promise: Promise<unknown>, timeoutMs = 8_000) {
106106
const done = Promise.resolve(promise).then(() => undefined).catch(() => undefined);
107-
const timeout = new Promise<void>((resolve) => setTimeout(resolve, timeoutMs));
107+
const timeout = new Promise<void>((resolve) => { setTimeout(resolve, timeoutMs); });
108108
this.listToolsBarrier = Promise.race([done, timeout]).then(() => undefined);
109109
}
110110

src/smithery.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@
77
*/
88
import type { z } from 'zod';
99

10+
import { PLACEHOLDER_APIFY_TOKEN } from './const.js';
1011
import { ActorsMcpServer } from './mcp/server.js';
1112
import type { Input, ToolCategory } from './types';
1213
import { serverConfigSchemaSmithery as configSchema } from './types.js';
1314
import { loadToolsFromInput } from './utils/tools-loader.js';
14-
import { PLACEHOLDER_APIFY_TOKEN } from './const.js';
1515

1616
// Export the config schema for Smithery. The export must be named configSchema
1717
export { configSchema };
1818

1919
/**
20-
* Main entrypoint for Smithery deployment do not change signature of this function.
20+
* The Main entrypoint for Smithery deployment do not change signature of this function.
2121
* @returns
2222
*/
23+
// eslint-disable-next-line import/no-default-export
2324
export default function ({ config: _config }: { config: z.infer<typeof configSchema> }) {
2425
try {
25-
let apifyToken = _config.apifyToken || process.env.APIFY_TOKEN || '';
26+
const apifyToken = _config.apifyToken || process.env.APIFY_TOKEN || '';
2627
const enableAddingActors = _config.enableAddingActors ?? true;
2728
const actors = _config.actors || '';
2829
const actorList = actors ? actors.split(',').map((a: string) => a.trim()) : [];
2930
const toolCategoryKeys = _config.tools ? _config.tools.split(',').map((t: string) => t.trim()) : [];
3031

31-
console.log(`Apify token ${apifyToken}`)
3232
process.env.APIFY_TOKEN = apifyToken; // Ensure token is set in the environment
3333
const server = new ActorsMcpServer({ enableAddingActors, enableDefaultActors: false });
3434

@@ -58,7 +58,6 @@ export default function ({ config: _config }: { config: z.infer<typeof configSch
5858
})();
5959
server.blockListToolsUntil(loadPromise);
6060
return server.server;
61-
6261
} catch (e) {
6362
// eslint-disable-next-line no-console
6463
console.error(e);

tests/unit/smithery.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
22

33
import log from '@apify/log';
44

5-
import * as toolsLoader from '../../src/utils/tools-loader.js';
65
import { ActorsMcpServer } from '../../src/mcp/server.js';
76
import smithery from '../../src/smithery.js';
7+
import * as toolsLoader from '../../src/utils/tools-loader.js';
88

99
// Silence logs in unit tests
1010
log.setLevel(log.LEVELS.OFF);
@@ -16,11 +16,11 @@ describe('smithery entrypoint barrier behavior', () => {
1616

1717
it('calls blockListToolsUntil', async () => {
1818
// Arrange
19-
const blockSpy = vi.spyOn(ActorsMcpServer.prototype as any, 'blockListToolsUntil');
19+
const blockSpy = vi.spyOn(ActorsMcpServer.prototype, 'blockListToolsUntil');
2020
const loadSpy = vi.spyOn(toolsLoader, 'loadToolsFromInput').mockResolvedValue([]);
2121

2222
// Act
23-
const server = smithery({ config: { apifyToken: 'TEST_TOKEN', enableAddingActors: true } as any });
23+
const server = smithery({ config: { apifyToken: 'TEST_TOKEN', enableAddingActors: true } });
2424

2525
// Assert
2626
expect(server).toBeTruthy();

0 commit comments

Comments
 (0)