6.5 C
New York
Saturday, February 28, 2026

The best way to Deploy MCP Servers as an API Endpoint


TL;DR

MCP servers join LLMs to exterior instruments and knowledge sources via a standardized protocol. Public MCP servers present capabilities akin to net search, GitHub entry, database queries, and browser automation via structured device definitions.

These servers sometimes run as long-lived stdio processes that reply to device invocation requests. To make use of them reliably in functions or share them throughout groups, they must be deployed as secure, accessible endpoints.

Clarifai permits MCP servers to be deployed as managed endpoints. The platform runs the configured MCP course of, handles lifecycle administration, discovers obtainable instruments, and exposes them via its API.

This tutorial walks you thru learn how to deploy any public MCP server. We might be utilizing the DuckDuckGo browser server as a reference implementation. The identical method applies to different stdio-based MCP servers, together with GitHub, Slack, and filesystem integrations.

DuckDuckGo Browser MCP Server

The DuckDuckGo browser MCP server is an open-source MCP implementation that exposes net search capabilities as callable instruments. It permits language fashions to carry out search queries and retrieve structured outcomes via the MCP protocol.

The server runs as a stdio-based course of and offers instruments akin to ddg_search for executing net searches. When invoked, the device returns structured search outcomes that LLMs can use to reply questions or full duties that require present net info.

We use this server because the reference implementation as a result of it doesn’t require further secrets and techniques or exterior configuration. The one requirement is defining the MCP command in config.yaml, which makes it easy for us to deploy and check on Clarifai.

If you would like to construct a customized MCP server from scratch with your personal instruments and logic, this information walks via that course of utilizing FastMCP.

Now that we’ve outlined the reference server, let’s begin.

Set Up the Atmosphere

Set up the Clarifai Python SDK:

Set your Clarifai Private Entry Token as an surroundings variable. Retrieve your PAT from the safety settings in your Clarifai account.

Clone the runners-examples repository and navigate to the browser MCP server listing:

The listing accommodates the deployment recordsdata:

  • config.yaml: Deployment configuration and MCP server specification
  • 1/mannequin.py: Mannequin class implementation
  • necessities.txt: Python dependencies

Configure the Deployment

Earlier than importing, replace config.yaml along with your Clarifai mannequin identifiers and compute settings. This file defines the mannequin metadata, MCP server startup command, and useful resource necessities. Clarifai makes use of it to start out the MCP server, allocate compute, and expose the server’s instruments via the mannequin endpoint.

The mcp_server part defines how the MCP server course of is began. command specifies the executable, and args lists the arguments handed to that executable. On this instance, uvx duckduckgo-mcp-server begins the DuckDuckGo MCP server as a stdio-based course of.

The mannequin implementation in 1/mannequin.py inherits from StdioMCPModelClass:

StdioMCPModelClass begins the method outlined in config.yaml, discovers the obtainable instruments via the MCP protocol, and exposes these instruments via the deployed mannequin endpoint. No further implementation is required past inheriting from StdioMCPModelClass.

The DuckDuckGo MCP server runs on CPU and requires minimal assets.

Add & Deploy MCP Server

Add the MCP server utilizing the Clarifai CLI:

The –skip_dockerfile flag is required when importing MCP servers. This command packages the mannequin listing and uploads it to your Clarifai account.

After importing your MCP server, deploy it on compute so it might run and serve device requests.

Go to the Compute part and create a brand new cluster. You will notice an inventory of accessible situations throughout completely different suppliers and areas, together with their {hardware} specs.

Every occasion exhibits:

  • Supplier
  • Area
  • Occasion kind
  • GPU and GPU reminiscence
  • CPU and system reminiscence
  • Hourly value

Choose an occasion primarily based on the useful resource necessities you outlined in your config.yaml file. For instance, for those who specified sure CPU and reminiscence limits, select an occasion that satisfies or exceeds these values. Most MCP servers run as light-weight stdio processes, so GPU is often not required until your server explicitly depends upon it.

After deciding on the occasion, configure the node pool. You possibly can set autoscaling parameters akin to minimal and most replicas primarily based in your anticipated workload.

Lastly, create the cluster and node pool, then deploy your MCP server to the chosen compute. Clarifai will begin the server utilizing the command outlined in your config.yaml and expose its instruments via the deployed mannequin endpoint.

You possibly can observe the information to learn to create your devoted compute surroundings and deploy your MCP server to the platform.

Utilizing the Deployed MCP Server

As soon as deployed, we will work together with the MCP server utilizing the FastMCP consumer. The consumer connects to the Clarifai endpoint and discovers the obtainable instruments.

Exchange the URL along with your deployed MCP server endpoint.

This consumer establishes an HTTP connection to the deployed MCP endpoint and retrieves the device definitions uncovered by the DuckDuckGo server. The list_tools() name confirms that the server is operating and that its instruments can be found for invocation.

Combine with LLMs

The instruments uncovered by your deployed MCP server can be utilized with any LLM that helps operate calling. Configure your MCP consumer and OpenAI-compatible consumer to connect with your Clarifai MCP endpoint so the mannequin can uncover and invoke the obtainable instruments.

 

Your MCP server is now deployed as an API endpoint on Clarifai, and its instruments might be accessed and invoked from any appropriate LLM via the MCP consumer.

Regularly Requested Questions (FAQs)

  • Can I deploy any MCP server utilizing this methodology?

    Sure. So long as the MCP server runs as a stdio-based course of, it may be outlined within the mcp_server part of config.yaml. Replace the command and arguments, add the mannequin, and the server might be uncovered via its personal endpoint.

  • Do MCP servers require Docker to deploy?

    No. When importing MCP servers utilizing the Clarifai CLI, the –skip_dockerfile flag permits the deployment with out requiring a customized Dockerfile.

  • Can I exploit deployed MCP servers with any LLM?

    Sure. Any LLM that helps operate calling or device calling can use the instruments uncovered by a deployed MCP server. The instruments have to be formatted in response to the mannequin’s operate calling schema.

  • Do MCP servers require API keys?

    It depends upon the server implementation. Some public MCP servers, such because the DuckDuckGo instance used on this information, don’t require further secrets and techniques. Others might require API credentials outlined in surroundings variables or configuration.

Closing Ideas

We transformed a stdio primarily based MCP server right into a publicly accessible API endpoint on Clarifai. Its instruments can now be found and invoked by any LLM that helps operate calling.

This method helps you to transfer MCP servers from native improvement into secure, shareable infrastructure with out altering their core implementation. If a server runs over stdio, it may be packaged, deployed, and uncovered via Clarifai.

Now you can deploy your personal MCP servers, join them to your fashions, and lengthen your LLM functions with customized instruments or exterior integrations. For extra examples, discover the runners-examples repository.



Related Articles

Latest Articles