Connect an MCP server to an agent
Learn how to connect and call tools from an MCP (Module Context Protocol) server with Retool Agents.
Retool Agents Availability | |||
---|---|---|---|
Cloud-hosted | Public beta | ||
Self-hosted (3.259 Edge) | Public beta | ||
Self-hosted (Stable) | Not currently available |
Model context protocol (MCP) is an open standard introduced by Anthropic that provides a standard protocol for LLM-applications (clients) to call tools from a remote system (server).
To pull pre-built third-party integrations into your agent as tools from external data sources (such as GitHub, Slack, Cloudflare, Stripe, Docker, etc.), select Connect to MCP Server. You can select Add new resource from the Select MCP Server dropdown if you have not already created an MCP resource. You can configure the Tool Timeout for up to 2 minutes maximum.
Retool currently only supports remote-hosted MCPs.
An MCP server dynamically provides a list of tools. It is not a one-time static import from the server into Retool. The tool list is fetched whenever Retool connects to the MCP server.
MCP Server is a resource type configured with a URL, but you cannot write queries directly to these resources.
Key features:
- Add an MCP server to an agent.
- An agent can retrieve and select tools.
- Agents can invoke one or more of those tools.
Connect to an MCP server
Retool Agents can connect to open MCP servers via Streamable HTTP or SSE, as well as private MCP servers using Basic HTTP authentication with a username and password. OAuth is not yet supported.
Many MCP servers are built to run locally over stdio
. These can be exposed to Retool via an HTTP gateway. Here are sample instructions using supergateway and ngrok:
First, use supergateway to start an MCP server that is accessible at http://localhost:8000/sse
.
npx -y supergateway --stdio "npx <server package>" --cors
For example, the Brave Search MCP Server can be run via the command:
BRAVE_API_KEY=... npx -y supergateway --stdio "npx
@modelcontextprotocol/server-brave-search" --cors
Next, use ngrok to tunnel your local MCP server to the internet. Generate a strong password to use for authentication.
ngrok http --basic-auth 'mylongusername:mylongpassword' 8000
ngrok provides a temporary URL similar to the following: https://xyz-123.ngrok-free.app
, which is the server's base URL. ngrok also supports static domains.
If you are using supergateway, your MCP server URL will be https://xyz-123.ngrok-free.app/sse
, which you can then paste into Retool.
Connect an MCP server to an agent
To connect an MCP server to an agent:
- Open an existing agent or create a new one.
- On the Configuration tab, click Add new tool.
- Click Connect to MCP Server.
- Select a previously created resource from the Select MCP Server dropdown, or choose Add new resource.
- Give the new resource a Name.
- Paste in the URL of your MCP server in the Server URL field, and optionally add your Basic Auth credentials.
- Click Create resource.
The tools exposed by the MCP server will be available as tools on your Retool Agent.