Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Core.dll Namespace: Microsoft.OData.Mcp.Core.Configuration Inheritance: System.Object

Syntax

Microsoft.OData.Mcp.Core.Configuration.ODataServiceConfiguration

Summary

Configuration for connecting to and interacting with OData services.

Remarks

This configuration specifies how the MCP server discovers and communicates with the underlying OData service, including metadata endpoints, authentication, and operational parameters.

Constructors

.ctor

Initializes a new instance of the ODataServiceConfiguration class.

Syntax

public ODataServiceConfiguration()

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

Authentication

Gets or sets the authentication configuration for the OData service.

Syntax

public Microsoft.OData.Mcp.Core.Configuration.ODataAuthenticationConfiguration Authentication { get; set; }

Property Value

Type: Microsoft.OData.Mcp.Core.Configuration.ODataAuthenticationConfiguration Configuration for authenticating with the OData service.

Remarks

This configuration specifies how the MCP server authenticates with the underlying OData service when making requests on behalf of users.

AutoDiscoverMetadata

Gets or sets a value indicating whether to automatically discover metadata.

Syntax

public bool AutoDiscoverMetadata { get; set; }

Property Value

Type: bool true to automatically fetch and parse metadata; otherwise, false.

Remarks

When enabled, the MCP server will automatically fetch metadata from the configured endpoint and generate tools based on the discovered schema.

BaseUrl

Gets or sets the base URL of the OData service.

Syntax

public string BaseUrl { get; set; }

Property Value

Type: string? The root URL of the OData service.

Remarks

For sidecar deployments, this is the external URL of the OData service. For middleware deployments, this can be null to use the host application’s base URL.

CustomProperties

Gets or sets custom configuration properties.

Syntax

public System.Collections.Generic.Dictionary<string, object> CustomProperties { get; set; }

Property Value

Type: System.Collections.Generic.Dictionary<string, object> A dictionary of custom configuration values.

Remarks

Custom properties allow extending the configuration with service-specific settings that don’t fit into the standard configuration properties.

DefaultHeaders

Gets or sets the default headers to include in OData requests.

Syntax

public System.Collections.Generic.Dictionary<string, string> DefaultHeaders { get; set; }

Property Value

Type: System.Collections.Generic.Dictionary<string, string> A dictionary of header name-value pairs to include in all requests.

Remarks

These headers will be added to all HTTP requests made to the OData service and can be used for custom authentication, tracing, or service identification. Gets or sets a value indicating whether to follow next links in paged results.

Syntax

public bool FollowNextLinks { get; set; }

Property Value

Type: bool true to automatically follow next links; otherwise, false.

Remarks

When enabled, the MCP server will automatically follow OData next links to retrieve additional pages of results.

MaxPages

Gets or sets the maximum number of pages to follow.

Syntax

public int MaxPages { get; set; }

Property Value

Type: int The maximum number of result pages to retrieve.

Remarks

This setting prevents infinite loops when following next links and limits the total amount of data retrieved in a single operation.

MaxPageSize

Gets or sets the maximum page size for query results.

Syntax

public System.Nullable<int> MaxPageSize { get; set; }

Property Value

Type: System.Nullable<int> The maximum number of entities to return in a single query response.

Remarks

This setting helps prevent excessively large responses that could impact performance or memory usage. Set to null for no limit.

MaxRetryAttempts

Gets or sets the maximum number of retry attempts for failed requests.

Syntax

public int MaxRetryAttempts { get; set; }

Property Value

Type: int The number of retry attempts for failed HTTP requests.

Remarks

When requests to the OData service fail due to transient errors, the MCP server will retry up to this number of times.

MetadataPath

Gets or sets the path to the OData metadata endpoint.

Syntax

public string MetadataPath { get; set; }

Property Value

Type: string The relative path to the metadata endpoint (typically ”/$metadata”).

Remarks

This path is appended to the base URL to construct the full metadata endpoint URL. The metadata endpoint must return CSDL (Common Schema Definition Language) XML.

RefreshInterval

Gets or sets the interval for refreshing metadata.

Syntax

public System.TimeSpan RefreshInterval { get; set; }

Property Value

Type: System.TimeSpan The time interval between metadata refresh attempts.

Remarks

The MCP server will periodically refresh metadata to detect schema changes. Set to Zero to disable automatic refresh.

RequestTimeout

Gets or sets the timeout for HTTP requests to the OData service.

Syntax

public System.TimeSpan RequestTimeout { get; set; }

Property Value

Type: System.TimeSpan The maximum time to wait for HTTP responses.

Remarks

This timeout applies to all HTTP requests made to the OData service, including metadata discovery and data operations.

RetryDelay

Gets or sets the base delay for retry attempts.

Syntax

public System.TimeSpan RetryDelay { get; set; }

Property Value

Type: System.TimeSpan The initial delay before the first retry attempt.

Remarks

Subsequent retries will use exponential backoff based on this initial delay.

SupportedODataVersions

Gets or sets the supported OData versions.

Syntax

public System.Collections.Generic.List<string> SupportedODataVersions { get; set; }

Property Value

Type: System.Collections.Generic.List<string> A list of OData versions supported by the service.

Remarks

This information helps the MCP server understand which OData features are available and how to construct appropriate requests.

UseHostContext

Gets or sets a value indicating whether to use the host application context.

Syntax

public bool UseHostContext { get; set; }

Property Value

Type: bool true to use host context for middleware deployments; otherwise, false.

Remarks

When enabled in middleware deployments, the MCP server will use the host application’s HTTP context to make requests to the OData service.

ValidateSSL

Gets or sets a value indicating whether to validate SSL certificates.

Syntax

public bool ValidateSSL { get; set; }

Property Value

Type: bool true to validate SSL certificates; otherwise, false.

Remarks

For development environments, SSL validation can be disabled to work with self-signed certificates. This should always be enabled in production.

Methods

AddCustomProperty

Adds a custom property to the configuration.

Syntax

public void AddCustomProperty(string key, object value)

Parameters

NameTypeDescription
keystringThe property key.
valueobjectThe property value.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when key is null or whitespace.

AddDefaultHeader

Adds a default header to be included in all OData requests.

Syntax

public void AddDefaultHeader(string name, string value)

Parameters

NameTypeDescription
namestringThe header name.
valuestringThe header value.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when name is null or whitespace.

Clone

Creates a copy of this configuration.

Syntax

public Microsoft.OData.Mcp.Core.Configuration.ODataServiceConfiguration Clone()

Returns

Type: Microsoft.OData.Mcp.Core.Configuration.ODataServiceConfiguration A new instance with the same settings.

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

GetCustomProperty

Gets a custom property value.

Syntax

public T GetCustomProperty<T>(string key)

Parameters

NameTypeDescription
keystringThe property key.

Returns

Type: T? The property value if found and of the correct type; otherwise, the default value.

Type Parameters

  • T - The type of the property value.

GetEntitySetUrl

Gets the full URL for an OData entity set.

Syntax

public string GetEntitySetUrl(string entitySetName, string hostBaseUrl = null)

Parameters

NameTypeDescription
entitySetNamestringThe name of the entity set.
hostBaseUrlstring?The host base URL for middleware deployments.

Returns

Type: string The complete URL to the entity set.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when entitySetName is null or whitespace.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetMetadataUrl

Gets the full metadata URL for the OData service.

Syntax

public string GetMetadataUrl(string hostBaseUrl = null)

Parameters

NameTypeDescription
hostBaseUrlstring?The host base URL for middleware deployments.

Returns

Type: string The complete URL to the metadata endpoint.

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

MergeWith

Merges another configuration into this one, with the other configuration taking precedence.

Syntax

public void MergeWith(Microsoft.OData.Mcp.Core.Configuration.ODataServiceConfiguration other)

Parameters

NameTypeDescription
otherMicrosoft.OData.Mcp.Core.Configuration.ODataServiceConfigurationThe configuration to merge into this one.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when other is null.

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

RemoveDefaultHeader

Removes a default header.

Syntax

public bool RemoveDefaultHeader(string name)

Parameters

NameTypeDescription
namestringThe header name to remove.

Returns

Type: bool true if the header was removed; otherwise, false.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

Validate

Validates the OData service configuration.

Syntax

public System.Collections.Generic.IEnumerable<string> Validate(Microsoft.OData.Mcp.Core.Configuration.McpDeploymentMode deploymentMode)

Parameters

NameTypeDescription
deploymentModeMicrosoft.OData.Mcp.Core.Configuration.McpDeploymentModeThe deployment mode for context-specific validation.

Returns

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