Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/mcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,15 @@ You can also use special values to control access to orgs:

await this.telemetry.start();

process.stdin.on('close', (err) => {
this.telemetry?.sendEvent(err ? 'SERVER_STOPPED_ERROR' : 'SERVER_STOPPED_SUCCESS');
process.stdin.on('close', () => {
this.telemetry?.sendEvent('SERVER_STOPPED_SUCCESS');
this.telemetry?.stop();
});

// Handle SIGTERM as a fallback to ensure telemetry is sent
// https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle#stdio
process.stdin.on('SIGTERM', () => {
this.telemetry?.sendEvent('SERVER_STOPPED_SUCCESS');
this.telemetry?.stop();
});
}
Expand Down Expand Up @@ -207,6 +214,7 @@ You can also use special values to control access to orgs:
await this.telemetry.start();
}

// Track startup failures such as invalid flags, missing dependencies, or initialization errors
this.telemetry?.sendEvent('START_ERROR', {
error: error.message,
stack: error.stack,
Expand Down
17 changes: 0 additions & 17 deletions packages/mcp/src/sf-mcp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
import { ServerOptions } from '@modelcontextprotocol/sdk/server/index.js';
import { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
import { Logger } from '@salesforce/core';
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
import { ZodRawShape } from 'zod';
import { Telemetry } from './telemetry.js';
import { RateLimiter, RateLimitConfig, createRateLimiter } from './utils/rate-limiter.js';
Expand Down Expand Up @@ -89,22 +88,6 @@ export class SfMcpServer extends McpServer implements ToolMethodSignatures {
};
}

public connect: McpServer['connect'] = async (transport: Transport): Promise<void> => {
try {
await super.connect(transport);
if (!this.isConnected()) {
this.telemetry?.sendEvent('SERVER_START_ERROR', {
error: 'Server not connected',
});
}
} catch (error: unknown) {
this.telemetry?.sendEvent('SERVER_START_ERROR', {
error: error instanceof Error ? error.message : 'Unknown error',
stack: error instanceof Error ? error.stack : undefined,
});
}
};

public registerTool<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape>(
name: string,
config: {
Expand Down
Loading