Definition
Assembly: Microsoft.Extensions.DependencyInjection.Abstractions.dll Namespace: Microsoft.Extensions.DependencyInjectionSyntax
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_ServiceCollectionExtensionsUseODataMcp 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. CallUseODataMcp to map MCP. Do not call
the SDK MapMcp yourself.
AddODataMcp Extension
Extension method from
Microsoft.Extensions.DependencyInjection.ODataMcp_AspNetCore_ServiceCollectionExtensionsUseODataMcp 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. CallUseODataMcp to map MCP. Do not call
the SDK MapMcp yourself.
AddODataMcp Extension
Extension method from
Microsoft.Extensions.DependencyInjection.ODataMcp_AspNetCore_ServiceCollectionExtensionsUseODataMcp 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. CallUseODataMcp 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_ServiceCollectionExtensionsSyntax
Parameters
Returns
Type:Microsoft.Extensions.DependencyInjection.IServiceCollection
The service collection.
AddProtectedResourceMetadata Extension
Extension method from
Microsoft.Extensions.DependencyInjection.ODataMcp_AspNetCore_ServiceCollectionExtensionsWWW-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 anIStartupFilter, 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.