Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Authentication.dll Namespace: Microsoft.OData.Mcp.Authentication.Models Inheritance: System.Object

Syntax

Summary

Configuration options for a specific target service in token delegation.

Remarks

These options define how tokens should be handled when making requests to a specific downstream service. Each service can have its own delegation strategy, scopes, and authentication requirements.

Constructors

.ctor

Initializes a new instance of the TargetServiceOptions class.

Syntax

.ctor

Initializes a new instance of the TargetServiceOptions class with the specified service ID and base URL.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from object

Syntax

Properties

AdditionalHeaders

Gets or sets additional headers to include in requests to this service.

Syntax

Property Value

Type: System.Collections.Generic.Dictionary<string, string> A dictionary of header names and values to include in requests.

Remarks

These headers are added to all requests made to this service, in addition to the authentication token. They can be used for service-specific requirements like API versions or custom authentication schemes.

BaseUrl

Gets or sets the base URL of the target service.

Syntax

Property Value

Type: string The base URL where the service can be accessed.

Remarks

This URL is used to determine which requests should use this service’s delegation configuration. Requests to URLs starting with this base URL will use these settings.

ClientCredentials

Gets or sets the client credentials for service-to-service authentication.

Syntax

Property Value

Type: Microsoft.OData.Mcp.Authentication.Models.ClientCredentials? Credentials used when the service requires client authentication.

Remarks

These credentials are used for OAuth2 flows that require client authentication, such as on-behalf-of or token exchange. They identify the MCP server to the authorization server.

Scopes

Gets or sets the scopes to request for this service.

Syntax

Property Value

Type: System.Collections.Generic.List<string> A collection of OAuth2 scopes to request when obtaining tokens for this service.

Remarks

These scopes define the level of access requested for the target service. They should be the minimum scopes required for the MCP server to perform its operations on behalf of the user.

ServiceId

Gets or sets the unique identifier for the target service.

Syntax

Property Value

Type: string A unique string that identifies this service configuration.

Remarks

This identifier is used to look up the appropriate delegation configuration when making requests to downstream services. It should be unique within the MCP server’s configuration.

Strategy

Gets or sets the token forwarding strategy for this service.

Syntax

Property Value

Type: System.Nullable<Microsoft.OData.Mcp.Authentication.Models.TokenForwardingStrategy> The strategy to use when forwarding tokens to this service.

Remarks

If not specified, the global token delegation strategy will be used. Service-specific strategies allow for fine-grained control over how different services receive authentication tokens.

TargetAudience

Gets or sets the target audience for token exchange operations.

Syntax

Property Value

Type: string? The audience claim to request when exchanging tokens for this service.

Remarks

When using token exchange or on-behalf-of flows, this audience identifies the target service for the new token. It’s typically the service’s API identifier or base URL.

Timeout

Gets or sets the timeout for requests to this service.

Syntax

Property Value

Type: System.Nullable<System.TimeSpan> The timeout duration for requests to this service.

Remarks

If not specified, the global delegation timeout will be used. Service-specific timeouts allow for different performance expectations for different services.

TokenEndpoint

Gets or sets the token endpoint URL for this service.

Syntax

Property Value

Type: string? The URL of the token endpoint for OAuth2 operations.

Remarks

If not specified, the token endpoint will be discovered from the authorization server’s metadata. Specifying this directly can improve performance and provide more control over token operations.

ValidateBeforeForwarding

Gets or sets a value indicating whether to validate tokens before sending to this service.

Syntax

Property Value

Type: System.Nullable<bool> true if tokens should be validated before forwarding; null to use global setting.

Remarks

This setting overrides the global token validation setting for this specific service. Some services may have different validation requirements or performance characteristics.

Methods

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetEffectiveStrategy

Gets the effective token forwarding strategy for this service.

Syntax

Parameters

Returns

Type: Microsoft.OData.Mcp.Authentication.Models.TokenForwardingStrategy The strategy to use for this service.

GetEffectiveTimeout

Gets the effective timeout for this service.

Syntax

Parameters

Returns

Type: System.TimeSpan The timeout to use for this service.

GetEffectiveValidation

Gets the effective validation setting for this service.

Syntax

Parameters

Returns

Type: bool The validation setting to use for this service.

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MatchesUrl

Determines whether a URL matches this target service configuration.

Syntax

Parameters

Returns

Type: bool true if the URL matches this service; otherwise, false.

MatchesUrl

Determines whether a URI matches this target service configuration.

Syntax

Parameters

Returns

Type: bool true if the URI matches this service; otherwise, false.

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Override

Returns a string representation of the target service options.

Syntax

Returns

Type: string A summary of the target service configuration.

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?

Validate

Validates the target service options for consistency and completeness.

Syntax

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of validation errors, or an empty collection if the options are valid.