sf-mcp

sf-mcp

MCP server for Salesforce that exposes CLI, REST, Connect, Data 360, Bulk 2.0, and Einstein Models APIs as tools for any MCP-compatible client to manage orgs, data, and metadata.

Category
访问服务器

README

sf-mcp

Model Context Protocol server for Salesforce, built on salesforce-py and FastMCP.

Exposes the Salesforce CLI, REST, Connect, Data 360, Models, and Bulk 2.0 APIs as MCP tools that any MCP-compatible client — Claude Code, Claude Desktop, Codex, Cursor — can call.

Quick start

1. Authenticate at least one Salesforce org

sf-mcp reuses your local sf CLI session. Before running the server, log in to an org:

sf org login web --alias my-org

2. Install

uv tool install sf-mcp
# or:
pipx install sf-mcp
# or, in a project venv:
uv add sf-mcp

3. Add the server to your MCP client

Claude Code (CLI)

claude mcp add sf-mcp -- uvx sf-mcp

By default, every tool call takes a target_org argument naming the alias to use, so the MCP works against whichever org you ask for at call time — no global pin required. Optionally, pin a default for this client:

claude mcp add sf-mcp --env SF_MCP_ALIAS=my-org -- uvx sf-mcp

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "sf-mcp": {
      "command": "uvx",
      "args": ["sf-mcp"]
    }
  }
}

A copy of this config lives at examples/claude_desktop_config.json. To pin a default org alias for this client, add "env": { "SF_MCP_ALIAS": "my-org" }.

Cursor

Add to ~/.cursor/mcp.json (or your workspace's .cursor/mcp.json):

{
  "mcpServers": {
    "sf-mcp": {
      "command": "uvx",
      "args": ["sf-mcp"]
    }
  }
}

A copy lives at examples/cursor_config.json. To pin a default org alias for this client, add "env": { "SF_MCP_ALIAS": "my-org" }.

Codex CLI

Add to ~/.codex/config.toml:

[mcp_servers.sf-mcp]
command = "uvx"
args = ["sf-mcp"]

To pin a default org alias for this client, add [mcp_servers.sf-mcp.env]\nSF_MCP_ALIAS = "my-org".

Tools

Every tool takes an optional target_org argument naming the alias to operate against. The expected default usage is to ask for an org per call — "list every account in qlabs", "deploy this to dev_99christian" — and let the MCP route to the matching sf CLI session.

If you'd rather not pass target_org every time, sf-mcp falls back through this chain when it's omitted:

  1. SF_MCP_ALIAS env var (set on the MCP client process)
  2. SF_TARGET_ORG env var (sf CLI's own standard)
  3. target-org from the project-local .sf/config.json or the global ~/.sf/config.json — i.e. whatever sf config get target-org would return

sf CLI (sf_*)

Tool Purpose
sf_org_list List every authenticated org
sf_org_display Show creds + metadata for the bound org
sf_apex_run_anonymous Execute anonymous Apex
sf_data_query SOQL via the CLI
sf_apex_run_tests Run Apex tests
sf_project_deploy Deploy a directory of metadata
sf_project_retrieve Retrieve metadata into a local directory

REST API (soql_*, sosl_*, sobject_*, tooling_*, limits_*)

Tool Purpose
soql_query Single-page SOQL via REST
soql_query_all_pages Paginated SOQL — every record
sosl_search Full-text SOSL search
sobject_describe Field/relationship describe for one sObject
sobject_list Describe-global — every sObject in the org
sobject_get Get a record by ID
sobject_create Create a record
sobject_update Patch a record
sobject_delete Delete a record
sobject_upsert Upsert by external ID
tooling_query SOQL against the Tooling API
limits_get API/storage/governor limits

Connect REST (connect_*)

Generic passthroughs against /services/data/vXX.X/connect/<path>:

Tool Purpose
connect_get / connect_post / connect_patch / connect_delete HTTP verb against any Connect subpath

Data 360 / CDP (data360_*)

Tool Purpose
data360_query_v2 Run a V2 (SAQL-style) query
data360_sql_run Submit a SQL query, poll, and return rows
data360_sql_rows Fetch additional row pages

Bulk API 2.0 (bulk_*)

Tool Purpose
bulk_query End-to-end Bulk SOQL → CSV
bulk_upsert End-to-end CSV upsert with polling

Einstein Models (models_*)

Requires SF_MODELS_CLIENT_ID and SF_MODELS_CLIENT_SECRET in the environment (Connected App with the sfap_api einstein_gpt_api api scopes).

Tool Purpose
models_chat Chat completion
models_embed Text embeddings

Configuration

Env var Purpose
SF_MCP_ALIAS Optional. Highest-priority default org alias; overrides SF_TARGET_ORG and the sf CLI's own configured target-org.
SF_TARGET_ORG Optional. Standard sf CLI env var; honoured when SF_MCP_ALIAS is unset.
SF_MODELS_CLIENT_ID / SF_MODELS_CLIENT_SECRET Required for Einstein Models tools
SF_MODELS_INSTANCE_URL Override the My Domain used for Models OAuth (defaults to the alias's instance URL)

When neither env var is set and no target_org is passed, sf-mcp defers to sf config get target-org (project-local .sf/config.json first, then global ~/.sf/config.json).

Local development

git clone https://github.com/geekstewie/sf-mcp
cd sf-mcp
uv sync --extra dev

# Run the server in stdio mode
uv run python -m sf_mcp

# Run tests
uv run pytest

# Lint + format
uv run ruff check src/
uv run ruff format src/

License

This project is a personal open-source project, released under the Apache License, Version 2.0.

You are free to use, modify, and distribute this software in accordance with the terms of the license. It is provided as-is, without warranty of any kind — express or implied — including but not limited to warranties of merchantability or fitness for a particular purpose. Use it at your own risk.

This project is not an official Salesforce product and is not affiliated with or endorsed by Salesforce, Inc. in any way.

See the LICENSE file for the full license text.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选