Skip to main content

Definition

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

Syntax

Microsoft.OData.Mcp.Authentication.Models.McpAuthenticationOptions

Summary

Configuration options for MCP server authentication.

Remarks

These options control how the MCP server validates and delegates authentication tokens. The server acts as an OAuth2 resource server, validating tokens issued by external authorization servers and optionally forwarding them to downstream OData services.

Constructors

.ctor

Initializes a new instance of the McpAuthenticationOptions class.

Syntax

public McpAuthenticationOptions()

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

Enabled

Gets or sets a value indicating whether authentication is enabled.

Syntax

public bool Enabled { get; set; }

Property Value

Type: bool true if authentication is enabled; otherwise, false.

Remarks

When disabled, the MCP server will allow all requests without authentication. This is useful for development scenarios or internal deployments where authentication is handled at a different layer.

JwtBearer

Gets or sets the JWT bearer token options.

Syntax

public Microsoft.OData.Mcp.Authentication.Models.JwtBearerOptions JwtBearer { get; set; }

Property Value

Type: Microsoft.OData.Mcp.Authentication.Models.JwtBearerOptions Configuration for JWT token validation.

Remarks

These options control how JWT tokens are validated, including issuer validation, audience validation, and token lifetime checks.

MetadataCacheDuration

Gets or sets the cache duration for authentication metadata.

Syntax

public System.TimeSpan MetadataCacheDuration { get; set; }

Property Value

Type: System.TimeSpan The duration to cache authentication metadata like JWKS keys.

Remarks

Caching authentication metadata improves performance by avoiding repeated requests to authorization servers. The cache is automatically refreshed when metadata expires.

RequireHttps

Gets or sets a value indicating whether to require HTTPS for authentication.

Syntax

public bool RequireHttps { get; set; }

Property Value

Type: bool true if HTTPS is required for authentication; otherwise, false.

Remarks

When true, the server will reject authentication attempts over insecure connections. This should be enabled in production environments to protect authentication tokens.

Scheme

Gets or sets the authentication scheme to use.

Syntax

public string Scheme { get; set; }

Property Value

Type: string The authentication scheme name (e.g., “Bearer”, “JWT”).

Remarks

This determines which authentication handler will be used to validate incoming requests. The default is “Bearer” for JWT bearer token authentication.

ScopeAuthorization

Gets or sets the scope-based authorization options.

Syntax

public Microsoft.OData.Mcp.Authentication.Models.ScopeAuthorizationOptions ScopeAuthorization { get; set; }

Property Value

Type: Microsoft.OData.Mcp.Authentication.Models.ScopeAuthorizationOptions Configuration for OAuth2 scope-based access control.

Remarks

These options define which OAuth2 scopes are required for different MCP operations and how scope-based authorization is enforced.

Timeout

Gets or sets the timeout for authentication operations.

Syntax

public System.TimeSpan Timeout { get; set; }

Property Value

Type: System.TimeSpan The timeout duration for authentication operations.

Remarks

This timeout applies to operations like token validation, metadata discovery, and communication with authorization servers.

TokenDelegation

Gets or sets the token delegation options.

Syntax

public Microsoft.OData.Mcp.Authentication.Models.TokenDelegationOptions TokenDelegation { get; set; }

Property Value

Type: Microsoft.OData.Mcp.Authentication.Models.TokenDelegationOptions Configuration for token delegation to downstream services.

Remarks

These options control how tokens are forwarded to OData services and other downstream dependencies that require authentication.

Methods

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Override

Returns a string representation of the authentication options.

Syntax

public override string ToString()

Returns

Type: string A summary of the authentication configuration.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

Validate

Validates the authentication options for consistency and completeness.

Syntax

public System.Collections.Generic.IEnumerable<string> Validate()

Returns

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