s

sf-mcp-server

@savidev1987/sf-mcp-server
0 Stars 2 次浏览 savidev1987 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "sf": {
      "command": "sf-mcp-server",
      "env": {
        "SALESFORCE_CLIENT_ID": "your_client_id",
        "SALESFORCE_CLIENT_SECRET": "your_client_secret",
        "SALESFORCE_PASSWORD": "your_password",
        "SALESFORCE_USERNAME": "your_username"
      }
    }
  }
}

服务介绍

SF MCP Server

An MCP (Model Context Protocol) server implementation that integrates Claude/VS Code with Salesforce, enabling natural language interactions with your Salesforce data and metadata. This server allows Claude to query, modify, and manage your Salesforce objects and records using everyday language.

Features

  • Smart Object Search: Find Salesforce objects using partial name matches
  • Detailed Schema Information: Get comprehensive field and relationship details for any object
  • Flexible Data Queries: Query records with relationship support and complex filters
  • Picklist Value Retrieval: Get all values for any picklist field
  • Field Type Filtering: Find fields of specific types across objects
  • Relationship Exploration: Analyze parent-child relationships between objects
  • Enhanced API Metadata: Access complete object metadata through direct API calls
  • Debug Log Management: Configure and retrieve debug logs for Salesforce users
  • Validation Rules Management: Get details about validation rules on objects

Installation

From PyPI

pip install sf-mcp-server

From Source

git clone https://github.com/savidev1987/sf-mcp-server.git
cd sf-mcp-server
pip install -e .

Prerequisites

You will need Salesforce OAuth2 credentials:

  • For OAuth 2.0 Client Credentials Flow: Client ID, Client Secret, and Instance URL

Environment Variables

Set the following environment variables:

export SALESFORCE_CLIENT_ID="your_client_id"
export SALESFORCE_CLIENT_SECRET="your_client_secret"
export SALESFORCE_USERNAME="your_username"
export SALESFORCE_PASSWORD="your_password"

Usage

Running the Server

sf-mcp-server

Usage with VS Code

Add the following to your VS Code User Settings (JSON) or .vscode/mcp.json:

{
  "mcp": {
    "servers": {
      "sf": {
        "command": "sf-mcp-server",
        "env": {
          "SALESFORCE_CLIENT_ID": "your_client_id",
          "SALESFORCE_CLIENT_SECRET": "your_client_secret",
          "SALESFORCE_USERNAME": "your_username",
          "SALESFORCE_PASSWORD": "your_password"
        }
      }
    }
  }
}

Usage with Claude Desktop

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "sf": {
      "command": "sf-mcp-server",
      "env": {
        "SALESFORCE_CLIENT_ID": "your_client_id",
        "SALESFORCE_CLIENT_SECRET": "your_client_secret",
        "SALESFORCE_USERNAME": "your_username",
        "SALESFORCE_PASSWORD": "your_password"
      }
    }
  }
}

Tools

Tool Name Description Parameters
search_objects Search for standard and custom objects by partial name matches query: The search string for object names
describe_object Get detailed schema information for a Salesforce object objectName: The API name of the object
describe_object_with_api Get extended object metadata using direct REST API calls objectName: The API name of the object, raw: (Optional) Return raw JSON
describe_relationship_fields Explore parent-child relationships between objects objectName: The API name of the object
query_records Query records with support for relationships and filters object: Object to query, fields: Fields to return, where: (Optional) WHERE conditions, limit: (Optional) Number of records to return
get_fields_by_type Find fields of specific data types in an object objectName: The API name of the object, fieldType: Data type to filter by
get_picklist_values Retrieve all values for a picklist field objectName: The API name of the object, fieldName: The picklist field name
get_validation_rules Get details about validation rules on an object objectName: The API name of the object
manage_debug_logs Configure and retrieve debug logs for users action: Action to perform (enable, disable, retrieve), userId: User ID, logLevel: (Optional) Debug log level

Development

Project Structure

sf_mcp_server/
 __init__.py           # Package initialization
 server.py             # MCP server implementation
 sf_connection.py      # Salesforce authentication
 tools/
     __init__.py       # Tools package initialization
     search_objects.py # Object search functionality
     describe_object.py # Object schema retrieval
     query_records.py  # SOQL query functionality
     ...               # Other tool modules

Building and Publishing

  1. Build the package:

    python -m build
    
  2. Upload to PyPI:

    python -m twine upload dist/*
    

Adding New Tools

  1. Create a new Python file in the tools directory
  2. Implement your function with proper docstrings and error handling
  3. Import and register the function in the MCP server

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Issues and Support

If you encounter any issues or need support, please file an issue on the GitHub repository.

相关 MCP 服务