首页
学习
活动
专区
圈层
工具
发布
MCP广场 >详情页
Salesforce MCP服务2026-10-21222分享添加福利群:解决AI开发者的「MCP实战痛点」
一种MCP服务器实现,它将克劳德与Salesforce集成在一起, enables使用自然语言与Salesforce数据和元数据进行交互,以查询、修改和管理对象和记录。
By tsmztech
2026-10-21222
github
详情内容

Salesforce MCP服务器

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

Salesforce MCP服务器

功能特性

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

安装方法

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

工具功能

salesforce_search_objects

搜索标准对象和自定义对象:

  • 通过部分名称匹配进行搜索
  • 可查找标准和自定义对象
  • 示例:"Find objects related to Account" 将找到Account、AccountHistory等

salesforce_describe_object

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

  • 字段定义和属性
  • 关系详情
  • 选择列表值
  • 示例:"Show me all fields in the Account object"

salesforce_query_records

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

  • 父到子关系
  • 子到父关系
  • 复杂WHERE条件
  • 示例:"Get all Accounts with their related Contacts"

salesforce_dml_records

执行数据操作:

  • 插入新记录
  • 更新现有记录
  • 删除记录
  • 使用外部ID进行upsert
  • 示例:"Update status of multiple accounts"

salesforce_manage_object

创建和修改自定义对象:

  • 创建新的自定义对象
  • 更新对象属性
  • 配置共享设置
  • 示例:"Create a Customer Feedback object"

salesforce_manage_field

管理对象字段:

  • 添加新的自定义字段
  • 修改字段属性
  • 创建关系
  • 示例:"Add a Rating picklist field to Account"

salesforce_search_all

跨多个对象搜索:

  • 基于SOSL的搜索
  • 支持多个对象
  • 字段片段
  • 示例:"Search for 'cloud' across Accounts and Opportunities"

salesforce_read_apex

读取Apex类:

  • 获取特定类的完整源代码
  • 列出匹配名称模式的类
  • 查看类元数据(API版本、状态等)
  • 支持名称模式中的通配符(*和?)
  • 示例:"Show me the AccountController class" 或 "Find all classes matching AccountCont"

salesforce_write_apex

创建和更新Apex类:

  • 创建新的Apex类
  • 更新现有类的实现
  • 指定API版本
  • 示例:"Create a new Apex class for handling account operations"

salesforce_read_apex_trigger

读取Apex触发器:

  • 获取特定触发器的完整源代码
  • 列出匹配名称模式的触发器
  • 查看触发器元数据(API版本、对象、状态等)
  • 支持名称模式中的通配符(*和?)
  • 示例:"Show me the AccountTrigger" 或 "Find all triggers for Contact object"

salesforce_write_apex_trigger

创建和更新Apex触发器:

  • 为特定对象创建新的Apex触发器
  • 更新现有触发器的实现
  • 指定API版本和事件操作
  • 示例:"Create a new trigger for the Account object" 或 "Update the Lead trigger"

salesforce_execute_anonymous

执行匿名Apex代码:

  • 运行Apex代码而无需创建永久类
  • 查看调试日志和执行结果
  • 适用于其他工具不直接支持的数据操作
  • 示例:"Execute Apex code to calculate account metrics" 或 "Run a script to update related records"

salesforce_manage_debug_logs

管理Salesforce用户的调试日志:

  • 为特定用户启用调试日志
  • 禁用活动的调试日志配置
  • 检索和查看调试日志
  • 配置日志级别(NONE、ERROR、WARN、INFO、DEBUG、FINE、FINER、FINEST)
  • 示例:"Enable debug logs for user@example.com" 或 "Retrieve recent logs for an admin user"

设置步骤

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"        // 可选。默认值: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"  // 必需:必须为您的确切Salesforce实例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"

开发

从源代码构建

# 克隆仓库
git clone https://github.com/tsmztech/mcp-server-salesforce.git

# 导航到目录
cd mcp-server-salesforce

# 安装依赖项
npm install

# 构建项目
npm run build

贡献

欢迎贡献!请随时提交Pull Request。

许可证

本项目根据MIT许可证授权 - 详情请参阅LICENSE文件。

问题与支持

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

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档