Model Context Protocol (MCP)
Merge offers an MCP server that integrates the Merge API with any LLM provider supporting the MCP protocol. This enables your AI agent to access hundreds of tools via a single MCP server.
The Merge MCP SDK can be found here.
The following items are prerequisites in order to implement Merge MCP:
- A Merge API key and linked account token
- Python 3.10 or higher
- uv
Here is an example config file which you can use to set up Merge MCP
Note: If the uvx command does not work, try absolute path (i.e./Users/username/.local/bin/uvx). You can find the absolute path by running which uvx through your terminal.
Example Claude Desktop setup
Ensure you have
uvxinstalledDownload Claude Desktop from the official website
Once downloaded, open the app and follow the instructions to set up your account
Navigate to Settings → Developer → Edit Config. This should open a file named
claude_desktop_config.jsonin a text editor.Copy the MCP server setup JSON above and paste it into the text editor
Replace
your_api_keyandyour_account_tokenwith your actual Merge API key and Linked Account token. You will also need to replaceuvxwith the absolute path to the command in the config file (i.e./Users/username/.local/bin/uvx). You can find the absolute path by runningwhich uvxthrough your terminal.Save the config file
Restart Claude Desktop to see your tools. The tools may take a minute to appear.
Example Python client setup
- Setting up your project
You will first need to set up a Python virtual environment and install the required dependencies.
You will also create a
client.pyfile that will contain the code for your MCP client and be the entry point for your application. - Setting up your API keys
You will need to set up your API keys in the environment variables.
The
ANTHROPIC_API_KEYwill be used to authenticate your requests to the Anthropic API.The
MERGE_API_KEYwill be needed to connect to the Merge MCP server. - Set up an
MCPClientclassTheMCPClientclass will handle the connection to the Merge MCP server and facilitate the calls made to the Anthropic API. - Add a
connect_to_serverfunction to the MCPClient classThe
connect_to_serverfunction will be used to connect to the MCP server.This function takes in a
linked_account_tokenparameter which is the token associated with the Linked Account you want to connect to. - Add a
process_queryfunction to the MCPClient classThe
process_queryfunction will be used to process queries from the MCP server.This function takes in a
queryparameter which is a user initiated prompt that will be sent to the Anthropic API.The Anthropic API will return a response that will contain text or tool use. In the case of tool use, the Anthropic call will have returned a name and input corresponding to the tool that should be used and the arguments that should be passed to the tool.
This information is then surfaced to the user to prompt them for confirmation on executing the tool.
Once the user confirms, the tool name and arguments will be passed to the
call_toolfunction of our existing session with the Merge MCP server.The results of the tool call will be sent to another Anthropic API call to generate a response.
- Add a
chat_loopfunction to the MCPClient classThe
chat_loopfunction will be used to handle chat interactions with the MCP server.This function handles the main chat loop where the user is prompted to input a query. That query is then sent to the
process_queryfunction. - Add a
cleanupfunction to the MCPClient classThe
cleanupfunction will be used to clean up resources when the MCPClient is no longer needed.This function will be called when the process is terminated.
- Add a
mainfunction to theclient.pyfile as the main entry pointThemainfunction will be used to initiate a MCPClient instance, connect to the MCP server, and start the chat loop. - Running the client
You can run the client by executing the
client.pyfile.If the set up was completed successfully, you should be prompted to input a query.
Scopes determine which tools are enabled on the MCP server and are used to control access to different parts of the Merge API. If no scopes are specified, all available scopes will be enabled.
When starting the server, you can specify which scopes to enable. This is done by passing the--scopes flag with a list of scopes.
Scopes in the Merge MCP server follow a specific format based on the Merge API category and Common Model names. Each scope is formatted as:
<category>.<common_model_name>:<permission>
Where:
<category>- The category of the Common Model (e.g.ats,hris,crm, etc.)<common_model_name>- The name of the Common Model (e.g.Candidate,Application, etc.)<permission>- The permission level of the Common Model (e.g.readorwrite)
Examples of valid scopes:
ats.Candidate:read- Read access to Candidate objectshris.Employee:write- Write access to Employee objectscrm.Contact- Read + Write access to Contact objects
You can combine multiple scopes to grant different permissions.
Scopes specified with the MCP server will be validated against enabled scopes on the Linked Account. The server will only enable tools for valid authorized scopes.
The following situations can occur:
- Category Mismatch: If you specify a scope for a category that doesn't match your Linked Account (e.g., using
ats.Jobwith an HRIS Linked Account), no tools for that scope will be returned. - Permission Mismatch: If you request a permission that isn't enabled for your Linked Account (e.g., using
hris.Employee:writewhen only read access is enabled), tools requiring that permission won't be returned. - Validation: The server will automatically validate your requested scopes against what's available in your Linked Account and will only enable tools for valid, authorized scopes.
Scopes typically correspond to different models or entity types in the Merge API, and they control both read and write access to these entities.
The Merge MCP server provides access to various Merge API endpoints as tools. The available tools depend on your Merge API category (HRIS, ATS, etc.) and the scopes you have enabled.
Tools are dynamically generated based on your Merge API schema and include operations for:
- Retrieving entity details
- Listing entities
- Creating new entities
- Updating existing entities
- And more, based on your specific Merge API configuration
Note: Download tools are not currently supported. This is a known limitation and will be addressed in a future release.
The following environment variables are used by the Merge MCP server:
MERGE_API_KEY: Your Merge API keyMERGE_ACCOUNT_TOKEN: Your Merge Linked Account tokenMERGE_TENANT(Optional): The Merge API tenant associated with your Linked Account. Valid values areUS,EU, andAPAC. Defaults toUS.