# Salesforce MCP智能服务器
## 基本信息
- Slug: `surajadsul-mcp-server-salesforce`
- Source: modelscope
- Publisher: @SurajAdsul/mcp-server-salesforce
- Categories: databases / customer-data-platforms
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@SurajAdsul/mcp-server-salesforce
## 简介
一种MCP服务器实现，它将克劳德与Salesforce集成，从而能够以自然语言与Salesforce的数据和元数据进行交互，以查询、修改和管理对象和记录。
## 安装提示

```bash
npm install -g @surajadsul02/mcp-server-salesforce
```

## MCP Server 详情

# Salesforce MCP 服务器

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

<a href="https://glama.ai/mcp/servers/n1rsv1aiee">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/n1rsv1aiee/badge" alt="Salesforce Server MCP server" />
</a>

## 特性

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

## 安装

```bash
npm install -g @surajadsul02/mcp-server-salesforce
```


## 设置

### Salesforce 认证
您可以使用以下两种方法之一来认证Salesforce：

#### 1. 用户名/密码认证
1. 设置您的Salesforce凭据
2. 获取您的安全令牌（从Salesforce设置中重置）
3. 如配置部分所示配置环境变量

#### 2. 使用消费者密钥/秘密的OAuth2认证
1. 在Salesforce中设置连接的应用程序
2. 获取消费者密钥和消费者秘密
3. 如配置部分所示配置环境变量

### IDE 集成

#### Cursor IDE 设置

1. 全局安装包：
```bash
npm install -g @surajadsul02/mcp-server-salesforce
```


2. 在Cursor IDE的`.cursor/mcp.json`中配置MCP服务器：

##### 使用env命令
```json
{
  "mcpServers": {
    "salesforce": {
      "command": "env",
      "args": [
        "SALESFORCE_USERNAME=your.actual.email@example.com",
        "SALESFORCE_PASSWORD=YourActualPassword123",
        "SALESFORCE_TOKEN=YourActualSecurityToken123",
        "SALESFORCE_INSTANCE_URL=https://login.salesforce.com",
        "npx",
        "-y",
        "@surajadsul02/mcp-server-salesforce"
      ]
    }
  }
}
```


##### 对于Cursor中的OAuth2认证
```json
{
  "mcpServers": {
    "salesforce": {
      "command": "env",
      "args": [
        "SALESFORCE_USERNAME=your.actual.email@example.com",
        "SALESFORCE_PASSWORD=YourActualPassword123",
        "SALESFORCE_TOKEN=YourActualSecurityToken123",
        "SALESFORCE_INSTANCE_URL=https://login.salesforce.com",
        "SALESFORCE_CONSUMER_KEY=YourConsumerKey",
        "SALESFORCE_CONSUMER_SECRET=YourConsumerSecret",
        "npx",
        "-y",
        "@surajadsul02/mcp-server-salesforce"
      ]
    }
  }
}
```


#### Claude 桌面版设置

1. 如果尚未安装，请全局安装包：
```bash
npm install -g @surajadsul02/mcp-server-salesforce
```


2. 添加到您的`claude_desktop_config.json`文件中：

##### 对于用户名/密码认证
```json
{
  "mcpServers": {
    "salesforce": {
      "command": "npx",
      "args": ["-y", "@surajadsul02/mcp-server-salesforce"],
      "env": {
        "SALESFORCE_USERNAME": "your_username",
        "SALESFORCE_PASSWORD": "your_password",
        "SALESFORCE_TOKEN": "your_security_token",
        "SALESFORCE_INSTANCE_URL": "https://login.salesforce.com"
      }
    }
  }
}
```


##### 对于OAuth2认证
```json
{
  "mcpServers": {
    "salesforce": {
      "command": "npx",
      "args": ["-y", "@surajadsul02/mcp-server-salesforce"],
      "env": {
        "SALESFORCE_USERNAME": "your_username",
        "SALESFORCE_PASSWORD": "your_password",
        "SALESFORCE_CONSUMER_KEY": "your_consumer_key",
        "SALESFORCE_CONSUMER_SECRET": "your_consumer_secret",
        "SALESFORCE_INSTANCE_URL": "https://login.salesforce.com"
      }
    }
  }
}
```


3. 配置文件位置：
   - macOS: `~/Library/Application Support/Claude Desktop/claude_desktop_config.json`
   - Windows: `%APPDATA%\Claude Desktop\claude_desktop_config.json`
   - Linux: `~/.config/Claude Desktop/claude_desktop_config.json`

### 必需的环境变量

对于用户名/密码认证：
- `SALESFORCE_USERNAME`: 您的Salesforce用户名/电子邮件
- `SALESFORCE_PASSWORD`: 您的Salesforce密码
- `SALESFORCE_TOKEN`: 您的Salesforce安全令牌
- `SALESFORCE_INSTANCE_URL`: 您的Salesforce实例URL（可选，默认值：https://login.salesforce.com）

对于OAuth2认证：

- `SALESFORCE_USERNAME`: 您的 Salesforce 用户名/电子邮件
- `SALESFORCE_PASSWORD`: 您的 Salesforce 密码
- `SALESFORCE_CONSUMER_KEY`: 您的连接应用的消费者密钥
- `SALESFORCE_CONSUMER_SECRET`: 您的连接应用的消费者密钥
- `SALESFORCE_INSTANCE_URL`: 您的 Salesforce 实例 URL（可选，默认: https://login.salesforce.com）

## 使用示例

### 搜索对象
```
"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"
```


## 开发

### 从源代码构建
```bash
# Clone the repository
git clone https://github.com/surajadsul02/mcp-server-salesforce.git

# Navigate to directory
cd mcp-server-salesforce

# Install dependencies
npm install

# Build the project
npm run build
```


## 故障排除

1. **认证错误**
   - 确认您的凭证是正确的
   - 对于用户名/密码认证：确保安全令牌正确
   - 对于 OAuth2 认证：验证消费者密钥和密钥

2. **连接问题**
   - 检查您的 Salesforce 实例 URL
   - 验证网络连接
   - 确保具有适当的 API 访问权限

3. **Cursor IDE 集成**
   - 在配置更改后重启 Cursor IDE
   - 检查开发工具（帮助 > 切换开发者工具）中的错误消息
   - 确认包已全局安装

4. **Claude Desktop 集成**
   - 验证配置文件位置
   - 检查文件权限
   - 在配置更改后重启 Claude Desktop
   - 确保环境变量已正确设置

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

## 许可证
本项目根据 MIT 许可证许可 - 详情请参阅 [LICENSE](LICENSE) 文件。

## 问题和支持
如果您遇到任何问题或需要支持，请在 GitHub 仓库中提交一个问题。

