Midio docs
  • Getting Started
    • Welcome
    • Quick Start Guide
  • Your First Midio App
  • Guides
    • HTTP
      • Making HTTP Requests
      • Responding to HTTP Requests
      • How to reach your own endpoints
      • CORS
      • Server-Sent Events (SSE)
    • Branching
    • Loops
    • Map, filter, reduce
    • Working with Data
    • Expressions
    • Building Agents
      • Streaming Agent API (experimental)
    • Debugging
    • Secrets and Environment variables
    • Convert JSON to data nodes
    • Writing tests
    • Cleaning up your flows
  • Package Manager
  • Integrating with third party services
  • Troubleshooting
  • Tutorials
    • Connecting LLMs to MCP-servers using the MCP-client package
    • Making Your Own MCP Server in Midio
    • A Fast Path to Functional RAG Agents
    • How to build a streaming agent using Server-Sent Events (SSE)
  • Reference
    • The Midio Editor
      • The Node Editor
      • User Traces
      • Traces (execution)
      • Processes
      • Log
      • Services
      • Problems
      • Function Signature
      • Data
      • Settings
    • The Midio Language
      • Nodes and execution
      • Functions and Events
        • Anonymous functions
      • Modules
      • Contexts
      • Data type
      • Local variables
      • Portals
      • Waypoint node
      • Partial function application
  • The Midio Engine
  • Built in Nodes
    • Core (std)
    • HTTP
    • LLM
Powered by GitBook
On this page
  • How to set up the package
  • Making tools accessible to the LLM
  • Testing with the Todo-MCP example
  • Connecting to a local MCP server using localtunnel and mcp-proxy
  • Install dependencies
  • Next steps

Was this helpful?

Edit on GitHub
  1. Tutorials

Connecting LLMs to MCP-servers using the MCP-client package

PreviousTroubleshootingNextMaking Your Own MCP Server in Midio

Last updated 14 days ago

Was this helpful?

We recently implemented an MCP client package in Midio that allows you to easily connect LLMs to any MCP server, as long as it supports the SSE transport. In this guide we’ll see how we can use the package, and show an example of how you can set up a local MCP server with a tunnel that allows Midio to connect to it.

How to set up the package

First, add the mcp-client package using the package manager.

The first thing we do is to add an instance of Connect to MCP Server. This function accepts a name and version for our client, which we can choose ourselves, and the URL of the server we want to connect to.

This node takes care of the whole song and dance of connecting, initializing and setting up long-lived communication channels with the server.

Making tools accessible to the LLM

To give our LLM node (for example open-ai Chat Complete, which can be added from the package manager by searching for “open-ai”) access to the tools in our server, we can use the Get LLM Compatible Tools List function. It retrieves the list of available tools from the server, and creates a handler function for each of them, which is automatically set up to relay any request from our LLM to be handled by the MCP server.

Now, all we have to do is connect the tools output to the tools input of our Chat Complete node, and we’re good to go.

Finally, we disconnect from the server using Disconnect from MCP Server.

Testing with the Todo-MCP example

We give our agent a system prompt so it understands it should manipulate a todo list, and then we can ask it to do something.

Here is a simple system prompt you can use:

You are a Todo list agent. You have access to performing todo list operations through various tools. You act on the users behalf to satisfy their request.

Click the play button on the Connect to MCP Server node to run the flow.

Connecting to a local MCP server using localtunnel and mcp-proxy

Most MCP-servers you'll find on the internet are programs you are expected to run locally on your machine, or host somewhere yourself. They are also usually designed for the STDIO transport, which is a kind of protocol which is typically only used when both the client and server are run on the same machine.

Install dependencies

Then, in one terminal, run the following:

uv tool install mcp-proxy
mcp-proxy --port 1337 uvx mcp-server-git

The first line installs the mcp-proxy tool, and the next one starts it with the mcp-server-git MCP server as a target. You should first navigate to a local git repository with which you want the server to interact.

You can then run:

npx localtunnel --port 1337

To set up a tunnel to your local MCP server which your Midio client will be able to reach.

You should see something like the following:

npx localtunnel --port 1337
Need to install the following packages:
localtunnel@2.0.2
Ok to proceed? (y) y

your url is: <https://puny-mammals-kick.loca.lt>

You can then copy that URL into the Connect to MCP Server node in midio.

Make sure you append "/sse" to the URL:

https://puny-mammals-kick.loca.lt/sse

You’re all set. You can now run the flow from the Connect to MCP Server node, and for example use the following system and user prompts for your Chat Complete node.

Here is a simple system prompt for testing:

You are a Git agent. You have access to performing git commands on a repo through various tools. You act on the users behalf to satisfy their request.

Next steps

You can also check out these guides for how to connect your flows to a frontend made with Lovable.

A Fast Path to Functional RAG Agents

How to build a streaming agent using Server-Sent Events (SSE)

Let’s connect to an actual server. If you don’t have your own at hand, you can set one up in Midio by following .

Since Midio is hosted in the cloud, it can’t directly access your machine. But for testing purposes there are simple tools you can use to make this possible (we’ll use a tool called ). We can also easily create a mapping from STDIO to SSE using a tool called .

You need the python tool and to do the following. Please install them first.

You now have a simple MCP client flow set up, but the only way to interact with it is by manually running flows in the editor. Midio makes it super simple to expose your flows as API endpoints using the HTTP Endpoint node, which you can read about .

this guide
local tunnel
mcp-proxy
uv
node
here