Skip to content
Tracon

TraconMcpBuilderExtensions

Namespace Tracon · Assembly Tracon.Mcp.dll

Extensions that register tool discovery from remote MCP servers.

public static class TraconMcpBuilderExtensions

objectTraconMcpBuilderExtensions

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Registers the Model Context Protocol client. Tools from every registered and enabled MCP server are discovered and listed alongside the tools registered in code.

public static ITraconBuilder UseMcp(this ITraconBuilder builder)

builder ITraconBuilder

The Tracon configuration chain.

ITraconBuilder

The chain, for further configuration.

Security boundary. Adding an MCP server means accepting tool definitions from an external source, and is a deliberate exception to the code-only tools rule (“tools are defined only in code”). It comes with the following safeguards:

  • Only remote HTTP servers; there is no local process (stdio) transport.
  • MCP tools require approval by default.
  • A tool name already registered in code can never be hijacked by MCP.
  • The server definition carries no secret; the authentication value is resolved from configuration.
  • Every call is written to the tool_invocations table with the source server name.
builder.AddTracon()
.UseOpenAI(apiKey)
.UsePostgreSql(connectionString)
.UseMcp()
.UseUI();

ArgumentNullException

builder is null.

UseMcp(ITraconBuilder, Action<TraconMcpOptions>)

Section titled “ UseMcp(ITraconBuilder, Action<TraconMcpOptions>)”

Registers the Model Context Protocol client with settings given in code.

public static ITraconBuilder UseMcp(this ITraconBuilder builder, Action<TraconMcpOptions> configure)

builder ITraconBuilder

The Tracon configuration chain.

configure Action<TraconMcpOptions>

The option modifier.

ITraconBuilder

The chain, for further configuration.

ArgumentNullException

One of the parameters is null.

UseMcp(ITraconBuilder, IConfiguration, Action<TraconMcpOptions>?)

Section titled “ UseMcp(ITraconBuilder, IConfiguration, Action<TraconMcpOptions>?)”

Registers the MCP client, reading options from the Tracon:Mcp section.

public static ITraconBuilder UseMcp(this ITraconBuilder builder, IConfiguration configurationSection, Action<TraconMcpOptions>? configure)

builder ITraconBuilder

The Tracon configuration chain.

configurationSection IConfiguration

The section options are read from. Typically configuration.GetSection(TraconMcpOptions.SectionName).

configure Action<TraconMcpOptions>?

The option modifier that runs AFTER the section is bound. A value given in code overrides the value coming from configuration. Pass null when configuration alone is enough.

ITraconBuilder

The chain, for further configuration.

Configuration is provided explicitly; Tracon never reads IConfiguration on its own. This follows the no-surprises rule and stays consistent with the other Use* extensions in the repository.

builder.AddTracon()
.UseMcp(builder.Configuration.GetSection(TraconMcpOptions.SectionName), configure: null);

ArgumentNullException

builder or configurationSection is null.