# TraconMcpServerBuilderExtensions

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.traconmcpserverbuilderextensions/
> Summary: TraconMcpServerBuilderExtensions: Extensions that register the services needed to publish Tracon agents as MCP tools.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.AspNetCore.dll</code></div>

Extensions that register the services needed to publish Tracon agents
as MCP tools.

```csharp
public static class TraconMcpServerBuilderExtensions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.traconmcpserverbuilderextensions/">TraconMcpServerBuilderExtensions</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Methods

### <a id="Tracon_TraconMcpServerBuilderExtensions_UseMcpServer_Tracon_ITraconBuilder_System_Action_Tracon_TraconMcpServerOptions__"></a> UseMcpServer\(ITraconBuilder, Action<TraconMcpServerOptions\>?\)

Registers the MCP server services. The HTTP endpoint must still be
connected separately with `app.MapTraconMcpServer(...)`.

```csharp
public static ITraconBuilder UseMcpServer(this ITraconBuilder builder, Action<TraconMcpServerOptions>? configure = null)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

The Tracon configuration chain.

`configure` [Action](https://learn.microsoft.com/dotnet/api/system.action\-1)<[TraconMcpServerOptions](/api/tracon.traconmcpserveroptions/)\>?

Options mutator.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The chain, for further configuration.

#### Remarks

Registration happens HERE, not in `MapTraconMcpServer`: the MCP
SDK's `AddMcpServer` call operates on [IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection)
and must happen BEFORE the application is `Build`-ed. The
`Map...` extensions only connect already-built services to HTTP.

By default **no agent is exposed**. Exposing one
requires an explicit choice via
[TraconMcpServerOptions.ExposedAgents](/api/tracon.traconmcpserveroptions/#Tracon_TraconMcpServerOptions_ExposedAgents) or
[TraconMcpServerOptions.ExposeAllAgents](/api/tracon.traconmcpserveroptions/#Tracon_TraconMcpServerOptions_ExposeAllAgents).

Also registers the MCP Tasks extension, gated OFF by default
through [TraconMcpServerOptions.EnableTasks](/api/tracon.traconmcpserveroptions/#Tracon_TraconMcpServerOptions_EnableTasks): the
execution-mode selector returns `McpTaskExecutionMode.Synchronous`
when it is off, which is the SDK's own fast path back to today's
behavior — `CreateTaskAsync` is never called. The task-provisioning
filter ([Tracon.McpTaskRunProvisioningFilter](/api/tracon/)) is still registered
unconditionally; it is value-transparent when tasks are off, since it
only replaces [Tracon.CatalogToolCallHandler](/api/tracon/)'s own id-minting with
an equivalent one handed down ambiently.

```csharp
builder.AddTracon()
       .UseOpenAI(apiKey)
       .UsePostgreSql(connectionString)
       .UseMcpServer(o => o.ExposedAgents.Add("asistan"));
// ...
app.MapTracon("/tracon");
app.MapTraconMcpServer();
```

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

`builder` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).
