Salesforce Object MCP Server
Enables AI agents to explore Salesforce metadata by parsing object and field definitions, reducing hallucination when working with Salesforce repositories.
README
Salesforce Object MCP Server
A Model Context Protocol (MCP) server that helps AI agents understand Salesforce metadata by parsing .object-meta.xml and .field-meta.xml files. This server provides tools for discovering objects, fields, relationships, formulas, and validation rules to reduce AI hallucination when working with Salesforce repositories.
Features
- Universal Repository Support: Works with any Salesforce repository structure - no configuration needed
- Automatic Discovery: Recursively finds all
.object-meta.xmland.field-meta.xmlfiles - Comprehensive Object Information: Access object metadata, fields, relationships, and validation rules
- Smart Caching: In-memory caching with file modification time checks for fast responses
- Relationship Mapping: Bidirectional relationship discovery (both incoming and outgoing)
- Formula & Validation Support: Parse and understand formula fields and validation rules
- Search Capabilities: Full-text search across all metadata
Available Tools
1. list_objects
List all Salesforce objects in the repository.
Parameters:
includeStandard(optional): Include standard objects (default: true)pattern(optional): Filter by name pattern (case-insensitive)
Example:
{
"includeStandard": false,
"pattern": "Account"
}
2. get_object_details
Get comprehensive details about a specific object.
Parameters:
objectName(required): API name of the object
Example:
{
"objectName": "Account"
}
3. list_fields
List all fields for a specific object.
Parameters:
objectName(required): API name of the objectfieldType(optional): Filter by field type (Text, Lookup, Formula, etc.)
Example:
{
"objectName": "Account",
"fieldType": "Formula"
}
4. get_field_details
Get detailed information about a specific field.
Parameters:
objectName(required): API name of the objectfieldName(required): API name of the field
Example:
{
"objectName": "Account",
"fieldName": "AnnualRevenue"
}
5. find_relationships
Find all relationships for an object.
Parameters:
objectName(required): API name of the objectdirection(optional): "outgoing", "incoming", or "both" (default: both)
Example:
{
"objectName": "Contact",
"direction": "both"
}
6. search_metadata
Search across all metadata by keyword.
Parameters:
query(required): Search term (case-insensitive)scope(optional): "objects", "fields", or "all" (default: all)
Example:
{
"query": "revenue",
"scope": "fields"
}
7. get_validation_rules
Get validation rules for an object.
Parameters:
objectName(required): API name of the object
Example:
{
"objectName": "Opportunity"
}
Installation
Local Development
- Clone the repository:
git clone <repository-url>
cd SFObjectMCP
- Install dependencies:
npm install
- Build the project:
npm run build
- Run the server:
SF_REPO_PATH=/path/to/your/salesforce/repo npm start
Docker
- Build the Docker image:
docker build -t sf-object-mcp .
- Run the container:
docker run -it \
-e SF_REPO_PATH=/workspace \
-v /path/to/your/salesforce/repo:/workspace:ro \
sf-object-mcp
Docker Compose
- Edit
docker-compose.ymland update the volume mount:
volumes:
- /path/to/your/salesforce/repo:/workspace:ro
- Start the server:
docker-compose up
MCP Configuration
To use this server with an MCP client (like Claude Desktop), add the following to your MCP configuration file:
Using Local Installation
{
"mcpServers": {
"salesforce-metadata": {
"command": "node",
"args": ["/path/to/SFObjectMCP/dist/index.js"],
"env": {
"SF_REPO_PATH": "/path/to/your/salesforce/repo"
}
}
}
}
Using Docker
{
"mcpServers": {
"salesforce-metadata": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"SF_REPO_PATH=/workspace",
"-v",
"/path/to/your/salesforce/repo:/workspace:ro",
"sf-object-mcp"
]
}
}
}
Supported Formats
This server works with any Salesforce repository structure. It scans for .object-meta.xml and .field-meta.xml files anywhere in your repository, regardless of directory structure.
Examples of Supported Structures
Standard SFDX:
force-app/main/default/objects/Account/Account.object-meta.xml
Custom SFDX:
src-package/main/default/core/objects/Account/Account.object-meta.xml
Metadata API:
src/objects/Account.object
Any custom structure:
any-directory/objects/Account/Account.object-meta.xml
The scanner automatically finds all Salesforce metadata files regardless of where they're located in your repository structure.
How It Works
- First Tool Call: When the first tool is called, the server scans the repository for all
.object-meta.xmland.field-meta.xmlfiles - Parsing: XML files are parsed and converted into structured TypeScript objects
- Caching: Parsed metadata is cached in memory with file modification time tracking
- Relationship Mapping: The server builds a bidirectional relationship map
- Subsequent Calls: Future tool calls use the cache for fast responses
Development
Build
npm run build
Watch Mode
npm run watch
Development Mode
npm run dev
Troubleshooting
Error: SF_REPO_PATH environment variable is required
Make sure you've set the SF_REPO_PATH environment variable to point to your Salesforce repository.
No objects found
Ensure your repository contains .object-meta.xml files. The scanner searches the entire repository recursively, so metadata files can be in any directory structure. Common locations include:
force-app/main/default/objects/src-package/main/default/core/objects/src/objects/- Any custom directory containing an
objects/folder
Object/Field not found
The server only discovers objects and fields that have metadata files in the repository. Standard objects may not be present unless they've been customized.
Use Cases
- AI-Assisted Development: Help AI agents understand your Salesforce schema to provide accurate code suggestions
- Documentation: Generate documentation from metadata
- Schema Analysis: Understand relationships and dependencies
- Code Review: Validate field references and formula syntax
- Migration Planning: Map object and field usage
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。