# Connect to Existing Agents

If you've already built an agent using another platform, you can still use Kiln to evaluate and optimize your system!

### Step 1: Expose your Existing Agent as an MCP Server

Wrap your existing agent in an [MCP server](https://modelcontextprotocol.io/docs/getting-started/intro), so Kiln can call it. You can use any library, framework, or programming language.

Exactly how to do this will depend on how you implemented your existing agents, but every major programming language has an MCP library for wrapping existing functions as MCP servers:

* [Python](https://github.com/modelcontextprotocol/python-sdk?utm_source=chatgpt.com)
* [Javascript/Typescript](https://github.com/modelcontextprotocol/typescript-sdk?utm_source=chatgpt.com)
* [Go](https://github.com/modelcontextprotocol/go-sdk)
* [Rust](https://github.com/modelcontextprotocol/rust-sdk?utm_source=chatgpt.com)
* [Java](https://github.com/modelcontextprotocol/java-sdk)
* [More](https://github.com/modelcontextprotocol)

### Step 2: Connect Your MCP Server to Kiln

Follow [our instructions](https://docs.kiln.tech/docs/tools-and-mcp/..#connecting-tools) to connect your MCP server to Kiln.

### Step 3: Connect an MCP Tool to a Kiln Task

A "task" in Kiln represents a unit of work an agent can do. It has a specific input/output schema, and may have a collection of evals to measure quality. There are a number of ways to connect an MCP tool to your Kiln tasks.

#### Option 1: Create a New Kiln Task From an MCP Tool

The easiest way is to create a new task from your MCP tool signature. It will create a new task with the exact same input and output schema as your MCP tool.

This is the preferred option if you're just getting started and don't already have evals created for an existing task. However, if you already have evals and Kiln agents, you'll probably want to use Option 2 or Option 3.

To create a new task from a tool, click `Settings > Manage Tools > Tool Server > Individual Tool > [...] Menu > Create Task from Tool`.

<figure><img src="https://2952104390-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEJ4b8A4QiEQlOGbYkXDX%2Fuploads%2FEDKCY0NDzoSqKLH8UsqH%2FScreenshot%202026-02-20%20at%202.36.57%E2%80%AFPM.png?alt=media&#x26;token=8b7b7ef7-8344-4983-adf5-40ff8edfabb5" alt="" width="276"><figcaption></figcaption></figure>

#### Option 2: Use a Wrapper Agent

Any existing Kiln task can call your MCP tools. You can give your existing agents in Kiln access to your external MCP tools by selecting them in the `Tools & Search` dropdown on the run screen.

<figure><img src="https://2952104390-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEJ4b8A4QiEQlOGbYkXDX%2Fuploads%2FSaPiDTHth9LbKhINPCcu%2FScreenshot%202026-02-20%20at%202.38.22%E2%80%AFPM.png?alt=media&#x26;token=51dfbb2e-336d-4b81-94f6-461624f6cea8" alt="Select Tools on the Run Screen" width="375"><figcaption></figcaption></figure>

This is a great approach if your task's input/output schemas doesn't exactly match your tool's input/output schemas. The wrapping LLM agent can follow instructions, and call the tool with the needed parameters.

#### Option 3: Connect an MCP Tool to an Existing Task

If you have an existing Kiln task and want to use Kiln to compare multiple methods of running your task (MCP tools, Kiln agents), you can connect your MCP tool to an existing task as a "Run Configuration". Run configurations describe how to run a specific task. For an agent, it's typically fields like model, system prompt, and LLM parameters; however, a run configuration can also point to any MCP server.

{% hint style="info" %}
The input/output signature of your MCP tool **must exactly match** the input/output signature of your Kiln task, or you won't be able to directly connect a task to an MCP tool.

If it doesn't match, we suggest either using a wrapper agent (option 2) or modifying the MCP tool's schema to align to your task.
{% endhint %}

To connect an MCP tool to an existing task, click  `Settings > Manage Tools > Tool Server > Individual Tool > [...] Menu > Run Task with Tool > Run Task Directly`.

<figure><img src="https://2952104390-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEJ4b8A4QiEQlOGbYkXDX%2Fuploads%2FxehqT9DtHIjaCMzPzwBR%2FScreenshot%202026-02-20%20at%202.47.25%E2%80%AFPM.png?alt=media&#x26;token=1904903a-d702-4c1f-bdec-b711f73c079e" alt="" width="375"><figcaption></figcaption></figure>
