> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tryhamsa.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an MCP server to give your agent its functions

> Add an MCP server in APIs & MCPs, check the connection, attach it to a single prompt or flow agent, and learn how its functions are used on calls.

An MCP server offers a set of functions over the Model Context Protocol. When you connect one, your agent can call any of those functions during a call, and decides from the conversation when to use them. This page shows how to add a server, attach it to an agent, and what to expect on calls.

## Before you start

* You need permission to create tools. See [APIs & MCPs](https://docs.tryhamsa.com/agents/tools/overview.md#before-you-start).
* The server must be reachable from the internet at a public HTTPS URL and support the streamable HTTP transport. Addresses on localhost or a private network are refused.
* If the server needs a key, store it as a [secret](https://docs.tryhamsa.com/agents/tools/secrets.md) first.

## Add an MCP server

**1. Start a new tool**

Open **APIs & MCPs**, click **Add new tool** and choose **MCP server**.

**2. Name and describe it**

Enter a **Tool name** and a **Description** so you and your team know what the server is for.

**3. Enter the connection settings**

Under **Tool settings**, enter the server's **URL**, the **Timeout**, and the **Authentication** and **Headers** it needs.

**4. Connect**

Under **Functions**, click **Connect and list functions**. When the server answers you see "Connected. The server offers N functions." and the list of functions with their inputs.

**5. Save**

Click **Create**. You can only save after a successful check of the current settings. If you change the URL, authentication or headers after checking, the list dims ("The connection settings changed since this check. Check again before saving."): click **Check again**.

![The Add new MCP server form after connecting: Connected. The server offers 6 functions, with the functions and their inputs listed](https://mintcdn.com/hamsa-452fa79a/7GY0-8K2sfzXu6G7/images/agents/tools/mcp-server-form-light.webp?fit=max\&auto=format\&n=7GY0-8K2sfzXu6G7\&q=85\&s=e80f17363f9d7a15199de2a9f922af79)

The list of functions isn't saved. Agents read it from the server at the start of every call, so functions you add or remove on the server reach your agents on their next call. The tool's page reads the list live too ("Read from the server when you open this page.").

### Long lists of functions

Some servers offer dozens or hundreds of functions. The form and the tool's page show the first 10. Click **Show \{n} more** to see up to 25 more at a time; the line beside it says how many are still hidden ("\{n} more not shown"). When a server offers more than 10 functions, a **Search functions** box above the list searches all of them, by name and description, not only the ones on screen.

![An MCP server's functions searched for product: ten matching functions with their inputs, then Show 6 more and 6 more not shown](https://mintcdn.com/hamsa-452fa79a/7GY0-8K2sfzXu6G7/images/agents/tools/mcp-functions-show-more-light.webp?fit=max\&auto=format\&n=7GY0-8K2sfzXu6G7\&q=85\&s=3651b7f49b4827af87e1ccd835771302)

## Settings

| Field | What it does | Default |
| - | - | - |
| **Tool name** | Your name for the server in Hamsa. | |
| **Description** | What the server is for. | |
| **URL** | The server's MCP endpoint. Must start with `https://`. | |
| **Timeout** | Seconds, from 1 to 60. | 5 |
| **Authentication** | **No authentication**, **Bearer token**, **Token** or **Basic authentication**. | **No authentication** |
| **Headers** | Extra headers to send, such as an API key header. | |

To use a secret, click the key icon next to the token or a header value and pick the secret: the field holds `{{secrets.NAME}}` and the value is filled in when the agent connects.

MCP servers have no **Method**, **On hold music**, **Async execution** or parameters: the server describes its own functions.

## Attach it to an agent

> [tab] Single prompt agent
>
> Under **Tools**, click **Manage** and select the server in **Select tools** (filter **Type** by **MCP server**). Click **Done**.
>
> Under **Tool configuration** you can change the server's connection settings (authentication, timeout, headers) for this agent only.

> [tab] Flow agent
>
> Open **Global settings**, go to **MCP servers** and click **Add MCP servers**. Pick the servers and save. Their functions are available on every step of the flow.
>
> ![A flow's Global settings, MCP servers, with the store\_catalog server added](https://mintcdn.com/hamsa-452fa79a/7GY0-8K2sfzXu6G7/images/agents/tools/flow-mcp-servers-light.webp?fit=max\&auto=format\&n=7GY0-8K2sfzXu6G7\&q=85\&s=c905a5f78884e6bec7d82fec4bc44dbd)
>
> MCP servers aren't picked on individual steps.

## How it works on a call

* When the call starts, the agent connects to each attached server and gets its functions. A server that can't be reached is skipped, and the call goes on without it.
* The model sees every function the server offers, with the server's own names and descriptions, and calls them when the conversation needs them. This works the same on single prompt and flow agents.
* If a function call fails, the agent is told the action couldn't be completed and to carry on without mentioning technical problems.

## Good to know

* Every function on the server is offered to the agent. If a server offers functions the agent shouldn't use, connect a server (or a server URL) that offers only the ones you want.
* Function descriptions come from the server. Clear descriptions there help the agent pick the right function.
* On a flow agent, MCP functions run when the model decides to call them, not when the call reaches a step.
* You can't delete an MCP server tool while an agent uses it.

## Related

> [card] [APIs & MCPs](https://docs.tryhamsa.com/agents/tools/overview.md)
>
> Kinds of tools and how agents use them.

> [card] [Connect an API](https://docs.tryhamsa.com/agents/tools/api-tools.md)
>
> Call a single endpoint with exact control.

> [card] [Secrets](https://docs.tryhamsa.com/agents/tools/secrets.md)
>
> Keep the server's key out of the tool.

> [card] [Flow settings](https://docs.tryhamsa.com/agents/flow/flow-settings.md)
>
> Global settings for a whole flow.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.