@salesforce/mcp 0.17.1-dev.0 → 0.17.2-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/lib/index.d.ts +1 -1
- package/lib/index.js +7 -88
- package/lib/main-server-provider.d.ts +7 -0
- package/lib/main-server-provider.js +31 -0
- package/lib/registry.d.ts +3 -0
- package/lib/{tools/core/index.js → registry.js} +11 -4
- package/lib/scripts/build-index.js +1 -1
- package/lib/services.d.ts +12 -0
- package/lib/services.js +34 -0
- package/lib/sf-mcp-server.d.ts +12 -7
- package/lib/sf-mcp-server.js +6 -20
- package/lib/telemetry.d.ts +2 -1
- package/lib/tools/sf-enable-tools.d.ts +23 -0
- package/lib/tools/sf-enable-tools.js +77 -0
- package/lib/tools/sf-list-tools.d.ts +8 -0
- package/lib/tools/{dynamic/sf-list-tools.js → sf-list-tools.js} +33 -9
- package/lib/tools/sf-suggest-cli-command.d.ts +25 -0
- package/lib/tools/{core/sf-suggest-cli-command.js → sf-suggest-cli-command.js} +46 -18
- package/lib/utils/assets.d.ts +21 -0
- package/lib/{assets.js → utils/assets.js} +23 -33
- package/lib/{shared → utils}/auth.d.ts +3 -8
- package/lib/{shared → utils}/auth.js +2 -42
- package/lib/utils/registry-utils.d.ts +4 -0
- package/lib/utils/registry-utils.js +87 -0
- package/lib/utils/tools.d.ts +41 -0
- package/lib/{shared → utils}/tools.js +0 -69
- package/lib/utils/types.d.ts +5 -0
- package/package.json +8 -6
- package/README.md +0 -263
- package/lib/assets.d.ts +0 -44
- package/lib/shared/params.d.ts +0 -5
- package/lib/shared/params.js +0 -46
- package/lib/shared/tools.d.ts +0 -68
- package/lib/shared/types.d.ts +0 -33
- package/lib/shared/utils.d.ts +0 -11
- package/lib/shared/utils.js +0 -71
- package/lib/tools/core/index.d.ts +0 -3
- package/lib/tools/core/sf-get-username.d.ts +0 -17
- package/lib/tools/core/sf-get-username.js +0 -109
- package/lib/tools/core/sf-resume.d.ts +0 -20
- package/lib/tools/core/sf-resume.js +0 -149
- package/lib/tools/core/sf-suggest-cli-command.d.ts +0 -5
- package/lib/tools/data/index.d.ts +0 -1
- package/lib/tools/data/index.js +0 -17
- package/lib/tools/data/sf-query-org.d.ts +0 -20
- package/lib/tools/data/sf-query-org.js +0 -66
- package/lib/tools/dynamic/index.d.ts +0 -2
- package/lib/tools/dynamic/index.js +0 -18
- package/lib/tools/dynamic/sf-enable-tools.d.ts +0 -2
- package/lib/tools/dynamic/sf-enable-tools.js +0 -42
- package/lib/tools/dynamic/sf-list-tools.d.ts +0 -2
- package/lib/tools/metadata/index.d.ts +0 -2
- package/lib/tools/metadata/index.js +0 -18
- package/lib/tools/metadata/sf-deploy-metadata.d.ts +0 -27
- package/lib/tools/metadata/sf-deploy-metadata.js +0 -164
- package/lib/tools/metadata/sf-retrieve-metadata.d.ts +0 -2
- package/lib/tools/metadata/sf-retrieve-metadata.js +0 -128
- package/lib/tools/orgs/index.d.ts +0 -5
- package/lib/tools/orgs/index.js +0 -21
- package/lib/tools/orgs/sf-create-org-snapshot.d.ts +0 -23
- package/lib/tools/orgs/sf-create-org-snapshot.js +0 -88
- package/lib/tools/orgs/sf-create-scratch-org.d.ts +0 -50
- package/lib/tools/orgs/sf-create-scratch-org.js +0 -132
- package/lib/tools/orgs/sf-delete-org.d.ts +0 -14
- package/lib/tools/orgs/sf-delete-org.js +0 -65
- package/lib/tools/orgs/sf-list-all-orgs.d.ts +0 -11
- package/lib/tools/orgs/sf-list-all-orgs.js +0 -59
- package/lib/tools/orgs/sf-org-open.d.ts +0 -17
- package/lib/tools/orgs/sf-org-open.js +0 -57
- package/lib/tools/testing/index.d.ts +0 -2
- package/lib/tools/testing/index.js +0 -18
- package/lib/tools/testing/sf-test-agents.d.ts +0 -21
- package/lib/tools/testing/sf-test-agents.js +0 -84
- package/lib/tools/testing/sf-test-apex.d.ts +0 -40
- package/lib/tools/testing/sf-test-apex.js +0 -132
- package/lib/tools/users/index.d.ts +0 -1
- package/lib/tools/users/index.js +0 -17
- package/lib/tools/users/sf-assign-permission-set.d.ts +0 -20
- package/lib/tools/users/sf-assign-permission-set.js +0 -89
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/npm-shrinkwrap.json +0 -18827
- /package/lib/{shared → utils}/cache.d.ts +0 -0
- /package/lib/{shared → utils}/cache.js +0 -0
- /package/lib/{shared → utils}/rate-limiter.d.ts +0 -0
- /package/lib/{shared → utils}/rate-limiter.js +0 -0
- /package/lib/{shared → utils}/types.js +0 -0
package/README.md
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
# mcp
|
|
2
|
-
|
|
3
|
-
MCP Server for Interacting with Salesforce Orgs
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@salesforce/mcp) [](https://opensource.org/license/apache-2-0)
|
|
6
|
-
|
|
7
|
-
## Overview of the Salesforce DX MCP Server (Developer Preview)
|
|
8
|
-
|
|
9
|
-
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.
|
|
10
|
-
|
|
11
|
-
Key Features:
|
|
12
|
-
|
|
13
|
-
- Direct interaction with Salesforce orgs through LLM-driven tools.
|
|
14
|
-
- Secure access using TypeScript libraries (not shelling out to the `sf` Salesforce CLI).
|
|
15
|
-
- Improved security by avoiding the exposure of secrets in plain text.
|
|
16
|
-
- Granular access control with org allowlisting.
|
|
17
|
-
- Modular tool architecture for easy extensibility.
|
|
18
|
-
|
|
19
|
-
**NOTE**: The Salesforce DX MCP Server is available as a developer preview. The feature isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. All commands, parameters, and other features are subject to change or deprecation at any time, with or without notice. Don't implement functionality developed with these commands or tools. As we continue to enhance and refine the implementation, the available functionality and tools may evolve. We welcome feedback and contributions to help shape the future of this project.
|
|
20
|
-
|
|
21
|
-
### Security Features
|
|
22
|
-
|
|
23
|
-
The Salesforce DX MCP Server was designed with security as a top priority.
|
|
24
|
-
|
|
25
|
-
- **Uses TypeScript libraries directly**
|
|
26
|
-
|
|
27
|
-
- Greatly decreases the size of the MCP Server.
|
|
28
|
-
- Significantly reduces the risk of remote code execution (RCE).
|
|
29
|
-
|
|
30
|
-
- **No secrets needed in configuration**
|
|
31
|
-
|
|
32
|
-
- Eliminates the risk of plain text secret exposure.
|
|
33
|
-
- Accesses pre-existing (encrypted) auth files on the user's machine.
|
|
34
|
-
- Implements allowlisting for auth info key/values to prevent sensitive data exposure.
|
|
35
|
-
|
|
36
|
-
- **No secrets exposed via MCP tools**
|
|
37
|
-
|
|
38
|
-
- Prevents other tools from accessing unencrypted tokens.
|
|
39
|
-
- Tools pass usernames around instead of tokens.
|
|
40
|
-
|
|
41
|
-
- **Granular access control**
|
|
42
|
-
|
|
43
|
-
- MCP Server can access auth info for only orgs that have been explicitly allowlisted.
|
|
44
|
-
- Users specify allowed orgs when starting the server.
|
|
45
|
-
|
|
46
|
-
## Get Started Using VS Code as the Client
|
|
47
|
-
|
|
48
|
-
Want to jump in and see what all the fuss is about? Read on!
|
|
49
|
-
|
|
50
|
-
This example uses Visual Studio Code (VS Code) as the MCP client because it's a standard Salesforce DX development tool. After you configure it with the Salesforce DX MCP Server, you then use GitHub Copilot and natural language to easily execute typical Salesforce DX development tasks, such as listing your authorized orgs, viewing org records, and deploying or retrieving metadata.
|
|
51
|
-
|
|
52
|
-
But you're not limited to using only VS Code and Copilot! You can [configure many other clients](README.md#configure-other-clients-to-use-the-salesforce-dx-mcp-server) to use the Salesforce DX MCP Server, such as Cursor, Cline, Claude Desktop, Zed, Windsurf, and more.
|
|
53
|
-
|
|
54
|
-
**Before You Begin**
|
|
55
|
-
|
|
56
|
-
For the best getting-started experience, make sure that you have a Salesforce DX environment set up on your computer. In particular:
|
|
57
|
-
|
|
58
|
-
- [Install Salesforce CLI](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm) on your computer.
|
|
59
|
-
- [Install VS Code](https://code.visualstudio.com/docs) on your computer.
|
|
60
|
-
- [Create a Salesforce DX project](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm) and open it in VS Code. You can also clone an example repo, such as [dreamhouse-lwc](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro_sample_repo.htm), which is a ready-to-use DX project that contains a simple Salesforce application, with metadata and test data.
|
|
61
|
-
- [Authorize at least one Salesforce org](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_web_flow.htm) to use with your DX project. You can also create a scratch org.
|
|
62
|
-
|
|
63
|
-
**Let's Do It**
|
|
64
|
-
|
|
65
|
-
1. Create a `.vscode/mcp.json` file at the root of your DX project and add this JSON:
|
|
66
|
-
|
|
67
|
-
```json
|
|
68
|
-
{
|
|
69
|
-
"servers": {
|
|
70
|
-
"Salesforce DX": {
|
|
71
|
-
"type": "stdio",
|
|
72
|
-
"command": "npx",
|
|
73
|
-
"args": ["-y", "@salesforce/mcp", "--orgs", "DEFAULT_TARGET_ORG", "--toolsets", "all"]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
You can also configure the MCP server globally by editing the VS Code [settings.json](https://code.visualstudio.com/docs/configure/settings#_settings-file-locations) file and adding a similar JSON snippet but contained in an `mcp:servers` section.
|
|
80
|
-
|
|
81
|
-
The `--orgs` argument is required and specifies the authorized orgs you're allowing the MCP server to access. The `--toolsets` argument is optional and specifies the toolsets it should consult when determining the specific tool to run. See [Configure Orgs and Toolsets](README.md#configure-orgs-and-toolsets) for the available values for the two arguments.
|
|
82
|
-
|
|
83
|
-
1. Open VS Code, go to **View -> Command Palette** and enter **MCP: List Servers**.
|
|
84
|
-
|
|
85
|
-
TIP: You can also get to the command palette by pressing press Ctrl+Shift+P (Windows or Linux) or Command-Shift-P (macOS).
|
|
86
|
-
|
|
87
|
-
1. Click `Salesforce DX`, then **Start Server**.
|
|
88
|
-
|
|
89
|
-
Check the Output tab for the server status.
|
|
90
|
-
|
|
91
|
-
1. Run **Chat: Open Chat (Agent)** from the command palette to start a new GitHub Copilot chat session.
|
|
92
|
-
|
|
93
|
-
Be sure your Copilot chat window is in `Agent` mode; if you're in `Ask` or `Edit` mode, use the [little drop-down](https://github.blog/ai-and-ml/github-copilot/copilot-ask-edit-and-agent-modes-what-they-do-and-when-to-use-them/) to switch.
|
|
94
|
-
|
|
95
|
-
1. In the GitHub Copilot chat window, use natural language to explain what you want to do. The MCP server determines which configured tool to use, and then shows it to you along with other information. Click **Continue** to run the tool and see the results of your request.
|
|
96
|
-
|
|
97
|
-
Try out these examples:
|
|
98
|
-
|
|
99
|
-
- List all my orgs.
|
|
100
|
-
- Which are my active scratch orgs?
|
|
101
|
-
- Show me all the accounts in the org with alias my-org.
|
|
102
|
-
- Deploy everything in my project to the org with alias my-org.
|
|
103
|
-
|
|
104
|
-
1. To stop, restart, or view the MCP server configuration, run the **MCP: List Servers** command, click `Salesforce DX`, then click the appropriate option.
|
|
105
|
-
|
|
106
|
-
## Configure Orgs and Toolsets
|
|
107
|
-
|
|
108
|
-
You configure the Salesforce DX MCP Server by specifying at least one authorized org and an optional list of MCP toolsets.
|
|
109
|
-
|
|
110
|
-
### Configure Orgs
|
|
111
|
-
|
|
112
|
-
The Salesforce MCP tools require an org, and so you must include the required `--orgs` argument to specify at least one authorized org when you configure the MCP server. Separate multiple values with commas.
|
|
113
|
-
|
|
114
|
-
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.
|
|
115
|
-
|
|
116
|
-
These are the available values for the `--orgs` argument:
|
|
117
|
-
|
|
118
|
-
- `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.
|
|
119
|
-
- `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.
|
|
120
|
-
- `ALLOW_ALL_ORGS` - Allow access to all authorized orgs. Use this value with caution.
|
|
121
|
-
- `<username or alias>` - Allow access to a specific org by specifying its username or alias.
|
|
122
|
-
|
|
123
|
-
This example shows how to specify that the MCP tools run against your default org when you configure the MCP server for VS Code:
|
|
124
|
-
|
|
125
|
-
```json
|
|
126
|
-
"mcp": {
|
|
127
|
-
"servers": {
|
|
128
|
-
"Salesforce DX": {
|
|
129
|
-
"type": "stdio",
|
|
130
|
-
"command": "npx",
|
|
131
|
-
"args": ["-y", "@salesforce/mcp", "--orgs", "DEFAULT_TARGET_ORG"]
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
This sample snippet shows how to configure access to your default Dev Hub org and an org with username `test-org@example.com`:
|
|
138
|
-
|
|
139
|
-
```json
|
|
140
|
-
"args": ["-y", "@salesforce/mcp", "--orgs", "DEFAULT_TARGET_DEV_HUB,test-org@example.com"]
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
This sample snippet shows how to configure access to two orgs for which you specified aliases when you authorized them:
|
|
144
|
-
|
|
145
|
-
```json
|
|
146
|
-
"args": ["-y", "@salesforce/mcp", "--orgs", "my-scratch-org,my-dev-hub"]
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Configure Toolsets
|
|
150
|
-
|
|
151
|
-
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.
|
|
152
|
-
|
|
153
|
-
Use the `--toolsets` (or short name `-t`) argument to specify the toolsets when you configure the Salesforce DX MCP Server. Separate multiple toolsets with commas. The `--toolsets` argument is optional; if you don't specify it, the MCP server is configured with all toolsets.
|
|
154
|
-
|
|
155
|
-
These are the available toolsets:
|
|
156
|
-
|
|
157
|
-
- `all` (default) - Enables all available tools from all toolsets.
|
|
158
|
-
- `orgs` - [Tools to manage your authorized orgs.](README.md#orgs-toolset)
|
|
159
|
-
- `data` - [Tools to manage the data in your org, such as listing all accounts.](README.md#data-toolset)
|
|
160
|
-
- `users` - [Tools to manage org users, such as assigning a permission set.](README.md#users-toolset)
|
|
161
|
-
- `metadata` - [Tools to deploy and retrieve metadata to and from your org and your DX project.](README.md#metadata-toolset)
|
|
162
|
-
- `testing` - [Tools to test your code and features](README.md#testing-toolset)
|
|
163
|
-
|
|
164
|
-
This example shows how to enable the `data`, `orgs`, and `metadata` toolsets when configuring the MCP server for VS Code:
|
|
165
|
-
|
|
166
|
-
```json
|
|
167
|
-
"mcp": {
|
|
168
|
-
"servers": {
|
|
169
|
-
"Salesforce DX": {
|
|
170
|
-
"type": "stdio",
|
|
171
|
-
"command": "npx",
|
|
172
|
-
"args": ["-y", "@salesforce/mcp", "--orgs", "DEFAULT_TARGET_ORG", "--toolsets", "data,orgs,metadata"]
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
#### Dynamic Tools (Experimental)
|
|
179
|
-
|
|
180
|
-
The `--dynamic-tools` flag enables dynamic tool discovery and loading. When this flag is set, the MCP server starts with a minimal set of core tools and will load new tools as the need arises. This is useful for reducing initial context size and improving LLM performance.
|
|
181
|
-
|
|
182
|
-
**NOTE:** This feature works in VSCode and Cline but may not work in other environments.
|
|
183
|
-
|
|
184
|
-
#### Core Toolset (always enabled)
|
|
185
|
-
|
|
186
|
-
Includes these tools:
|
|
187
|
-
|
|
188
|
-
- `sf-get-username` - Determines the appropriate username or alias for Salesforce operations, handling both default orgs and Dev Hubs.
|
|
189
|
-
- `sf-resume` - Resumes a long-running operation that wasn't completed by another tool.
|
|
190
|
-
- `sf-suggest-cli-command` - Suggests an `sf` Salesforce CLI command based on a natural language query. The tool finds relevant CLI commands from a local index and uses an LLM to construct the precise command to fulfill your request.
|
|
191
|
-
|
|
192
|
-
#### Orgs Toolset
|
|
193
|
-
|
|
194
|
-
Includes this tool:
|
|
195
|
-
|
|
196
|
-
- `sf-list-all-orgs` - Lists all configured Salesforce orgs, with optional connection status checking.
|
|
197
|
-
|
|
198
|
-
#### Data Toolset
|
|
199
|
-
|
|
200
|
-
Includes this tool:
|
|
201
|
-
|
|
202
|
-
- `sf-query-org` - Runs a SOQL query against a Salesforce org.
|
|
203
|
-
|
|
204
|
-
#### Users Toolset
|
|
205
|
-
|
|
206
|
-
Includes this tool:
|
|
207
|
-
|
|
208
|
-
- `sf-assign-permission-set` - Assigns a permission set to the user or on behalf of another user.
|
|
209
|
-
|
|
210
|
-
#### Metadata Toolset
|
|
211
|
-
|
|
212
|
-
Includes these tools:
|
|
213
|
-
|
|
214
|
-
- `sf-deploy-metadata` - Deploys metadata from your DX project to an org.
|
|
215
|
-
- `sf-retrieve-metadata` - Retrieves metadata from your org to your DX project.
|
|
216
|
-
|
|
217
|
-
#### Testing Toolset
|
|
218
|
-
|
|
219
|
-
Includes these tools:
|
|
220
|
-
|
|
221
|
-
- `sf-test-agents` - Executes agent tests in your org.
|
|
222
|
-
- `sf-test-apex` - Executes apex tests in your org.
|
|
223
|
-
|
|
224
|
-
## Configure Other Clients to Use the Salesforce DX MCP Server
|
|
225
|
-
|
|
226
|
-
**Cursor**
|
|
227
|
-
|
|
228
|
-
To configure [Cursor](https://www.cursor.com/) to work with Salesforce DX MCP Server, add this snippet to your Cursor `mcp.json` file:
|
|
229
|
-
|
|
230
|
-
```json
|
|
231
|
-
{
|
|
232
|
-
"mcpServers": {
|
|
233
|
-
"Salesforce DX": {
|
|
234
|
-
"command": "npx",
|
|
235
|
-
"args": ["-y", "@salesforce/mcp", "--orgs", "DEFAULT_TARGET_ORG", "--toolsets", "all"]
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
**Cline**
|
|
242
|
-
|
|
243
|
-
To configure [Cline](https://cline.bot), add this snippet to your Cline `cline_mcp_settings.json` file:
|
|
244
|
-
|
|
245
|
-
```json
|
|
246
|
-
{
|
|
247
|
-
"mcpServers": {
|
|
248
|
-
"Salesforce DX": {
|
|
249
|
-
"command": "npx",
|
|
250
|
-
"args": ["-y", "@salesforce/mcp", "--orgs", "DEFAULT_TARGET_ORG", "--toolsets", "all"]
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
**Other Clients**
|
|
257
|
-
|
|
258
|
-
For these other clients, refer to their documentation for adding MCP servers and follow the same pattern as in the preceding VS Code and Cursor JSON snippets:
|
|
259
|
-
|
|
260
|
-
- [Claude Desktop](https://claude.ai/download)
|
|
261
|
-
- [Zed](https://github.com/zed-industries/zed)
|
|
262
|
-
- [Windsurf](https://www.windsurf.com/)
|
|
263
|
-
- [Trae](https://trae.ai)
|
package/lib/assets.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import faiss from 'faiss-node';
|
|
2
|
-
import { FeatureExtractionPipeline } from '@huggingface/transformers';
|
|
3
|
-
type CommandData = {
|
|
4
|
-
id: number;
|
|
5
|
-
command: string;
|
|
6
|
-
summary: string;
|
|
7
|
-
description: string;
|
|
8
|
-
examples?: string[];
|
|
9
|
-
flags?: Array<{
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
required?: boolean;
|
|
14
|
-
options?: string[];
|
|
15
|
-
atLeastOne?: boolean;
|
|
16
|
-
exactlyOne?: boolean;
|
|
17
|
-
relationships?: string[];
|
|
18
|
-
default?: string | boolean | number | string[];
|
|
19
|
-
}>;
|
|
20
|
-
embeddingText: string;
|
|
21
|
-
};
|
|
22
|
-
type Assets = {
|
|
23
|
-
commands: CommandData[];
|
|
24
|
-
commandNames: string[];
|
|
25
|
-
faissIndex: faiss.IndexFlatL2;
|
|
26
|
-
embedder: FeatureExtractionPipeline;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Conditionally builds or rebuilds a FAISS index based on its existence and age.
|
|
30
|
-
*
|
|
31
|
-
* This function checks if a FAISS index file exists in the specified output directory.
|
|
32
|
-
* If the index exists but is older than one week, it triggers a rebuild. If the index
|
|
33
|
-
* doesn't exist, it initiates the initial build process. The build process can run as a
|
|
34
|
-
* detached child process or in the same process depending on the detached parameter.
|
|
35
|
-
*
|
|
36
|
-
* @param outputDir - The directory path where the FAISS index should be located or created
|
|
37
|
-
* @param detached - Whether to run the build process detached (default: true)
|
|
38
|
-
*
|
|
39
|
-
* @remarks
|
|
40
|
-
* - Sets the global CACHED_DATA_DIR variable to the provided outputDir. This is used to locate the index file.
|
|
41
|
-
*/
|
|
42
|
-
export declare function maybeBuildIndex(outputDir: string, detached?: boolean): Promise<void>;
|
|
43
|
-
export declare function getAssets(): Promise<Assets>;
|
|
44
|
-
export {};
|
package/lib/shared/params.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const usernameOrAliasParam: z.ZodString;
|
|
3
|
-
export declare const useToolingApiParam: z.ZodOptional<z.ZodBoolean>;
|
|
4
|
-
export declare const baseAbsolutePathParam: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
-
export declare const directoryParam: z.ZodEffects<z.ZodString, string, string>;
|
package/lib/shared/params.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
import { z } from 'zod';
|
|
17
|
-
import { sanitizePath } from './utils.js';
|
|
18
|
-
/*
|
|
19
|
-
* A collection of reusable Tool parameters
|
|
20
|
-
*/
|
|
21
|
-
export const usernameOrAliasParam = z.string()
|
|
22
|
-
.describe(`The username or alias for the Salesforce org to run this tool against.
|
|
23
|
-
|
|
24
|
-
AGENT INSTRUCTIONS:
|
|
25
|
-
If it is not clear what username or alias is, run the #sf-get-username tool.
|
|
26
|
-
NEVER guess or make-up a username or alias, use #sf-get-username if you are not sure.
|
|
27
|
-
DO NOT use #sf-get-username if the user mentions an alias or username, like "for my an-alias org" or "for my test-prgelc2petd9@example.com org".
|
|
28
|
-
|
|
29
|
-
USAGE:
|
|
30
|
-
...for the my-alias org
|
|
31
|
-
...for my 'my-alias' user
|
|
32
|
-
...for alias myAlias
|
|
33
|
-
...for my 'test@example.com' user
|
|
34
|
-
...for the 'test@example.com' org`);
|
|
35
|
-
export const useToolingApiParam = z.boolean().optional().describe('Use Tooling API for the operation');
|
|
36
|
-
export const baseAbsolutePathParam = z
|
|
37
|
-
.string()
|
|
38
|
-
.refine(sanitizePath, 'Invalid path: Must be an absolute path and cannot contain path traversal sequences');
|
|
39
|
-
export const directoryParam = baseAbsolutePathParam.describe(`The directory to run this tool from.
|
|
40
|
-
AGENT INSTRUCTIONS:
|
|
41
|
-
We need to know where the user wants to run this tool from.
|
|
42
|
-
Look at your current Workspace Context to determine this filepath.
|
|
43
|
-
ALWAYS USE A FULL PATH TO THE DIRECTORY.
|
|
44
|
-
Unless the user explicitly asks for a different directory, or a new directory is created from the action of a tool, use this same directory for future tool calls.
|
|
45
|
-
`);
|
|
46
|
-
//# sourceMappingURL=params.js.map
|
package/lib/shared/tools.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
export declare const TOOLSETS: readonly ["orgs", "data", "users", "metadata", "testing", "experimental"];
|
|
3
|
-
type Toolset = (typeof TOOLSETS)[number];
|
|
4
|
-
export declare const CORE_TOOLS: string[];
|
|
5
|
-
/**
|
|
6
|
-
* Determines which toolsets should be enabled based on the provided toolsets array and dynamic tools flag.
|
|
7
|
-
*
|
|
8
|
-
* @param {Array<Toolset | 'all'>} toolsets - Array of toolsets to enable. Can include 'all' to enable all non-experimental toolsets.
|
|
9
|
-
* @param {boolean} dynamicTools - Flag indicating whether dynamic tools should be enabled. When true, only core and dynamic toolsets are enabled.
|
|
10
|
-
* @returns {Record<Toolset | 'dynamic' | 'core', boolean>} Object mapping each toolset to a boolean indicating whether it should be enabled.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // Enable all toolsets except experimental
|
|
14
|
-
* determineToolsetsToEnable(['all'], false)
|
|
15
|
-
* // Returns: { core: true, data: true, dynamic: false, experimental: false, metadata: true, orgs: true, testing: true, users: true }
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // Enable only dynamic tools
|
|
19
|
-
* determineToolsetsToEnable([], true)
|
|
20
|
-
* // Returns: { core: true, data: false, dynamic: true, experimental: false, metadata: false, orgs: false, testing: false, users: false }
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* // Enable specific toolsets
|
|
24
|
-
* determineToolsetsToEnable(['data', 'users'], false)
|
|
25
|
-
* // Returns: { core: true, data: true, dynamic: false, experimental: false, metadata: false, orgs: false, testing: false, users: true }
|
|
26
|
-
*/
|
|
27
|
-
export declare function determineToolsetsToEnable(toolsets: Array<Toolset | 'all'>, dynamicTools: boolean): Record<Toolset | 'dynamic' | 'core', boolean>;
|
|
28
|
-
/**
|
|
29
|
-
* Add a tool to the cache
|
|
30
|
-
*/
|
|
31
|
-
export declare function addTool(tool: RegisteredTool, name: string): Promise<{
|
|
32
|
-
success: boolean;
|
|
33
|
-
message: string;
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Enable an individual tool
|
|
37
|
-
*/
|
|
38
|
-
export declare function enableTool(toolName: string): Promise<{
|
|
39
|
-
success: boolean;
|
|
40
|
-
message: string;
|
|
41
|
-
}>;
|
|
42
|
-
export declare function enableTools(tools: string[]): Promise<Array<{
|
|
43
|
-
success: boolean;
|
|
44
|
-
message: string;
|
|
45
|
-
}>>;
|
|
46
|
-
/**
|
|
47
|
-
* Disable an individual tool
|
|
48
|
-
*/
|
|
49
|
-
export declare function disableTool(toolName: string): Promise<{
|
|
50
|
-
success: boolean;
|
|
51
|
-
message: string;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Get individual tool status
|
|
55
|
-
*/
|
|
56
|
-
export declare function getToolStatus(toolName: string): Promise<{
|
|
57
|
-
enabled: boolean;
|
|
58
|
-
description: string;
|
|
59
|
-
} | undefined>;
|
|
60
|
-
/**
|
|
61
|
-
* List all individual tools with their status
|
|
62
|
-
*/
|
|
63
|
-
export declare function listAllTools(): Promise<Array<{
|
|
64
|
-
name: string;
|
|
65
|
-
enabled: boolean;
|
|
66
|
-
description: string;
|
|
67
|
-
}>>;
|
|
68
|
-
export {};
|
package/lib/shared/types.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ConfigInfo } from '@salesforce/core';
|
|
2
|
-
import { type Nullable } from '@salesforce/ts-types';
|
|
3
|
-
import { RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
-
export type ConfigInfoWithCache = {
|
|
5
|
-
key: string;
|
|
6
|
-
location?: ConfigInfo['location'];
|
|
7
|
-
value: string;
|
|
8
|
-
cached?: boolean;
|
|
9
|
-
path: string;
|
|
10
|
-
};
|
|
11
|
-
export type SanitizedOrgAuthorization = {
|
|
12
|
-
aliases?: Nullable<string[]>;
|
|
13
|
-
configs?: Nullable<string[]>;
|
|
14
|
-
username?: string;
|
|
15
|
-
instanceUrl?: string;
|
|
16
|
-
isScratchOrg?: boolean;
|
|
17
|
-
isDevHub?: boolean;
|
|
18
|
-
isSandbox?: boolean;
|
|
19
|
-
orgId?: string;
|
|
20
|
-
oauthMethod?: string;
|
|
21
|
-
isExpired?: boolean | 'unknown';
|
|
22
|
-
};
|
|
23
|
-
export type ToolTextResponse = {
|
|
24
|
-
isError: boolean;
|
|
25
|
-
content: Array<{
|
|
26
|
-
type: 'text';
|
|
27
|
-
text: string;
|
|
28
|
-
}>;
|
|
29
|
-
};
|
|
30
|
-
export type ToolInfo = {
|
|
31
|
-
tool: RegisteredTool;
|
|
32
|
-
name: string;
|
|
33
|
-
};
|
package/lib/shared/utils.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type ToolTextResponse } from './types.js';
|
|
2
|
-
export declare function textResponse(text: string, isError?: boolean): ToolTextResponse;
|
|
3
|
-
/**
|
|
4
|
-
* Gets the enabled toolsets based on user input and validates against available toolsets
|
|
5
|
-
*
|
|
6
|
-
* @param availableToolsets - The list of available toolsets
|
|
7
|
-
* @param toolsetsInput - The comma-separated list of toolsets
|
|
8
|
-
* @returns A Set of enabled toolsets
|
|
9
|
-
*/
|
|
10
|
-
export declare function getEnabledToolsets(availableToolsets: string[], toolsetsInput: string): Set<string>;
|
|
11
|
-
export declare function sanitizePath(projectPath: string): boolean;
|
package/lib/shared/utils.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
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 no-console */
|
|
17
|
-
import path from 'node:path';
|
|
18
|
-
// TODO: break into two helpers? One for errors and one for success?
|
|
19
|
-
export function textResponse(text, isError = false) {
|
|
20
|
-
if (text === '')
|
|
21
|
-
throw new Error('textResponse error: "text" cannot be empty');
|
|
22
|
-
return {
|
|
23
|
-
isError,
|
|
24
|
-
content: [
|
|
25
|
-
{
|
|
26
|
-
type: 'text',
|
|
27
|
-
text,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Gets the enabled toolsets based on user input and validates against available toolsets
|
|
34
|
-
*
|
|
35
|
-
* @param availableToolsets - The list of available toolsets
|
|
36
|
-
* @param toolsetsInput - The comma-separated list of toolsets
|
|
37
|
-
* @returns A Set of enabled toolsets
|
|
38
|
-
*/
|
|
39
|
-
export function getEnabledToolsets(availableToolsets, toolsetsInput) {
|
|
40
|
-
const availableToolsetsSet = new Set(availableToolsets);
|
|
41
|
-
const passedToolsets = toolsetsInput.split(',').map((toolset) => toolset.trim());
|
|
42
|
-
// Check if any passed toolset is not in the available list
|
|
43
|
-
for (const toolset of passedToolsets) {
|
|
44
|
-
if (!availableToolsetsSet.has(toolset)) {
|
|
45
|
-
console.error(`Passed toolset "${toolset}" is not in the allowed toolset list. Available toolsets are "all (default), ${Array.from(availableToolsetsSet)
|
|
46
|
-
.filter((t) => t !== 'all')
|
|
47
|
-
.join(', ')}"`);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const enabledToolsets = new Set(passedToolsets.filter((toolset) => availableToolsetsSet.has(toolset)));
|
|
52
|
-
console.error('Enabling toolsets:', Array.from(enabledToolsets).join(', '));
|
|
53
|
-
return enabledToolsets;
|
|
54
|
-
}
|
|
55
|
-
export function sanitizePath(projectPath) {
|
|
56
|
-
// Decode URL-encoded sequences
|
|
57
|
-
const decodedProjectPath = decodeURIComponent(projectPath);
|
|
58
|
-
// Normalize Unicode characters
|
|
59
|
-
const normalizedProjectPath = decodedProjectPath.normalize();
|
|
60
|
-
// Check for various traversal patterns
|
|
61
|
-
const hasTraversal = normalizedProjectPath.includes('..') ||
|
|
62
|
-
normalizedProjectPath.includes('\u2025') || // Unicode horizontal ellipsis
|
|
63
|
-
normalizedProjectPath.includes('\u2026'); // Unicode vertical ellipsis
|
|
64
|
-
// `path.isAbsolute` doesn't cover Windows's drive-relative path:
|
|
65
|
-
// https://github.com/nodejs/node/issues/56766
|
|
66
|
-
//
|
|
67
|
-
// we can assume it's a drive-relative path if it's starts with `\`.
|
|
68
|
-
const isAbsolute = path.isAbsolute(projectPath) && (process.platform === 'win32' ? !projectPath.startsWith('\\') : true);
|
|
69
|
-
return !hasTraversal && isAbsolute;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { SfMcpServer } from '../../sf-mcp-server.js';
|
|
3
|
-
export declare const getUsernameParamsSchema: z.ZodObject<{
|
|
4
|
-
defaultTargetOrg: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
5
|
-
defaultDevHub: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
6
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
defaultTargetOrg: boolean;
|
|
9
|
-
defaultDevHub: boolean;
|
|
10
|
-
directory: string;
|
|
11
|
-
}, {
|
|
12
|
-
directory: string;
|
|
13
|
-
defaultTargetOrg?: boolean | undefined;
|
|
14
|
-
defaultDevHub?: boolean | undefined;
|
|
15
|
-
}>;
|
|
16
|
-
export type GetUsernameParamsSchema = z.infer<typeof getUsernameParamsSchema>;
|
|
17
|
-
export declare const registerToolGetUsername: (server: SfMcpServer) => void;
|