Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Tools.dll Namespace: Microsoft.OData.Mcp.Tools.Hosting Inheritance: System.Object

Syntax

Summary

The local MCP host for a remote OData service: one generic host that owns the authenticating "OData" client, the unauthenticated "OAuth" client, the token cache, the catalog built from the service’s $metadata, and — when the process is serving stdio — the MCP server itself.

Remarks

There is exactly one Build(), and everything the process needs is registered before it. That matters because IHttpClientFactory cannot be shared between service providers: the $metadata GET has to run through the same authenticating client the tools later run through, or the credential the handler negotiated would be attached to one client and thrown away with the other.

Examples

Constructors

.ctor

Initializes a new instance of the ToolsMcpHost class.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from object

Syntax

Properties

Catalog

Gets the catalog advertised by this host.

Syntax

Property Value

Type: Microsoft.OData.Mcp.Core.Catalog.ODataMcpCatalog

Host

Gets the generic host that owns every service this host resolves, including the two named HTTP clients and, when stdio is enabled, the MCP server.

Syntax

Property Value

Type: Microsoft.Extensions.Hosting.IHost

ServiceRoot

Gets the remote service root, always with a trailing slash.

Syntax

Property Value

Type: System.Uri

Session

Gets the MCP session.

Syntax

Property Value

Type: Microsoft.OData.Mcp.Core.Catalog.ODataMcpSession

Methods

CreateAsync

Builds the host, authenticates against the remote service, fetches and parses $metadata, and returns a host whose catalog and session are ready to serve.

Syntax

Parameters

Returns

Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Tools.Hosting.ToolsMcpHost> The host.

Exceptions

Examples

Remarks

The order here is the whole point. Registrations first, configureServices last, then one Build(); only afterwards does anything touch the network, because the $metadata GET is what drives the authentication handler through discovery, consent, and the token cache. A restart that finds a still-valid cached token spends exactly one request here: no device code, no token endpoint, no discovery. The credential store is not probed here either: OutboundOAuthClient proves it usable on the first acquisition, so a service that answers $metadata without a challenge never touches the operating system keyring and never creates a token cache directory.

Dispose

Syntax

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?
  • System.IDisposable