TNS
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
NEW! Try Stackie AI
AI / AI Engineering / Software Development

How To Access Local MCP Servers Through a Secure Tunnel

We show you how to utilize Ngrok to securely expose MCP servers to hosted LLMs — including creating an MCP client on the Anthropic Claude API.
Jun 5th, 2025 7:00am by
Featued image for: How To Access Local MCP Servers Through a Secure Tunnel
Image via Unsplash+. 

MCP servers are excellent candidates for exposing data from traditional databases as context to large language models (LLMs). Since these MCP servers reside on-premises closer to the data sources, we need a mechanism to expose them to remote LLMs and agents.

In this tutorial, we will explore how to utilize Ngrok to securely expose MCP servers to hosted LLMs. We will first build an MCP server based on streamable HTTP transport that returns data. We will then expose it through an Ngrok tunnel, and finally create an MCP client based on the Anthropic Claude API.

The diagram below explains this approach:

Step 1: Create an MCP Server

We will create a simple MCP server that returns employee data in JSON. This can be easily replaced with a database query to fetch the data from an existing database. Install the latest FastMCP Python module before proceeding.


Notice that we are using streamable HTTP as the transport.

Run the MCP server and ensure it is listening for incoming requests.

Step 2: Expose the MCP Server Through an Ngrok Tunnel

Start by installing Ngrok on your machine. This tutorial shows how to install and run it on macOS. Refer to the Ngrok documentation for other environments.


Get your Authtoken from the Ngrok dashboard and initialize the CLI.


We are now ready to open a secure tunnel to expose our MCP server.


Our MCP server is now accessible at the URL exposed by Ngrok. In my case, it is https://c45c-49-205-249-147.ngrok-free.app/mcp. We are now ready to build the MCP client that talks to this endpoint.

Step 3: Building an MCP Client with Claude API

The Claude API, which is in beta, supports invoking tools exposed by an MCP server directly within the request. Refer to the documentation on the latest API specification.

The code below demonstrates how to access remote MCP servers from Claude’s API. It assumes you have the API key from Anthropic and have installed the required Python modules.


The code is self-explanatory, as it points to the remote MCP server via the API. The prompt is about identifying the intern within the company, and this forces Claude to invoke the tools within the MCP server.

Claude successfully identified the intern and showed the details of the employee. This confirms that it is indeed accessing the remote MCP server.

In the upcoming tutorials of this series, we will explore how to implement OAuth to secure MCP servers. Stay tuned.

Created with Sketch.
TNS owner Insight Partners is an investor in: Anthropic.
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.