Use this guide to learn how to contribute to the Salesforce DX MCP Server.
One-Time Setup
Quick Start
Testing
Debugging
Useful Yarn Commands
- Install Node.js. If you need to work with multiple versions of Node, consider using nvm.
- Suggestion: Use the current LTS version of Node.js.
- Install yarn v1 to manage Node.js dependencies.
- Suggestion: Install
yarnglobally using this command:npm install --global yarn.
- Suggestion: Install
- If you're an external contributor, fork the
mainbranch of this Salesforce DX MCP Server repo. - Clone this repository from GitHub.
- Example (ssh):
git clone git@github.com:salesforcecli/mcp.git
- Example (ssh):
- Configure git commit signing.
-
Open a terminal or command window and change to the
mcpdirectory (cd mcp). -
Check out the
mainbranch:git checkout main. -
Get all the latest changes:
git pull. -
Download the NPM dependencies:
yarn install.- Suggestion: If it's been a while since you last ran the command, consider running
yarn clean-allbefore you runyarn install.
- Suggestion: If it's been a while since you last ran the command, consider running
-
Build and lint the code:
yarn build. -
Create a branch off of
mainfor your new work:git checkout -b <branch_name>.- Suggestion: Name your branch using this format:
<initials>/<work-title>. Example:mb/refactor-tests
- Suggestion: Name your branch using this format:
-
Make your code changes and then build:
yarn build. -
Update your MCP client to launch your local build using
nodeinstead of the published npm package usingnpx. For example, if you're using VS Code, update your MCP configuration file like this (change/full/path/toto the full location where you cloned themcprepo):{ "servers": { "Salesforce DX": { "command": "node", "args": ["/full/path/to/mcp/bin/run.js", "--toolsets", "all", "--orgs", "ALLOW_ALL_ORGS"] } } } -
Start the Salesforce DX MCP server and call the tools using natural language prompts. See [./README.md] for details.
-
Write tests and run them:
yarn test. See Unit Tests for details. -
See all changed files and verify that you want to commit them:
git status. -
Add all files to staging:
git add .(Make sure you include the period!) -
Commit staged files with a helpful commit message that adheres to the conventional commits specification:
git commit -m "feat: add new tool". -
Push commit(s) to remote:
git push -u origin <branch_name>. -
Create a pull request (PR) using the GitHub UI.
All changes must have associated unit tests when possible. End-to-end tests for tools will be added in the future.
For manual tool testing, use the MCP Inspector to make tool calls directly from your browser or terminal. This type of testing is handy when you start working on a new tool and you want to focus on the tool logic first before optimizing the agent instructions.
First install the MCP Inspector CLI:
npm i -g @modelcontextprotocol/inspector
Then follow the steps for the type of testing you want to do: from the browser or from a terminal.
-
Build the local server:
yarn build. -
Start the MCP Inspector server:
mcp-inspector node lib/index.js --orgs DEFAULT_TARGET_ORG. -
If successful, open the specified localhost URL in your browser. In this example it's
http://127.0.0.1:6274:MCP Inspector is up and running at http://127.0.0.1:6274 -
Click the
Connectbutton; you should see this message in the bottom-left panel:✅ Salesforce MCP Server running on stdio -
Click
List Tools, then select one of the tools, fill the required parameters, and clickRun Tool.
- Build the local server:
yarn build. - Use the MCP Inspector CLI to call a specific tool with its parameters.
This example calls the sf-query-org tool from the context of a Salesforce DX project:
mcp-inspector --cli node bin/run.js --orgs DEFAULT_TARGET_ORG \
--method tools/call \
--tool-name sf-query-org \
--tool-arg query="select id from account limit 5" \
--tool-arg usernameOrAlias=dreamhouse \
--tool-arg directory="/path/to/sfdx-project"
{
"content": [
{
"type": "text",
"text": "SOQL query results for dreamhouse:\n\n{\n \"records\": [\n {\n \"attributes\": {\n \"type\": \"Account\",\n \"url\": \"/services/d
ata/v63.0/sobjects/Account/001DK00001BFbHbYAL\"\n },\n \"Id\": \"001DK00001BFbHbYAL\"\n }\n ],\n \"totalSize\": 1,\n \"done\": true\n}"
}
],
"isError": false
}Learn more about each tool argument by looking at its definition in the code, the MCP Inspector browser UI, or by listing all tools using the MCP Inspector CLI. For example:
mcp-inspector --cli node bin/run.js --orgs DEFAULT_TARGET_ORG --method tools/listUnit tests are run with yarn test and use the Mocha test framework. Tests are located in the test directory and are named with the pattern, test/**/*.test.ts.
Confidence tests validate that the MCP server tools are accurately invoked by various LLM models through the Salesforce LLM Gateway API. These tests ensure that natural language prompts correctly trigger the expected tools with appropriate parameters, maintaining the quality of the AI-powered tool selection.
-
Set up API access: Follow this documentation to setup an External Client App that will give you access to the Models API. Once you have the consumer key and secret from the External Client App, you'll need to add these to environment variables:
export SF_MCP_CONFIDENCE_CONSUMER_KEY=your_client_id_here export SF_MCP_CONFIDENCE_CONSUMER_SECRET=your_client_secret_here export SF_MCP_CONFIDENCE_INSTANCE_URL=https://your_instance.salesforce.com
These environment variables are used to generate a JWT token that will be used to authenticate with the Models API.
-
Run a confidence test:
yarn test:confidence --file test/confidence/sf-deploy-metadata.yml
Confidence tests are defined in YAML files located in test/confidence/. Each test file specifies:
- Models: Which LLM models to test against. See the Agentforce Developer Guide for available models.
- Initial Context: Background information provided to the model
- Test Cases: Natural language utterances with expected tool invocations and confidence thresholds
The tests run multiple iterations (default: 5) to calculate confidence levels and ensure consistent tool selection across different model runs. This can be adjusted by passing the --runs flag when running the tests, like this:
yarn test:confidence test/confidence/sf-deploy-metadata.yml --runs 2Tests measure two types of confidence:
- Tool Confidence: Whether the correct tool was invoked
- Parameter Confidence: Whether the tool was called with the expected parameters
Failed tests indicate that either:
- The model selected the wrong tool for a given prompt
- The model selected the correct tool but with incorrect parameters
- The confidence level fell below the specified threshold
These failures help identify areas where tool descriptions or agent instructions need improvement.
Note
This section assumes you're using Visual Studio Code (VS Code).
You can use the VS Code debugger with the MCP Inspector CLI to step through the code of your MCP tools:
- Make a change in a tool file.
- Set a breakpoint.
- Build the local MCP server:
yarn compile. - Call the tool using the MCP Inspector CLI.
- In the VS Code debugger, select the
Attach to Debug Hook Processlaunch config and start debugging.
Here's an example of calling the sf-query-org tool:
MCP_SERVER_REQUEST_TIMEOUT=120000 mcp-inspector --cli node --inspect-brk bin/run.js -o DEFAULT_TARGET_ORG --no-telemetry --method tools/call \
--tool-name sf-query-org \
--tool-arg directory="/path/to/sfdx-project" \
--tool-arg query="select name from Property__c order by name asc" \
--tool-arg usernameOrAlias=dreamhouseWe suggest you set MCP_SERVER_REQUEST_TIMEOUT to 120000ms (2 minutes) to allow longer debugging sessions without having the MCP Inspector client timeout.
For other configuration values see: https://github.com/modelcontextprotocol/inspector?tab=readme-ov-file#configuration
Important
You must compile the local MCP server using yarn compile after every change in a TypeScript file, otherwise breakpoints in the TypeScript files might not match the running JavaScript code.
Downloads all NPM dependencies into the node_modules directory.
Compiles the TypeScript code to JavaScript.
Watches for file changes and compiles the TypeScript code to JavaScript.
Lints all the TypeScript code using ESLint.
Compiles and lints all the TypeScript code. (Basically the same as yarn compile && yarn lint).
Cleans all generated files and directories. Run yarn clean-all to also clean up the node_modules directories.
Runs unit tests (Mocha) for the project using ts-node.