Skip to content
This documentation covers kagent while it is in development and can describe unreleased features. For the current release, see the latest docs.

Add an MCP server

Page as Markdown

Register a Model Context Protocol server and give its tools to your agent.

Add an MCP server

Register a Model Context Protocol server and give its tools to your agent.

About this tutorial

A system prompt tells an agent how to behave. Tools tell it what it can do. In this tutorial, you register a weather Model Context ProtocolModel Context ProtocolAn open protocol for exposing tools and resources to a model. kagent reaches an MCP server through a RemoteMCPServer resource, and an AgentTemplate binds individual tools from it.Learn more (MCP) server in the kagent UI, and give its tool to the personal assistant from Build an agent.

A registered server is a RemoteMCPServer resource. kagent connects to it, reads its tool list, and lets any agent in the namespace bind those tools, without an egress policy. For how agents use tools, see About tools and Core concepts.

To bind a tool from YAML instead, see Your first MCP tool.

Time: about 10 minutes.

Before you begin

  1. Complete Build an agent, so that the personal-assistant agent exists.
  2. Make sure that your cluster can reach the internet. The weather server in this tutorial is a public demonstration server that the kagent project does not run, so it can change or go away. Any MCP server that speaks streamable HTTP or SSE works the same way.

Register the server and use it

Follow the steps in the kagent UI, or apply the same resources as YAML from the command line.

Open the kagent UI

kagent dashboard

The command forwards the UI to http://localhost:8082 and opens it in your browser. Leave it running while you work.

Register the MCP server

The kagent UI registering an MCP server named weather, expanding it to show the get_weather tool, then adding the server to the personal-assistant agent
Figure: Registering the weather server and adding it to the agent, sped up
  1. In the sidebar, click MCP Servers, and then click New Server.

  2. Fill in the form.

    FieldValue
    Nameweather
    Namespacekagent
    Server URLmcp-weather-1cyg.onrender.com/mcp
    TLSHTTPS. The scheme in front of the URL changes to https://.
    Use streamable HTTP instead of SSESelected, which is the default.
    Connection timeout60s. When the server has been idle, its first answer can take close to a minute.
  3. Click Create server. kagent connects to the server and reads its list of tools.

  4. On the MCP servers page, click Refresh until the weather server shows 1 in the Tools column. Expand the row to see the tool, get_weather, which returns the current weather for a pair of GPS coordinates.

Give the tool to your agent

An agent does not need an egress policy to reach a model or a registered MCP server.

  1. In the sidebar, click Agents. In the row of the personal-assistant agent, click the edit icon.

  2. Under Tools from MCP servers, click Add an MCP server, and choose kagent/weather from the MCP server list.

    Leave the tool list on All tools to expose every tool from the server. To expose only some tools, choose them from that list. To make the agent pause for your approval before it runs a tool, select Require approval.

  3. Click Save agent. The agent shows the Updating status while kagent prepares a new revision, and then returns to Ready.

  4. Click the agent name to open its chat page, and ask about the weather, such as What is the weather in Toronto right now?.

Verify the tool

  1. Check that kagent accepted the weather server.

    kubectl get remotemcpserver weather -n kagent

    The ACCEPTED column shows True.

  2. Check that the agent is ready again after the change.

    kubectl get agent personal-assistant -n kagent

    Example output:

    NAME                 READY   AGE
    personal-assistant   True    10m
    
  3. In the kagent UI, open a New chat with personal-assistant, and ask What is the weather in Toronto right now? The conversation shows a get_weather tool call before the answer.

What you built

An agent that calls a tool from a remote MCP server. Along the way, you used these features:

FeatureWhat you didRead more
Remote MCP serversRegistered a server that speaks streamable HTTP, with a connection timeoutAbout tools
Tool bindingsGave the agent the server’s tools, all of them or a chosen fewAbout tools

Clean up

If you go on to Human in the loop, keep these resources, because that tutorial reuses them.

  1. Delete the agent and the weather server.
    kubectl delete agent personal-assistant -n kagent
    kubectl delete remotemcpserver weather -n kagent

Next steps