Salesforce MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Provides comprehensive access to Salesforce data and metadata, enabling object and field management, schema exploration, data querying with relationship support, record creation/modification, cross-object searching, and custom object development - all using the Salesforce API.

Salesforce MCP 服务器

一个 MCP(模型上下文协议)服务器实现,将 Claude 与 Salesforce 集成,从而实现与 Salesforce 数据和元数据的自然语言交互。此服务器允许 Claude 使用日常语言查询、修改和管理您的 Salesforce 对象和记录。

特征

  • 对象和字段管理:使用自然语言创建和修改自定义对象和字段
  • 智能对象搜索:使用部分名称匹配查找 Salesforce 对象
  • 详细架构信息:获取任何对象的全面字段和关系详细信息
  • 灵活的数据查询:使用关系支持和复杂过滤器查询记录
  • 数据操作:轻松插入、更新、删除和插入记录
  • 跨对象搜索:使用 SOSL 跨多个对象进行搜索
  • Apex 代码管理:读取、创建和更新 Apex 类和触发器
  • 直观的错误处理:使用 Salesforce 特定的错误详细信息提供清晰的反馈

安装

npm install -g @tsmztech/mcp-server-salesforce

工具

salesforce_search_objects

搜索标准和自定义对象:

  • 按部分名称匹配搜索
  • 查找标准和自定义对象
  • 例如:“查找与帐户相关的对象”将找到帐户、帐户历史等。

salesforce_describe_object

获取详细的对象架构信息:

  • 字段定义和属性
  • 关系详情
  • 选择列表值
  • 例如:“显示帐户对象中的所有字段”

salesforce_query_records

查询具有关系支持的记录:

  • 亲子关系
  • 子女与父母的关系
  • 复杂的 WHERE 条件
  • 例如:“获取所有帐户及其相关联系人”

salesforce_dml_记录

执行数据操作:

  • 插入新记录
  • 更新现有记录
  • 删除记录
  • 使用外部 ID 进行更新插入
  • 例如:“更新多个帐户的状态”

salesforce_manage_object

创建和修改自定义对象:

  • 创建新的自定义对象
  • 更新对象属性
  • 配置共享设置
  • 示例:“创建客户反馈对象”

salesforce_manage_field

管理对象字段:

  • 添加新的自定义字段
  • 修改字段属性
  • 创建关系
  • 示例:“向帐户添加评级选择列表字段”

salesforce_search_all

跨多个对象搜索:

  • 基于SOSL的搜索
  • 多对象支持
  • 字段片段
  • 示例:“在帐户和商机中搜索‘云’”

salesforce_read_apex

阅读 Apex 课程:

  • 获取特定类的完整源代码
  • 列出与名称模式匹配的类
  • 查看类元数据(API 版本、状态等)
  • 名称模式中支持通配符(* 和 ?)
  • 例如:“显示 AccountController 类”或“查找所有与 Account Cont匹配的类”

salesforce_write_apex

创建和更新 Apex 类:

  • 创建新的 Apex 类
  • 更新现有的类实现
  • 指定 API 版本
  • 示例:“创建一个新的 Apex 类来处理帐户操作”

salesforce_read_apex_trigger

读取 Apex 触发器:

  • 获取特定触发器的完整源代码
  • 列出与名称模式匹配的触发器
  • 查看触发器元数据(API 版本、对象、状态等)
  • 名称模式中支持通配符(* 和 ?)
  • 例如:“显示 AccountTrigger”或“查找 Contact 对象的所有触发器”

salesforce_write_apex_trigger

创建和更新 Apex 触发器:

  • 为特定对象创建新的 Apex 触发器
  • 更新现有的触发器实现
  • 指定 API 版本和事件操作
  • 示例:“为帐户对象创建新触发器”或“更新潜在客户触发器”

salesforce_execute_anonymous

执行匿名 Apex 代码:

  • 无需创建永久类即可运行 Apex 代码
  • 查看调试日志和执行结果
  • 对于其他工具不直接支持的数据操作很有用
  • 示例:“执行 Apex 代码来计算帐户指标”或“运行脚本来更新相关记录”

salesforce_manage_debug_logs

管理 Salesforce 用户的调试日志:

  • 为特定用户启用调试日志
  • 禁用活动调试日志配置
  • 检索并查看调试日志
  • 配置日志级别(NONE、ERROR、WARN、INFO、DEBUG、FINE、FINER、FINEST)
  • 示例:“为user@example.com启用调试日志”或“检索管理员用户的最近日志”

设置

Salesforce 身份验证

您可以使用以下两种身份验证方法之一连接到 Salesforce:

1.用户名/密码验证(默认)

  1. 设置您的 Salesforce 凭据
  2. 获取您的安全令牌(从 Salesforce 设置重置)

2. OAuth 2.0 客户端凭证流程

  1. 在 Salesforce 中创建连接的应用程序
  2. 启用 OAuth 设置并选择“客户端凭证流”
  3. 设置适当的范围(通常“api”就足够了)
  4. 保存客户端 ID 和客户端密钥
  5. 重要提示:请注意您的实例 URL(例如https://your-domain.my.salesforce.com ),因为它是身份验证所必需的

与 Claude Desktop 一起使用

添加到您的claude_desktop_config.json

对于用户名/密码验证:

{ "mcpServers": { "salesforce": { "command": "npx", "args": ["-y", "@tsmztech/mcp-server-salesforce"], "env": { "SALESFORCE_CONNECTION_TYPE": "User_Password", "SALESFORCE_USERNAME": "your_username", "SALESFORCE_PASSWORD": "your_password", "SALESFORCE_TOKEN": "your_security_token", "SALESFORCE_INSTANCE_URL": "org_url" // Optional. Default value: https://login.salesforce.com } } } }

对于 OAuth 2.0 客户端凭证流程:

{ "mcpServers": { "salesforce": { "command": "npx", "args": ["-y", "@tsmztech/mcp-server-salesforce"], "env": { "SALESFORCE_CONNECTION_TYPE": "OAuth_2.0_Client_Credentials", "SALESFORCE_CLIENT_ID": "your_client_id", "SALESFORCE_CLIENT_SECRET": "your_client_secret", "SALESFORCE_INSTANCE_URL": "https://your-domain.my.salesforce.com" // REQUIRED: Must be your exact Salesforce instance URL } } } }

注意:对于 OAuth 2.0 客户端凭证流程, SALESFORCE_INSTANCE_URL必须是您 Salesforce 实例的准确 URL(例如, https://your-domain.my.salesforce.com )。令牌端点将构建为<instance_url>/services/oauth2/token

示例用法

搜索对象

"Find all objects related to Accounts" "Show me objects that handle customer service" "What objects are available for order management?"

获取架构信息

"What fields are available in the Account object?" "Show me the picklist values for Case Status" "Describe the relationship fields in Opportunity"

查询记录

"Get all Accounts created this month" "Show me high-priority Cases with their related Contacts" "Find all Opportunities over $100k"

管理自定义对象

"Create a Customer Feedback object" "Add a Rating field to the Feedback object" "Update sharing settings for the Service Request object"

跨对象搜索

"Search for 'cloud' in Accounts and Opportunities" "Find mentions of 'network issue' in Cases and Knowledge Articles" "Search for customer name across all relevant objects"

管理 Apex 代码

"Show me all Apex classes with 'Controller' in the name" "Get the full code for the AccountService class" "Create a new Apex utility class for handling date operations" "Update the LeadConverter class to add a new method"

管理 Apex 触发器

"List all triggers for the Account object" "Show me the code for the ContactTrigger" "Create a new trigger for the Opportunity object" "Update the Case trigger to handle after delete events"

执行匿名 Apex 代码

"Execute Apex code to calculate account metrics" "Run a script to update related records" "Execute a batch job to process large datasets"

管理调试日志

"Enable debug logs for user@example.com" "Retrieve recent logs for an admin user" "Disable debug logs for a specific user" "Configure log level to DEBUG for a user"

发展

从源代码构建

# Clone the repository git clone https://github.com/tsmztech/mcp-server-salesforce.git # Navigate to directory cd mcp-server-salesforce # Install dependencies npm install # Build the project npm run build

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

问题与支持

如果您遇到任何问题或需要支持,请在GitHub 存储库上提交问题。

ID: kqeniawbr6