Model Context Protocol (MCP)

Learn about Merge MCP and how to implement our MCP server
Overview

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.

Installation

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
MCP setup

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
  1. Ensure you have uvx installed

  2. Download Claude Desktop from the official website

  3. Once downloaded, open the app and follow the instructions to set up your account

  4. Navigate to SettingsDeveloperEdit Config. This should open a file named claude_desktop_config.json in a text editor.

  5. Copy the MCP server setup JSON above and paste it into the text editor

  6. Replace your_api_key and your_account_token with your actual Merge API key and Linked Account token. You will also need to replace uvx with the absolute path to the command in the config file (i.e. /Users/username/.local/bin/uvx). You can find the absolute path by running which uvx through your terminal.

  7. Save the config file

  8. Restart Claude Desktop to see your tools. The tools may take a minute to appear.

Example Python client setup
  1. 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.py file that will contain the code for your MCP client and be the entry point for your application.

  2. Setting up your API keys

    You will need to set up your API keys in the environment variables.

    The ANTHROPIC_API_KEY will be used to authenticate your requests to the Anthropic API.

    The MERGE_API_KEY will be needed to connect to the Merge MCP server.

  3. Set up an MCPClient class
    The MCPClient class will handle the connection to the Merge MCP server and facilitate the calls made to the Anthropic API.
  4. Add a connect_to_server function to the MCPClient class

    The connect_to_server function will be used to connect to the MCP server.

    This function takes in a linked_account_token parameter which is the token associated with the Linked Account you want to connect to.

  5. Add a process_query function to the MCPClient class

    The process_query function will be used to process queries from the MCP server.

    This function takes in a query parameter 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_tool function 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.

  6. Add a chat_loop function to the MCPClient class

    The chat_loop function 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_query function.

  7. Add a cleanup function to the MCPClient class

    The cleanup function will be used to clean up resources when the MCPClient is no longer needed.

    This function will be called when the process is terminated.

  8. Add a main function to the client.py file as the main entry point
    The main function will be used to initiate a MCPClient instance, connect to the MCP server, and start the chat loop.
  9. Running the client

    You can run the client by executing the client.py file.

    If the set up was completed successfully, you should be prompted to input a query.

Scopes

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.

Scope format

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. read or write)

Examples of valid scopes:

  • ats.Candidate:read - Read access to Candidate objects
  • hris.Employee:write - Write access to Employee objects
  • crm.Contact - Read + Write access to Contact objects

You can combine multiple scopes to grant different permissions.

Important note on scopes availability

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.Job with 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:write when 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.

Available tools

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.

Environment variables

The following environment variables are used by the Merge MCP server:

  • MERGE_API_KEY: Your Merge API key
  • MERGE_ACCOUNT_TOKEN: Your Merge Linked Account token
  • MERGE_TENANT (Optional): The Merge API tenant associated with your Linked Account. Valid values are US, EU, and APAC. Defaults to US.