Skip to content

Commit 255e789

Browse files
committed
try to route actorized server notifications
1 parent 571582b commit 255e789

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,9 @@ if (STANDBY_MODE) {
6262
log.info(`Pushed ${datasetInfo?.itemCount} items to the dataset`);
6363
await Actor.exit();
6464
}
65+
66+
// So Ctrl+C works locally
67+
process.on('SIGINT', async () => {
68+
log.info('Received SIGINT, shutting down gracefully...');
69+
await Actor.exit();
70+
});

src/mcp/server.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ErrorCode,
1212
ListToolsRequestSchema,
1313
McpError,
14+
ServerNotificationSchema,
1415
} from '@modelcontextprotocol/sdk/types.js';
1516
import type { ValidateFunction } from 'ajv';
1617
import { type ActorCallOptions, ApifyApiError } from 'apify-client';
@@ -433,6 +434,22 @@ export class ActorsMcpServer {
433434
let client: Client | undefined;
434435
try {
435436
client = await connectMCPClient(serverTool.serverUrl, apifyToken);
437+
438+
// TODO: for some reason the client does not receive notifications
439+
// we need to investigate this
440+
// Set up notification handlers for the client
441+
for (const schema of ServerNotificationSchema.options) {
442+
const method = schema.shape.method.value;
443+
// Forward notifications from the proxy client to the server
444+
client.setNotificationHandler(schema, async (notification) => {
445+
log.info('Sending MCP notification', {
446+
method,
447+
notification,
448+
});
449+
await extra.sendNotification(notification);
450+
});
451+
}
452+
436453
const res = await client.callTool({
437454
name: serverTool.originToolName,
438455
arguments: args,

0 commit comments

Comments
 (0)