Skip to main content

Definition

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

Syntax

Microsoft.OData.Mcp.Core.Server.ODataMcpTools

Summary

OData MCP tools using the official SDK attribute-based approach.

Remarks

This class provides MCP tools for interacting with OData services using the official Model Context Protocol C# SDK patterns with attributes.

Constructors

.ctor

Initializes a new instance of the ODataMcpTools class.

Syntax

public ODataMcpTools(System.Net.Http.IHttpClientFactory httpClientFactory, Microsoft.Extensions.Options.IOptions<Microsoft.OData.Mcp.Core.Configuration.McpServerConfiguration> configuration, Microsoft.Extensions.Logging.ILogger<Microsoft.OData.Mcp.Core.Server.ODataMcpTools> logger)

Parameters

NameTypeDescription
httpClientFactorySystem.Net.Http.IHttpClientFactoryThe HTTP client factory.
configurationMicrosoft.Extensions.Options.IOptions<Microsoft.OData.Mcp.Core.Configuration.McpServerConfiguration>The server configuration.
loggerMicrosoft.Extensions.Logging.ILogger<Microsoft.OData.Mcp.Core.Server.ODataMcpTools>The logger instance.

.ctor Inherited

Inherited from object

Syntax

public Object()

Methods

CreateEntity

Creates a new entity in the specified OData entity set.

Syntax

public System.Threading.Tasks.Task<string> CreateEntity(string entitySet, string entity)

Parameters

NameTypeDescription
entitySetstringThe name of the entity set.
entitystringThe entity data as JSON.

Returns

Type: System.Threading.Tasks.Task<string> The created entity as JSON.

DeleteEntity

Deletes an entity from the OData service.

Syntax

public System.Threading.Tasks.Task<string> DeleteEntity(string entitySet, string key)

Parameters

NameTypeDescription
entitySetstringThe entity set name.
keystringThe entity key.

Returns

Type: System.Threading.Tasks.Task<string> Success message.

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

GetEntity

Gets a single entity by its key from an OData service.

Syntax

public System.Threading.Tasks.Task<string> GetEntity(string entitySet, string key, string select = null)

Parameters

NameTypeDescription
entitySetstringThe name of the entity set.
keystringThe entity key value as a string or number.
selectstring?Optional comma-separated list of properties to select.

Returns

Type: System.Threading.Tasks.Task<string> The entity data as JSON.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetMetadata

Gets the OData service metadata document.

Syntax

public System.Threading.Tasks.Task<string> GetMetadata()

Returns

Type: System.Threading.Tasks.Task<string> The OData metadata as XML.

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 Navigates from a source entity to related entities via a navigation property.

Syntax

public System.Threading.Tasks.Task<string> NavigateRelationship(string entitySet, string key, string navigationProperty)

Parameters

NameTypeDescription
entitySetstringThe source entity set name.
keystringThe source entity key.
navigationPropertystringThe navigation property name.

Returns

Type: System.Threading.Tasks.Task<string> The related entities.

QueryEntitySet

Queries an OData entity set with optional filtering, sorting, and pagination.

Syntax

public System.Threading.Tasks.Task<string> QueryEntitySet(string entitySet, string filter = null, string orderby = null, string select = null, System.Nullable<int> top = null, System.Nullable<int> skip = null, bool count = false)

Parameters

NameTypeDescription
entitySetstringThe name of the entity set to query.
filterstring?Optional OData filter expression.
orderbystring?Optional OData orderby expression.
selectstring?Optional comma-separated list of properties to select.
topSystem.Nullable<int>?Optional maximum number of results to return.
skipSystem.Nullable<int>?Optional number of results to skip for pagination.
countboolOptional flag to include the total count of matching entities.

Returns

Type: System.Threading.Tasks.Task<string> The query results as JSON.

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

UpdateEntity

Updates an existing entity in the OData service.

Syntax

public System.Threading.Tasks.Task<string> UpdateEntity(string entitySet, string key, string entity)

Parameters

NameTypeDescription
entitySetstringThe entity set name.
keystringThe entity key.
entitystringThe updated entity data as JSON.

Returns

Type: System.Threading.Tasks.Task<string> The updated entity.