How to Let a Cloud AI Agent Use Your Localhost API (No Open Ports)

A cloud AI agent cannot call http://localhost on your machine, because the request starts in the provider's cloud, not on your computer. You either give the local service a public address (a tunnel) or run a small outbound-only connector next to it that picks up the agent's calls.

6 min read / Updated:

Connect a local system to Qaalia
An AI agent calling your API with a permission on every operationCreate the customerAna Ruiz, ana@acme.coAgentYour APIPOST/customersAllowedGET/orders/{id}AllowedPOST/refundsApprovalDELETE/customersBlocked

Short answer: an agent that runs in the cloud can only reach addresses that are reachable from the internet. To let it use an API on localhost, an internal server or a NAS, something on your side has to open the path. A tunnel gives the service a public URL that you must then protect. An outbound-only connector keeps the service private: it connects out to the agent platform, receives the calls and runs them locally. This guide compares both and shows how the second one works in Qaalia, for Qaalia's own agent.

Why can't ChatGPT or Claude reach my localhost API?

Because localhost always means "this same machine". When a hosted assistant calls a tool, the HTTP request is made from the provider's servers, so localhost points to their machine, not yours. ngrok's documentation puts it plainly: AI apps like ChatGPT, Claude.ai and Grok call MCP servers from their own cloud and cannot reach a server running on localhost on your laptop, VM or container (ngrok docs, checked November 23, 2026). The same applies to an internal API on your office network or a database behind a firewall.

What are the options for connecting a cloud agent to a local system?

OptionHow it worksWhat to watch
Deploy the API publiclyMove the service to a server with a public HTTPS addressReal hosting work; the API is now on the internet and needs full authentication
Tunnel (ngrok and similar)A local agent opens an outbound connection and the tunnel provider gives you a public URL that forwards to localhostThe URL is reachable by anyone who has it, so you must add authentication and limits
VPN or private networkThe cloud service joins your networkUsually not available for hosted assistants; heavier to operate
Outbound-only connectorA small program next to your system connects out, picks up the agent's calls and runs them locallyWorks only with the platform that ships the connector; the machine must be on

Tunnels are the standard answer for hosted assistants and they work well. The trade-off is that you create a new public entry point, and its security becomes your job. A connector inverts that: nothing new is published, and the scope of what can be called is fixed on your machine.

How does an outbound-only connector work?

The Qaalia Connector is a small Node.js program (npx qaalia) that you install once on the machine where your system runs. It never opens a port. It keeps a connection out to Qaalia, and when Qaalia's agent wants to use one of your tools, the call is queued for the Connector, which picks it up, confirms with Qaalia that it is still valid, and only then calls your local API. Your system answers the Connector, and the Connector returns the answer to the agent. For the full design, read why AI agents cannot reach localhost.

Important scope note: the Connector connects your system to Qaalia's agent, the one you use in Qaalia Chat, from your own app through Qaalia's API with an API key, or from Qaalia triggers. It is not a way to plug ChatGPT or Claude into your localhost.

How do you connect a local API to Qaalia, step by step?

  1. Check the machine: it needs Node.js 18 or later (or Docker), and your API must be running, for example at http://localhost:3000.
  2. Add the system: in Qaalia Chat, open Systems, click Add system and choose "It's on my machine or my network". Enter the local address of your API.
  3. Run the command: Qaalia shows a command with a one-time code that expires in 15 minutes. Paste it into a terminal on that machine. The Connector publishes your system's tools and waits for work.
  4. Let it discover your operations: if your API publishes an OpenAPI or Swagger spec at a usual path such as /openapi.json, /swagger.json or /v3/api-docs, its operations appear on their own.
  5. Leave it as a service: run npx qaalia servicio instalar. It becomes an operating system service (systemd on Linux, launchd on macOS, Task Scheduler on Windows) that starts with the machine and restarts if it fails. On a server or NAS you can use the Docker command instead.
  6. Choose a permission for each tool: allow, requires approval or blocked. Then ask the agent for something, for example "Enroll Ana Ruiz in Physics".

Can the agent also use local MCP servers and local files?

Yes. The same Connector can publish three things, together or separately: your local API (--api), a folder the agent can only read (--carpeta) and local MCP servers that run as a command (--mcp "name=command", repeatable), such as a database's MCP server. The Connector acts as the MCP client of those local servers, so their credentials stay on your machine. The folder is read-only: the agent can list it and read text files (CSV, JSON, TXT, Markdown and similar) of up to 2 MB, in parts when they are large, and it can never write or leave the folder. With Docker, the API and the local MCP servers are published; the shared folder is not available.

What happens when the machine is off or the connection drops?

  • No signal for 45 seconds: the system shows as disconnected and the agent says so right away, without running the action.
  • Nothing runs late: a call the Connector does not pick up within 30 seconds expires and never runs, even if the machine comes back later.
  • Dropped in the middle of an action: Qaalia does not repeat it on its own, so it is not applied a second time; the agent tells you it may have been applied.
  • Each call to your machine can take up to 40 seconds.

How is the local system kept safe?

  • Only outbound connections to Qaalia; no port is opened and nothing is published.
  • It only calls the API, reads the folder and uses the MCP servers you set when connecting. Qaalia cannot widen that scope.
  • It only runs tools you allowed or approved, and only after Qaalia confirms the call is still valid.
  • Its key is stored on your machine in ~/.qaalia; Qaalia keeps only a hash of it. Deleting the system in Qaalia disconnects it.
  • Every call to your local API carries an Idempotency-Key header, so your API can ignore a duplicate.

FAQ

Can ChatGPT connect to a local MCP server on my computer?

Not directly. ChatGPT calls MCP servers from OpenAI's cloud, so it needs a public URL; the usual workaround is a tunnel. The Qaalia Connector does not change that: it connects your local system to Qaalia's agent, not to ChatGPT.

Do I need to open a port or set up a VPN to use the Qaalia Connector?

No. The Connector only makes outbound connections to Qaalia. It does not open ports or publish your system on the internet.

Does my API need an OpenAPI spec?

It helps. If the local API publishes its spec at a usual path such as /openapi.json, Qaalia lists its operations automatically. You can also add operations by hand as manual operations.

Do I have to keep a terminal open?

No. Install it as a service with npx qaalia servicio instalar, or run it in Docker, and it starts with the machine and restarts if it fails.

Can the agent write to the shared folder?

No. The folder is read-only. The agent can list it and read text files up to 2 MB; it cannot write, delete or read outside it, including through symbolic links.