Skip to main content

Definition

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

Syntax

Microsoft.OData.Mcp.Core.Routing.McpRouteMatcher

Summary

Efficiently matches MCP routes to their corresponding OData endpoints.

Remarks

This matcher is optimized for startup-time registration and runtime lookups using frozen collections for maximum performance.

Constructors

.ctor

Initializes a new instance of the McpRouteMatcher class.

Syntax

public McpRouteMatcher(System.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Routing.McpRouteEntry> routes)

Parameters

NameTypeDescription
routesSystem.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Routing.McpRouteEntry>The routes to register.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when routes is null.

.ctor Inherited

Inherited from object

Syntax

public Object()

Methods

BuildMcpUrl

Builds the MCP URL for a given OData route.

Syntax

public string BuildMcpUrl(string odataPrefix, System.Nullable<Microsoft.OData.Mcp.Core.Routing.McpCommand> command = null)

Parameters

NameTypeDescription
odataPrefixstringThe OData route prefix.
commandSystem.Nullable<Microsoft.OData.Mcp.Core.Routing.McpCommand>The MCP command (optional).

Returns

Type: string? The MCP URL, or null if the route is not found.

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

GetAllRoutes

Gets all registered routes.

Syntax

public System.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Routing.McpRouteEntry> GetAllRoutes()

Returns

Type: System.Collections.Generic.IEnumerable<Microsoft.OData.Mcp.Core.Routing.McpRouteEntry> A collection of all registered route entries.

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 Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

TryGetRouteByODataPrefix

Gets a route entry by its OData prefix.

Syntax

public bool TryGetRouteByODataPrefix(string odataPrefix, out Microsoft.OData.Mcp.Core.Routing.McpRouteEntry route)

Parameters

NameTypeDescription
odataPrefixstringThe OData route prefix.
routeMicrosoft.OData.Mcp.Core.Routing.McpRouteEntry?The route entry if found.

Returns

Type: bool True if the route was found; otherwise, false.

TryMatch

Attempts to match a request path to an MCP route.

Syntax

public bool TryMatch(string path, out Microsoft.OData.Mcp.Core.Routing.McpRouteEntry route, out Microsoft.OData.Mcp.Core.Routing.McpCommand mcpCommand)

Parameters

NameTypeDescription
pathstringThe request path.
routeMicrosoft.OData.Mcp.Core.Routing.McpRouteEntry?The matched route entry.
mcpCommandMicrosoft.OData.Mcp.Core.Routing.McpCommandThe MCP command extracted from the path.

Returns

Type: bool True if a route was matched; otherwise, false.