
If you work with and sell to companies in the AI industry, youâre likely receiving requests to support the Model Context Protocol (MCP) through an MCP server.
Your MCP server would allow any large language model (LLMs) to easily access data and functionality in your product, which an LLM can then use to complete key workflows for customers.
But the process of building a robust, production-ready MCP server isnât straightforward.Â
To help you implement yours faster and more easily, Iâll walk you through the steps youâll need to take based on my experience in building our own MCP serverâMerge MCP.Â
But first, letâs align on the core elements of the Model Context Protocol.Â
{{this-blog-only-cta}}
At its core, MCP consists of tools, a call_tool function, and a list_tool function.
For example, hereâs how the input schema looks for the Merge MCP file_retrieval function:

In most cases, your users would see the tools available in the list_tool function before deciding on the tool they use for the call_tool function.Â
Once a tool is selected, the LLM populates its name and parameters in the call_tool function, and the call_tool function would go on to perform the predefined action (e.g., making an API request).
For example, hereâs the call_tool function for the Merge MCP file_retrieval function:
Related: MCP server examples to help you build powerful AI agents
Building an MCP server requires building both the list_tool and call_tool functions.
The steps for implementing each function depend on the type of MCP server youâre supporting, but here are the steps we took to build Merge MCP and that you need to take to build your own server.
Establishing the server requires adding just a few lines of code.Â
For example, to build an MCP server via Python, you can use the following code:
When we implemented Merge MCPâs server, we also included Merge API Token and Merge Account Key fields so that our end users (our customersâ customers) can access our customersâ integrations securely.
You can implement this in one of two ways:
For example, the MCP quickstart guide outlined the code you can use to define two functionsâget_alerts and get_forecastâwithin an MCP server.Â
This works great when your function is static. For example, if, hypothetically, your MCP server consists of API endpoints that wonât change.
Since weâre constantly adding to and improving our endpoints, we opted for this approach when building Merge MCP.
For example, if one of your users wants to create tickets in their project management system via Merge MCP, they can input something like:
 âCan you create me a ticket called â[BUG] Google Auth sign in broken" that is high priority?ââ
The LLM can then identify the appropriate toolâticket_createâand use the predefined schema to ensure all the necessary information is properly formatted and validated before making the request.Â
Hereâs how this can look for the user:

Related: When to use an MCP gateway
Assuming your tools map to API endpoints listed on an OpenAPI schema, youâll need to look up the OpenAPI spec parameters for each tool.Â
From there, you can construct the endpoint, any query parameters (if applicable), and the body of the request (if applicable) from the given arguments. You can then make a live API call.
You should also pass along the API callâs output with what you provided in the request so that the function can include detailed messages when the call_tool function succeeds and when it fails. That way, your LLM knows how to handle the data, whether thatâs making a follow-up request that addresses the previous issue or itâs sharing the parameters from a successful request with the user.
As part of this step, youâll also want to sanitize the data so that youâre not passing along any sensitive information.

Once this is set up, the LLM picks a tool and sets up the arguments on the client side. It then passes the toolâs name and arguments to the call_tool function, which invokes the appropriate action.
https://www.merge.dev/blog/rag-vs-mcp?blog-related=image
 Merge Agent Handler lets you securely connect to more than a thousand tools!

Merge Agent Handler also provides the tooling you need to test, monitor, and manage your agentsâ tool calls. This includes a comprehensive evaluation suite to benchmark any tool callâs performance, fully-searchable logs to drill into individual tool calls and API requests, customizable alerts so teams can detect and resolve issues quickly, and more.
Test Merge Agent Handler for yourself by signing up for a free account!
Leverage Merge Agent Handler to both securely connect to more than a thousand tools and observe and manage your AI agents.