MCPEx.Protocol.Schemas (MCPEx v0.1.0)
JSON Schema validation for MCP protocol messages.
This module provides validation of incoming and outgoing messages against the MCP protocol specification schemas.
Summary
Functions
Detects the message type based on its structure.
Gets the resolved JSON schema for MCP protocol validation.
Validates a message against a specific schema definition.
Validates an initialize request message.
Validates an initialize response message.
Validates a message by detecting its type and then validating against the appropriate schema.
Functions
Detects the message type based on its structure.
Parameters
message
- The message to analyze
Returns
{:ok, type}
- Successfully detected the message type{:error, reason}
- Unable to determine the message type
Gets the resolved JSON schema for MCP protocol validation.
Returns
{:ok, map()}
- The resolved schema{:error, reason}
- Failed to get the schema
Validates a message against a specific schema definition.
Parameters
message
- The message to validateschema_type
- The name of the schema type (e.g., "InitializeRequest")
Returns
:ok
- The message is valid{:error, reason}
- The message is invalid
Validates an initialize request message.
Parameters
message
- The initialize request message to validate
Returns
:ok
- The message is valid{:error, reason}
- The message is invalid
Validates an initialize response message.
Parameters
message
- The initialize response message to validate
Returns
:ok
- The message is valid{:error, reason}
- The message is invalid
Validates a message by detecting its type and then validating against the appropriate schema.
Parameters
message
- The message to validate
Returns
:ok
- The message is valid{:error, reason}
- The message is invalid