Newer Version Available

This content describes an older version of this product. View Latest

Step 3 [Optional]: Configure a Rule

​​To help the MCP server function optimally, you can create a rule that guides your AI assistant, such as Agentforce Vibes or Cursor Agent, to call the Metadata API Context MCP tool. An AI rule is a plain-text file like Markdown that provides specific instructions, context, or constraints to your AI assistant.

Use this example rule to ensure that the Metadata API Context MCP tool is called to provide AI with additional context when generating metadata XML files. This helps ensure the structural integrity of the metadata XML files generated, and minimize errors during deployment.

1# Rule: Metadata Context and XML Structure
2
3**Description:** To guarantee the creation of accurate and deployable Salesforce metadata files, you must call the get_metadata_api_context MCP tool. This step provides comprehensive contextual information—including complete field definitions, valid values, and constraints—that is essential for correctly determining the required entity shape and creating a valid Metadata XML structure.
4
5**Guidelines:**
6- Before generating the XML structure for any Salesforce Metadata Type, the get_metadata_api_context MCP tool must be called.
7- The returned information—which includes field definitions, valid values, constraints, and examples—must be used to correctly determine the required shape of the entity.
8- The resulting Metadata XML structure must strictly adhere to the determined shape to leverage the complete field definitions and constraints provided by the tool.
9- Following these constraints is mandatory to ensure the resulting XML file is valid and will pass Salesforce validation upon deployment.

For more details about configuring AI rules, see: