# MCP Server Management Reference Register, configure, and manage Model Context Protocol (MCP) servers in the Salesforce API Catalog using the `sf agent mcp` CLI commands. This reference backs the **Manage MCP Servers** task domain in `SKILL.md`. MCP servers expose **assets** — tools, prompts, and resources — that become available as agent actions once whitelisted. This reference covers server registration, lifecycle management, and interactive asset whitelisting. **Requires:** `sf` CLI with the `agent mcp` plugin installed. Verify with `sf help agent mcp`. If the command is missing, check `sf version`, run `sf update`, and confirm plugin availability with `sf plugins`. **Developer preview:** Every `sf agent mcp` command is currently in developer preview. Each response includes a `warnings` array containing a preview notice (`"This command is currently in developer preview..."`). Parse `result` as usual and ignore the warning for automation, but be aware flag/output shapes may change. **ID formats (observed):** Server IDs use the `0Le` prefix (e.g. `0LeSB000000JoFd`), and asset IDs use the `1XO` prefix (e.g. `1XOSB0000008riJ`). The `0XSxx…`/`0YSxx…` placeholders in older examples are illustrative only. ## Core Principles 1. **Always `--json`** — Include `--json` on every `sf agent mcp` command to get structured output. (Consistent with Rule 1 in `SKILL.md`.) 2. **Verify target org** — Before any operation, confirm a target org is set with `sf config get target-org --json`. If none, ask the user to run `sf config set target-org `. (Consistent with Rule 2.) 3. **Interactive approval** — When whitelisting tools, display metadata for each tool individually and wait for user approval before activating. 4. **Security first** — For OAuth servers, handle client secrets securely (stdin piping) and warn about credential exposure. Flag destructive or broadly-scoped tools before activation. ## Task Workflows ### 1. Register a New MCP Server When the user wants to register/create/add an MCP server: #### Required Information Gather from the user (ask if not provided): - **Server name** (`-n, --name`) — Unique identifier - **Server URL** (`--server-url`) — Endpoint URL - **Target org** (`-o, --target-org`) — Org alias or username - **Label** (optional, `--label`) — Human-readable display name - **Description** (optional, `--description`) — Server purpose - **Authentication type** (`--auth-type`) — `NO_AUTH` (default) or `OAUTH` If `--auth-type OAUTH`, also gather: - **Identity provider** (`--identity-provider`) - **Client ID** (`--client-id`) - **Client secret** (`--client-secret`) — Handle securely via stdin - **Scope** (`--scope`) #### Execution Steps 1. **Verify target org is set** ```bash sf config get target-org --json ``` If no target org, ask user to set one with `sf config set target-org ` 2. **Gather required information** — Ask for any missing required fields 3. **Create the server** **NO_AUTH example:** ```bash sf agent mcp create -n MyServer --server-url https://mcp.example.com/mcp -o myOrg --json ``` **OAUTH example (secure client secret handling):** ```bash echo "secret-value" | sf agent mcp create -n MyServer --server-url https://mcp.example.com/mcp --auth-type OAUTH --identity-provider MyIdp --client-id abc123 --client-secret - --scope "read write" -o myOrg --json ``` 4. **Extract server ID** — Parse the JSON response and extract `result.server.id` (format: `0LeSB000000Jp5F`). Note the ID is under `result.server`, not `result` directly. This ID is required for all subsequent operations. The response also includes `result.assets` (discovered but not yet registered — they have `id: null` and `status: "NOT_REGISTERED"` until you activate them). 5. **Display confirmation** — Show the user: - Server name - Server ID - Server URL - Connection status 6. **Offer next steps** - "Would you like to fetch and whitelist tools from this server now?" - If yes, proceed to **Fetch and Whitelist Assets** workflow ### 2. List MCP Servers When the user wants to see all registered MCP servers: 1. **Verify target org** ```bash sf config get target-org --json ``` 2. **List servers** ```bash sf agent mcp list -o myOrg --json ``` **Optional filters:** - By status: `--status ACTIVE` or `--status DISCONNECTED` - By type: `--type EXTERNAL` - By label: `--label "My Server"` 3. **Display results** — The server array is under `result.mcpServers`. Show a table or list with: Server name, Server ID, Status (ACTIVE/DISCONNECTED), Server URL, Label. Auth type is under each server's `authorization.authType`. 4. **Offer actions** — Ask if the user wants to get details on a specific server, fetch assets, or update/delete a server ### 3. Get Server Details When the user wants details on a specific server: 1. **Verify target org** ```bash sf config get target-org --json ``` 2. **Get server details** ```bash sf agent mcp get -i 0XSxx0000000001 -o myOrg --json ``` 3. **Display details** — Name, label, description, server URL, status, authentication type (`authorization.authType`), and created/modified timestamps. Audit fields are IDs only (`createdById`/`lastModifiedById`) — there are no user-name objects. For OAUTH servers, `authorization.scope` and `authorization.identityProvider` (a token endpoint URL) are also present. ### 4. Fetch and Whitelist Assets (Interactive Tool Approval) This is the **core whitelisting workflow** with interactive tool-by-tool approval. 1. **Verify target org** ```bash sf config get target-org --json ``` 2. **Fetch live assets from the server** ```bash sf agent mcp fetch -i 0XSxx0000000001 -o myOrg --json ``` 3. **Parse the response** — Extract the list of assets from `result.assets`. Each asset includes: `id`, `name` (e.g., `McpTool__getTickets`), `label`, `kind` (`MCP_TOOL`/`MCP_PROMPT`/`MCP_RESOURCE`), `active` (boolean), `availableAsAgentAction` (boolean), `description`, and `status` (`IN_SYNC`/`NOT_REGISTERED`). Note: `inputSchema`, `outputSchema`, and `annotations` are NOT guaranteed to be present (the live server did not return them) — handle their absence gracefully. 4. **Interactive tool review** — For EACH tool in the list: a. **Display tool metadata clearly** (only render schema/annotations fields if the server actually returned them — they are often absent): ```text Tool: (