Skip to main content

Definition

Assembly: Microsoft.Extensions.DependencyInjection.Abstractions.dll Namespace: Microsoft.Extensions.DependencyInjection

Syntax

Summary

This type is defined in Microsoft.Extensions.DependencyInjection.Abstractions.

Remarks

See Microsoft documentation for more information about the rest of the API.

Methods

AddODataMcp Extension

Extension method from Microsoft.Extensions.DependencyInjection.ODataMcp_AspNetCore_ServiceCollectionExtensions
Registers OData MCP services. Call UseODataMcp after mapping OData routes to turn MCP on at {prefix}/mcp. Discovers prefixes from ASP.NET Core endpoint routing (OData 7 MapODataRoute / Restier MapApiRoute and OData 8 conventional endpoints), plus any routes registered with IEdmModel). Prefer this unless a prefix must stay hidden from agents; then set ODataMcpHostOptions.IncludePrefixes or ODataMcpHostOptions.ExcludeRoutes.

Syntax

Parameters

Returns

Type: Microsoft.Extensions.DependencyInjection.IServiceCollection The service collection.

Examples

Remarks

This package does not reference Microsoft.AspNetCore.OData. The app brings OData 7 or 8. This method does not map endpoints. Call UseODataMcp to map MCP. Do not call the SDK MapMcp yourself.

AddODataMcp Extension

Extension method from Microsoft.Extensions.DependencyInjection.ODataMcp_AspNetCore_ServiceCollectionExtensions
Registers OData MCP services. Call UseODataMcp after mapping OData routes to turn MCP on at {prefix}/mcp. Discovers prefixes from ASP.NET Core endpoint routing (OData 7 MapODataRoute / Restier MapApiRoute and OData 8 conventional endpoints), plus any routes registered with IEdmModel). Prefer this unless a prefix must stay hidden from agents; then set ODataMcpHostOptions.IncludePrefixes or ODataMcpHostOptions.ExcludeRoutes.

Syntax

Parameters

Returns

Type: Microsoft.Extensions.DependencyInjection.IServiceCollection The service collection.

Examples

Remarks

This package does not reference Microsoft.AspNetCore.OData. The app brings OData 7 or 8. This method does not map endpoints. Call UseODataMcp to map MCP. Do not call the SDK MapMcp yourself.

AddODataMcp Extension

Extension method from Microsoft.Extensions.DependencyInjection.ODataMcp_AspNetCore_ServiceCollectionExtensions
Registers OData MCP services. Call UseODataMcp after mapping OData routes to turn MCP on at {prefix}/mcp. Discovers prefixes from ASP.NET Core endpoint routing (OData 7 MapODataRoute / Restier MapApiRoute and OData 8 conventional endpoints), plus any routes registered with IEdmModel). Prefer this unless a prefix must stay hidden from agents; then set ODataMcpHostOptions.IncludePrefixes or ODataMcpHostOptions.ExcludeRoutes.

Syntax

Parameters

Returns

Type: Microsoft.Extensions.DependencyInjection.IServiceCollection The service collection.

Examples

Remarks

This package does not reference Microsoft.AspNetCore.OData. The app brings OData 7 or 8. This method does not map endpoints. Call UseODataMcp to map MCP. Do not call the SDK MapMcp yourself. Configure Tasks here, not on UseODataMcp.

AddODataMcpCore Extension

Extension method from Microsoft.Extensions.DependencyInjection.ODataMcp_Core_ServiceCollectionExtensions
Adds the CSDL parser and a named OData HttpClient.

Syntax

Parameters

Returns

Type: Microsoft.Extensions.DependencyInjection.IServiceCollection The service collection.

AddProtectedResourceMetadata Extension

Extension method from Microsoft.Extensions.DependencyInjection.ODataMcp_AspNetCore_ServiceCollectionExtensions
Publishes RFC 9728 protected resource metadata for this host, and annotates the WWW-Authenticate challenge on a 401 beneath a covered route base with the URL of that document. This is how a client such as dotnet odata-mcp start discovers how to sign in without being told.

Syntax

Parameters

Returns

Type: Microsoft.Extensions.DependencyInjection.IServiceCollection The service collection.

Exceptions

Examples

Remarks

Independent of IServiceCollection): an API that hosts no MCP server at all still benefits, because the discovery this feeds is the client’s, not ours. The default route base is the application root. Set ProtectedResourceMetadataOptions.Prefixes to any route base Endpoint Routing or Minimal APIs accept, including an empty string, when the resource is not the whole host. The middleware is inserted at the front of the pipeline through an IStartupFilter, which is what keeps the metadata document anonymously readable. There is no Use call to add. Calling this more than once adds the extra configuration and registers the filter once.