@salesforce/mcp 0.23.4 → 0.23.5-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,247 @@
1
+ # mcp
2
+
3
+ MCP Server for Interacting with Salesforce Orgs
4
+
5
+ [![NPM](https://img.shields.io/npm/v/@salesforce/mcp.svg?label=@salesforce/mcp)](https://www.npmjs.com/package/@salesforce/mcp) [![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/license/apache-2-0)
6
+
7
+ ## Feedback
8
+
9
+ Report bugs and issues [here](https://github.com/forcedotcom/mcp/issues).
10
+ For feature requests and other related topics, start a Discussion [here](https://github.com/forcedotcom/mcp/discussions).
11
+
12
+ ## Documentation
13
+
14
+ For complete documentation about the Salesforce DX MCP Server, see [this section](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_mcp.htm) in the _Salesforce DX Developer Guide_. The docs include:
15
+
16
+ * Comprehensive overview, including details about the security features.
17
+ * Quick start guide.
18
+ * Multiple examples of configuring the server in your MCP client.
19
+ * Sample prompts for invoking the core DX MCP tools.
20
+
21
+ [Here are the release notes.](https://github.com/forcedotcom/mcp/tree/main/releasenotes)
22
+
23
+ ## Overview of the Salesforce DX MCP Server (Beta)
24
+
25
+ The Salesforce DX MCP Server is a specialized Model Context Protocol (MCP) implementation designed to facilitate seamless interaction between large language models (LLMs) and Salesforce orgs. This MCP server provides a robust set of tools and capabilities that enable LLMs to read, manage, and operate Salesforce resources securely.
26
+
27
+ > [!NOTE]
28
+ > _Salesforce DX MCP Server is a pilot or beta service that is subject to the Beta Services Terms at [Agreements - Salesforce.com](https://www.salesforce.com/company/legal/) or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the [Product Terms Directory](https://ptd.salesforce.com/). Use of this pilot or beta service is at the Customer's sole discretion._
29
+
30
+ ## Configure the DX MCP Server
31
+
32
+ Configure the Salesforce DX MCP Server for your MCP client by updating its associated MCP JSON file; each client is slightly different, so check your MCP client documentation for details.
33
+
34
+ Here's an example for VS Code with Copilot in which you create and update a `.vscode/mcp.json` file in your project:
35
+
36
+ ```
37
+ {
38
+ "servers": {
39
+ "Salesforce DX": {
40
+ "command": "npx",
41
+ "args": ["-y", "@salesforce/mcp",
42
+ "--orgs", "DEFAULT_TARGET_ORG",
43
+ "--toolsets", "orgs,metadata,data,users",
44
+ "--tools", "run_apex_test",
45
+ "--allow-non-ga-tools"]
46
+ }
47
+ }
48
+ }
49
+ ```
50
+ The `args` format shown in the preceding example is the same for all MCP clients; it's how you customize the DX MCP Server for your particular environment. Notes:
51
+
52
+ - The `"-y", "@salesforce/mcp"` part tells `npx` to automatically install the `@salesforce/mcp` package instead of asking permission. Don't change this.
53
+ - See the *Reference* sections below for the possible flags you can pass the `args` option, and possible values you can pass to the `--orgs`, `--toolsets`, and `--tools` flags.
54
+ - When writing the `args` option, surround both the flag names and their values in double quotes, and separate all flags and values with commas. Some flags are Boolean and don't take a value.
55
+ - The preceding example shows three flags that take a string value (`--orgs`, `--toolsets`, and `--tools`) and one Boolean flag (`--allow-non-ga-tools`). This configuration starts a DX MCP Server that enables all the MCP tools in the `orgs`, `metadata`, `data`, and `users` toolsets and a specific tool called `run_apex_tests`. It also enables tools in these configured toolsets that aren't yet generally available.
56
+
57
+ <details>
58
+ <summary>Reference: Available Flags for the `args` Option</summary>
59
+
60
+ ## Reference: Available Flags for the "args" Option
61
+
62
+ These are the flags that you can pass to the `args` option.
63
+
64
+ | Flag Name | Description | Required? |Notes |
65
+ | -----------------| -------| ------- | ----- |
66
+ | `--orgs` | One or more orgs that you've locally authorized. | Yes | You must specify at least one org. <br/> <br/>See [Configure Orgs](README.md#configure-orgs) for the values you can pass to this flag. |
67
+ | `--toolsets` | Sets of tools, based on functionality, that you want to enable. | No | Set to "all" to enable every tool in every toolset. <br/> <br/>See [Configure Toolsets](README.md#configure-toolsets) for the values you can pass to this flag.|
68
+ | `--tools` | Individual tool names that you want to enable. | No | You can use this flag in combination with the `--toolsets` flag. For example, you can enable all tools in one toolset, and just one tool in a different toolset. |
69
+ | `--no-telemetry` | Boolean flag to disable telemetry, the automatic collection of data for monitoring and analysis. | No | Telemetry is enabled by default, so specify this flag to disable it. |
70
+ | `--debug` | Boolean flag that requests that the DX MCP Server print debug logs. | No | Debug mode is disabled by default. <br/> <br/>**NOTE:** Not all MCP clients expose MCP logs, so this flag might not work for all IDEs. |
71
+ | `--allow-non-ga-tools` | Boolean flag to allow the DX MCP Server to use both the generally available (GA) and NON-GA tools that are in the toolsets or tools you specify. | No | By default, the DX MCP server uses only the tools marked GA. |
72
+ | `--dynamic-tools` | (experimental) Boolean flag that enables dynamic tool discovery and loading. When specified, the DX MCP server starts with a minimal set of core tools and loads new tools as needed. | No| This flag is useful for reducing the initial context size and improving LLM performance. Dynamic tool discovery is disabled by default.<br/> <br/>**NOTE:** This feature works in VSCode and Cline but may not work in other environments.|
73
+
74
+ </details>
75
+ <details>
76
+
77
+ <summary>Reference: Configure Orgs</summary>
78
+
79
+ ## Configure Orgs
80
+
81
+ The Salesforce MCP tools require an org, and so you must include the required `--orgs` flag to specify at least one authorized org when you configure the MCP server. Separate multiple values with commas.
82
+
83
+ You must explicitly [authorize the orgs](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_web_flow.htm) on your computer before the MCP server can access them. Use the `org login web` Salesforce CLI command or the VS Code **SFDX: Authorize an Org** command from the command palette.
84
+
85
+ These are the available values for the `--orgs` flag:
86
+
87
+ | --orgs Value | Description |
88
+ | -------- | ---------- |
89
+ | `DEFAULT_TARGET_ORG` | Allow access to your default org. If you've set a local default org in your DX project, the MCP server uses it. If not, the server uses a globally-set default org.|
90
+ | `DEFAULT_TARGET_DEV_HUB` | Allow access to your default Dev Hub org. If you've set a local default Dev Hub org in your DX project, the MCP server uses it. If not, the server uses a globally-set default Dev Hub org.|
91
+ | `ALLOW_ALL_ORGS` | Allow access to all authorized orgs. Use this value with caution.|
92
+ | `<username or alias>` | Allow access to a specific org by specifying its username or alias.|
93
+
94
+ </details>
95
+
96
+ <details>
97
+ <summary>Reference: Configure Toolsets and Tools</summary>
98
+
99
+ ## Configure Toolsets
100
+
101
+ The Salesforce DX MCP Server supports **toolsets** - a way to selectively enable different groups of MCP tools based on your needs. This allows you to run the MCP server with only the tools you require, which in turn reduces the context.
102
+
103
+ Use the `--toolsets` flag to specify the toolsets when you configure the Salesforce DX MCP Server. Separate multiple toolsets with commas.
104
+
105
+ These are the available toolsets.
106
+
107
+ | Toolset| Description|
108
+ | ----- | ----- |
109
+ | `all` | Enables all available tools from all toolsets. Use caution, this will load over 60 tools. |
110
+ | `orgs` | [Tools to manage your authorized orgs.](README.md#orgs-toolset)|
111
+ | `data` | [Tools to manage the data in your org, such as listing all accounts.](README.md#data-toolset)|
112
+ | `users` | [Tools to manage org users, such as assigning a permission set.](README.md#users-toolset)|
113
+ | `metadata` | [Tools to deploy and retrieve metadata to and from your org and your DX project.](README.md#metadata-toolset)|
114
+ | `testing` | [Tools to test your code and features](README.md#testing-toolset)|
115
+ | `other` | [Other useful tools, such as tools for static analysis of your code using Salesforce Code Analyzer.](README.md#other-toolset)|
116
+ | `mobile` | [Tools for mobile development and capabilities.](README.md#mobile-toolset)|
117
+ | `mobile-core` | [A subset of mobile tools focused on essential mobile capabilities.](README.md#mobile-core-toolset)|
118
+ | `aura-experts` | [Tools which provides Aura component analysis, blueprinting, and migration expertise.](README.md#aura-experts-toolset)|
119
+ | `lwc-experts` | [Tools to assist with LWC development, testing, optimization, and best practices.](README.md#lwc-experts-toolset)|
120
+
121
+ ## Configure Tools
122
+
123
+ The Salesforce DX MCP Server also supports registering individual **tools**. This can be used in combination with **toolsets** to further fine-tune registered tools.
124
+
125
+ Use the `--tools` flag to enable specific tools when you configure the Salesforce DX MCP Server. Separate multiple tools with commas. The `--tools` flag is optional.
126
+
127
+ The following sections list all the tools that are included in a specific toolset. The tools marked NON-GA are not yet generally available, specify the `--allow-non-ga-tools` flag to use them.
128
+
129
+ ### Core Toolset (always enabled)
130
+
131
+ - `get_username` - Determines the appropriate username or alias for Salesforce operations, handling both default orgs and Dev Hubs.
132
+ - `resume_tool_operation` - Resumes a long-running operation that wasn't completed by another tool.
133
+
134
+ ### Orgs Toolset
135
+
136
+ - `list_all_orgs` - Lists all configured Salesforce orgs, with optional connection status checking.
137
+ - `create_org_snapshot` - (NON-GA) Create a scratch org snapshot.
138
+ - `create_scratch_org` - (NON-GA) Create a scratch org.
139
+ - `delete_org` - (NON-GA) Delete a locally-authorized Salesforce scratch org or sandbox.
140
+ - `org_open` - (NON-GA) Open an org in a browser.
141
+
142
+ **NOTE:** The tools marked NON-GA are not yet generally available, specify the `--allow-non-ga-tools` flag to use them.
143
+
144
+ ### Data Toolset
145
+
146
+ - `run_soql_query` - Runs a SOQL query against a Salesforce org.
147
+
148
+ ### Users Toolset
149
+
150
+ - `assign_permission_set` - Assigns a permission set to the user or on behalf of another user.
151
+
152
+ ### Metadata Toolset
153
+
154
+ - `deploy_metadata` - Deploys metadata from your DX project to an org.
155
+ - `retrieve_metadata` - Retrieves metadata from your org to your DX project.
156
+
157
+ ### Testing Toolset
158
+
159
+ - `run_agent_test` - Executes agent tests in your org.
160
+ - `run_apex_test` - Executes apex tests in your org.
161
+
162
+ ### Mobile Toolset
163
+
164
+ - `create_mobile_lwc_app_review` - Provides TypeScript API documentation for Salesforce LWC App Review Service, offering expert guidance for implementing app review features in Lightning Web Components.
165
+ - `create_mobile_lwc_ar_space_capture` - Provides TypeScript API documentation for Salesforce L WC AR Space Capture, offering expert guidance for implementing AR space capture features in Lightning Web Components.
166
+ - `create_mobile_lwc_barcode_scanner` - Provides TypeScript API documentation for Salesforce LWC Barcode Scanner, offering expert guidance for implementing barcode scanning features in Lightning Web Components.
167
+ - `create_mobile_lwc_biometrics` - Provides TypeScript API documentation for Salesforce LWC Biometrics Service, offering expert guidance for implementing biometric authentication features in Lightning Web Components.
168
+ - `create_mobile_lwc_calendar` - Provides TypeScript API documentation for Salesforce LWC Calendar Service, offering expert guidance for implementing calendar integration features in Lightning Web Components.
169
+ - `create_mobile_lwc_contacts` - Provides TypeScript API documentation for Salesforce LWC Contacts Service, offering expert guidance for implementing contacts management features in Lightning Web Components.
170
+ - `create_mobile_lwc_document_scanner` - Provides TypeScript API documentation for Salesforce LWC Document Scanner, offering expert guidance for implementing document scanning features in Lightning Web Components.
171
+ - `create_mobile_lwc_geofencing` - Provides TypeScript API documentation for Salesforce LWC Geofencing Service, offering expert guidance for implementing geofencing features in Lightning Web Components.
172
+ - `create_mobile_lwc_location` - Provides TypeScript API documentation for Salesforce LWC Location Service, offering expert guidance for implementing location services in Lightning Web Components.
173
+ - `create_mobile_lwc_nfc` - Provides TypeScript API documentation for Salesforce LWC NFC Service, offering expert guidance for implementing NFC features in Lightning Web Components.
174
+ - `create_mobile_lwc_payments` - Provides TypeScript API documentation for Salesforce LWC Payments Service, offering expert guidance for implementing payment processing features in Lightning Web Components.
175
+ - `get_mobile_lwc_offline_analysis` - Analyzes Lightning Web Components for mobile-specific issues and provides detailed recommendations for mobile offline compatibility and performance improvements.
176
+ - `get_mobile_lwc_offline_guidance` - Provides structured review instructions to detect and remediate mobile offline code violations in Lightning Web Components for Salesforce Mobile Apps.
177
+
178
+ ### Mobile-core Toolset
179
+
180
+ - `create_mobile_lwc_barcode_scanner` - Provides TypeScript API documentation for Salesforce LWC Barcode Scanner, offering expert guidance for implementing barcode scanning features in Lightning Web Components.
181
+ - `create_mobile_lwc_biometrics` - Provides TypeScript API documentation for Salesforce LWC Biometrics Service, offering expert guidance for implementing biometric authentication features in Lightning Web Components.
182
+ - `create_mobile_lwc_location` - Provides TypeScript API documentation for Salesforce LWC Location Service, offering expert guidance for implementing location services in Lightning Web Components.
183
+ - `get_mobile_lwc_offline_analysis` - Analyzes Lightning Web Components for mobile-specific issues and provides detailed recommendations for mobile offline compatibility and performance improvements.
184
+ - `get_mobile_lwc_offline_guidance` - Provides structured review instructions to detect and remediate mobile offline code violations in Lightning Web Components for Salesforce Mobile Apps.
185
+
186
+ ### Aura Experts Toolset
187
+
188
+ - `create_aura_blueprint_draft` - (GA)
189
+ Creates a comprehensive Product Requirements Document (PRD) blueprint for Aura component migration. Analyzes Aura component files and generates framework-agnostic specifications suitable for LWC migration, including business requirements, technical patterns, and migration guidelines.
190
+
191
+ - `enhance_aura_blueprint_draft` - (GA)
192
+ Enhances an existing draft PRD with expert analysis and unknown resolution. Takes a draft blueprint and applies specialized Aura expert knowledge to resolve dependencies, add technical insights, and improve the migration specifications for better LWC implementation guidance.
193
+
194
+ - `transition_prd_to_lwc` - (GA)
195
+ Provides migration bridge guidance for creating LWC components from Aura specifications. Takes the enhanced PRD and generates specific implementation guidance, platform service mappings, and step-by-step instructions for building the equivalent LWC component.
196
+
197
+ - `orchestrate_aura_migration` - (GA)
198
+ Orchestrates the complete Aura to LWC migration workflow. Provides end-to-end guidance for the entire migration process, from initial analysis through final implementation, including best practices, tooling recommendations, and quality assurance steps.
199
+
200
+ ### Lwc Experts Toolset
201
+
202
+ #### Component Development
203
+
204
+ - `create_lwc_component_from_prd` - (GA) Creates complete LWC components from PRD specifications with proper structure and best practices
205
+ - `create_lwc_jest_tests` - (GA) Generates comprehensive Jest test suites for LWC components with coverage and mocking
206
+ - `review_lwc_jest_tests` - (GA) Reviews and validates Jest test implementations for LWC components
207
+
208
+ #### Development Guidelines
209
+
210
+ - `guide_lwc_accessibility` - (GA) Provides accessibility guidelines and testing instructions for LWC components
211
+ - `guide_lwc_best_practices` - (GA) Offers LWC development best practices and coding standards guidance
212
+ - `guide_lwc_development` - (GA) Comprehensive LWC development workflow and implementation guidelines
213
+ - `guide_lwc_rtl_support` - (GA) Right-to-Left internationalization support and RTL development guidance
214
+ - `guide_lwc_slds2_uplift_linter_fixes` - (GA) Analyzes the given LWC code along with the slds-linter output to fix issues using the SLDS2 knowledge
215
+ - `guide_lwc_security` - (GA) Comprehensive security analysis in accordance with Product Security Guidelines and Lightning Web Security Guidelines
216
+ - `guide_design_general` - (GA) Comprehensive SLDS guidelines and best practices for Lightning Web Components with accessibility, responsive design, and component usage patterns
217
+
218
+ #### Workflow Tools
219
+
220
+ - `orchestrate_lwc_component_creation` - (GA) Step-by-step component creation workflow guidance
221
+ - `orchestrate_lwc_component_optimization` - (GA) Performance optimization and best practices for LWC components
222
+ - `orchestrate_lwc_component_testing` - (GA) Comprehensive testing workflow and test generation guidance
223
+ - `orchestrate_lwc_slds2_uplift` - (GA) Migration guidance for upgrading to SLDS2 design system
224
+
225
+ #### LDS (Lightning Data Service) Tools
226
+
227
+ - `explore_lds_uiapi` - (GA) Explores and documents Lightning Data Service UI API capabilities
228
+ - `guide_lds_data_consistency` - (GA) Data consistency patterns and best practices for LDS components
229
+ - `guide_lds_development` - (GA) LDS development guidelines and component integration
230
+ - `guide_lds_referential_integrity` - (GA) Referential integrity patterns for LDS data management
231
+ - `orchestrate_lds_data_requirements` - (GA) Step-by-step guidance for analyzing and clarifying LDS data requirements to produce PRD-ready specifications.
232
+ - `create_lds_graphql_read_query` - (GA) Create GraphQL read queries for LDS
233
+ - `explore_lds_graphql_schema` - (GA) Explore GraphQL schema structure for Salesforce LDS
234
+ - `guide_lds_graphql` - (GA) LDS GraphQL usage patterns and guidelines
235
+
236
+ #### Migration & Integration Tools
237
+
238
+ - `verify_aura_migration_completeness` - (GA) Aura to LWC migration completeness checklist and validation
239
+ - `guide_figma_to_lwc_conversion` - (GA) Converts Figma designs to LWC component specifications
240
+ - `run_lwc_accessibility_jest_tests` - (GA) Accessibility testing utilities and Jest integration for LWC components
241
+
242
+ ### Code-Analysis Toolset
243
+
244
+ - `run_code_analyzer` - (NON-GA) Performs a static analysis of your code using Salesforce Code Analyzer. Includes validating that the code conforms to best practices, checking for security vulnerabilities, and identifying possible performance issues.
245
+ - `describe_code_analyzer_rule` - (NON-GA) Gets the description of a Salesforce Code Analyzer rule, including the engine it belongs to, its severity, and associated tags.
246
+
247
+ </details>
@@ -0,0 +1,2 @@
1
+ export type CI = 'circleci' | 'travisci' | 'bitbucket' | 'hudson' | 'heroku' | 'codebuild' | 'bamboo' | 'cirrus' | 'jenkins' | 'github_actions' | 'azure_pipelines' | 'teamcity' | 'gitlab' | 'nevercode' | 'wercker' | 'buildkite' | 'semaphore' | 'bitrise' | 'buddy' | 'appveyor' | 'copado' | 'unknown';
2
+ export declare const guessCISystem: () => CI | undefined;
package/lib/guessCI.js ADDED
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Copyright 2025, Salesforce, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // eslint-disable-next-line complexity
17
+ export const guessCISystem = () => {
18
+ const keys = Object.keys(process.env);
19
+ if (keys.find((key) => key.startsWith('CIRCLE'))) {
20
+ return 'circleci';
21
+ }
22
+ if (keys.find((key) => key.startsWith('TRAVIS'))) {
23
+ return 'travisci';
24
+ }
25
+ if (keys.find((key) => key.startsWith('BITBUCKET'))) {
26
+ return 'bitbucket';
27
+ }
28
+ if (keys.find((key) => key.startsWith('CIRRUS'))) {
29
+ return 'cirrus';
30
+ }
31
+ if (keys.find((key) => key.startsWith('HEROKU_TEST_RUN_ID'))) {
32
+ return 'heroku';
33
+ }
34
+ if (keys.find((key) => key.startsWith('bamboo') || key.startsWith('BAMBOO'))) {
35
+ return 'bamboo';
36
+ }
37
+ if (keys.find((key) => key.startsWith('CODEBUILD'))) {
38
+ return 'codebuild';
39
+ }
40
+ if (keys.find((key) => key.startsWith('GITHUB_ACTION'))) {
41
+ return 'github_actions';
42
+ }
43
+ if (keys.find((key) => key.startsWith('AGENT_NAME')) ?? keys.find((key) => key.startsWith('BUILD_BUILDNUMBER'))) {
44
+ return 'azure_pipelines';
45
+ }
46
+ if (keys.find((key) => key.startsWith('TEAMCITY'))) {
47
+ return 'teamcity';
48
+ }
49
+ if (keys.find((key) => key.startsWith('GITLAB'))) {
50
+ return 'gitlab';
51
+ }
52
+ if (keys.find((key) => key.startsWith('NEVERCODE'))) {
53
+ return 'nevercode';
54
+ }
55
+ if (keys.find((key) => key.startsWith('WERCKER'))) {
56
+ return 'wercker';
57
+ }
58
+ if (keys.find((key) => key.startsWith('BUILDKITE'))) {
59
+ return 'buildkite';
60
+ }
61
+ if (keys.find((key) => key.startsWith('SEMAPHORE'))) {
62
+ return 'semaphore';
63
+ }
64
+ if (keys.find((key) => key.startsWith('BITRISE'))) {
65
+ return 'bitrise';
66
+ }
67
+ if (keys.find((key) => key.startsWith('BUDDY'))) {
68
+ return 'buddy';
69
+ }
70
+ if (keys.find((key) => key.startsWith('APPVEYOR'))) {
71
+ return 'appveyor';
72
+ }
73
+ if (keys.find((key) => key.startsWith('JENKINS'))) {
74
+ return 'jenkins';
75
+ }
76
+ if (keys.find((key) => key.startsWith('HUDSON'))) {
77
+ return 'hudson';
78
+ }
79
+ if (keys.find((key) => key.startsWith('CF_SF_') || key.startsWith('COPADO_CI'))) {
80
+ return 'copado';
81
+ }
82
+ if (keys.find((key) => key === 'CI' || key === 'CONTINUOUS_INTEGRATION' || key === 'BUILD_ID')) {
83
+ return 'unknown';
84
+ }
85
+ };
86
+ //# sourceMappingURL=guessCI.js.map
package/lib/index.js CHANGED
@@ -135,8 +135,14 @@ You can also use special values to control access to orgs:
135
135
  orgs: sanitizeOrgInput(flags.orgs),
136
136
  });
137
137
  await this.telemetry.start();
138
- process.stdin.on('close', (err) => {
139
- this.telemetry?.sendEvent(err ? 'SERVER_STOPPED_ERROR' : 'SERVER_STOPPED_SUCCESS');
138
+ process.stdin.on('close', () => {
139
+ this.telemetry?.sendEvent('SERVER_STOPPED_SUCCESS');
140
+ this.telemetry?.stop();
141
+ });
142
+ // Handle SIGTERM as a fallback to ensure telemetry is sent
143
+ // https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle#stdio
144
+ process.stdin.on('SIGTERM', () => {
145
+ this.telemetry?.sendEvent('SERVER_STOPPED_SUCCESS');
140
146
  this.telemetry?.stop();
141
147
  });
142
148
  }
@@ -172,6 +178,7 @@ You can also use special values to control access to orgs:
172
178
  this.telemetry = new Telemetry(this.config);
173
179
  await this.telemetry.start();
174
180
  }
181
+ // Track startup failures such as invalid flags, missing dependencies, or initialization errors
175
182
  this.telemetry?.sendEvent('START_ERROR', {
176
183
  error: error.message,
177
184
  stack: error.stack,
@@ -39,7 +39,6 @@ export declare class SfMcpServer extends McpServer implements ToolMethodSignatur
39
39
  * @param {SfMcpServerOptions} [options] - Optional server configuration including telemetry and rate limiting
40
40
  */
41
41
  constructor(serverInfo: Implementation, options?: SfMcpServerOptions);
42
- connect: McpServer['connect'];
43
42
  registerTool<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape>(name: string, config: {
44
43
  title?: string;
45
44
  description?: string;
@@ -55,22 +55,6 @@ export class SfMcpServer extends McpServer {
55
55
  this.telemetry?.sendEvent('SERVER_START_SUCCESS');
56
56
  };
57
57
  }
58
- connect = async (transport) => {
59
- try {
60
- await super.connect(transport);
61
- if (!this.isConnected()) {
62
- this.telemetry?.sendEvent('SERVER_START_ERROR', {
63
- error: 'Server not connected',
64
- });
65
- }
66
- }
67
- catch (error) {
68
- this.telemetry?.sendEvent('SERVER_START_ERROR', {
69
- error: error instanceof Error ? error.message : 'Unknown error',
70
- stack: error instanceof Error ? error.stack : undefined,
71
- });
72
- }
73
- };
74
58
  registerTool(name, config, cb) {
75
59
  const wrappedCb = async (args, extra) => {
76
60
  this.logger.debug(`Tool ${name} called`);
@@ -105,7 +89,13 @@ export class SfMcpServer extends McpServer {
105
89
  this.telemetry?.sendEvent('TOOL_CALLED', {
106
90
  name,
107
91
  runtimeMs,
108
- isError: result.isError,
92
+ // `isError`:
93
+ // Whether the tool call ended in an error.
94
+ //
95
+ // If not set, this is assumed to be false (the call was successful).
96
+ //
97
+ // https://modelcontextprotocol.io/specification/2025-06-18/schema#calltoolresult
98
+ isError: result.isError ?? false,
109
99
  });
110
100
  return result;
111
101
  };
package/lib/telemetry.js CHANGED
@@ -19,6 +19,7 @@ import { join } from 'node:path';
19
19
  import * as os from 'node:os';
20
20
  import { TelemetryReporter } from '@salesforce/telemetry';
21
21
  import { warn } from '@oclif/core/ux';
22
+ import { guessCISystem } from './guessCI.js';
22
23
  const PROJECT = 'salesforce-mcp-server';
23
24
  // WARN: This is intentionally empty! It's populated at the time of publish
24
25
  // This is to prevent telemetry pollution from local clones and forks
@@ -114,6 +115,8 @@ export class Telemetry {
114
115
  nodeVersion: process.version,
115
116
  nodeEnv: process.env.NODE_ENV,
116
117
  origin: this.config.userAgent,
118
+ // CI Information
119
+ ci: guessCISystem(),
117
120
  // Timestamps
118
121
  date: new Date().toUTCString(),
119
122
  timestamp: String(Date.now()),