Skip to main content

Definition

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

Syntax

Microsoft.OData.Mcp.Core.Routing.SpanRouteParser

Summary

High-performance route parser using ReadOnlySpan for zero-allocation parsing.

Remarks

This parser handles MCP routes in the format: //mcp/ where can be empty, and is optional.

Constructors

.ctor

Initializes a new instance of the SpanRouteParser struct.

Syntax

public SpanRouteParser(System.ReadOnlySpan<char> path)

Parameters

NameTypeDescription
pathSystem.ReadOnlySpan<char>The path to parse.

Methods

IsMcpRoute

Checks if the path is an MCP route without parsing details.

Syntax

public bool IsMcpRoute()

Returns

Type: bool True if this is an MCP route; otherwise, false.

TryGetMcpCommand

Gets the MCP command from the path.

Syntax

public bool TryGetMcpCommand(out Microsoft.OData.Mcp.Core.Routing.McpCommand command)

Parameters

NameTypeDescription
commandMicrosoft.OData.Mcp.Core.Routing.McpCommandThe MCP command.

Returns

Type: bool True if a command was found; otherwise, false.

TryGetODataRoute

Extracts just the OData route portion from an MCP path.

Syntax

public bool TryGetODataRoute(out System.ReadOnlySpan<char> odataRoute)

Parameters

NameTypeDescription
odataRouteSystem.ReadOnlySpan<char>The OData route prefix.

Returns

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

TryGetToolName

Extracts the tool name from a tool info request path.

Syntax

public bool TryGetToolName(out System.ReadOnlySpan<char> toolName)

Parameters

NameTypeDescription
toolNameSystem.ReadOnlySpan<char>The tool name.

Returns

Type: bool True if a tool name was found; otherwise, false.

TryParseMcpRoute

Attempts to parse an MCP route from the path.

Syntax

public bool TryParseMcpRoute(out System.ReadOnlySpan<char> odataRoute, out System.ReadOnlySpan<char> mcpCommand)

Parameters

NameTypeDescription
odataRouteSystem.ReadOnlySpan<char>The OData route prefix, if found.
mcpCommandSystem.ReadOnlySpan<char>The MCP command, if specified.

Returns

Type: bool True if this is an MCP route; otherwise, false.