Expand description
Core Model Context Protocol types and validation
This crate provides the fundamental types, traits, and validation logic for the Model Context Protocol. It serves as the foundation for building MCP servers and clients with strong type safety and validation.
§Quick Start
use pulseengine_mcp_protocol::{Tool, Content, CallToolResult};
use serde_json::json;
// Define a tool with proper schema and optional output schema
let tool = Tool {
name: "get_weather".to_string(),
description: "Get current weather for a location".to_string(),
input_schema: json!({
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name or coordinates"
}
},
"required": ["location"]
}),
output_schema: Some(json!({
"type": "object",
"properties": {
"temperature": {"type": "string"},
"condition": {"type": "string"}
}
})),
};
// Create a tool response with optional structured content
let result = CallToolResult {
content: vec![Content::text("Current weather: 22°C, sunny".to_string())],
is_error: Some(false),
structured_content: Some(json!({
"temperature": "22°C",
"condition": "sunny"
})),
};
This crate is currently used in production by the Loxone MCP Server for home automation with 30+ tools.
Re-exports§
pub use error::Error;
pub use error::ErrorCode;
pub use error::McpResult;
pub use error::Result;
pub use errors::CommonError;
pub use errors::CommonResult;
pub use validation::Validator;
pub use model::*;
Modules§
- error
- Error types for the MCP protocol
- errors
- Error harmonization and convenience utilities
- model
- MCP model types for protocol messages and data structures
- validation
- Validation utilities for MCP protocol types
Macros§
- mcp_
error - Macro for quick error creation
Constants§
- MCP_
VERSION - Protocol version constants
- SUPPORTED_
PROTOCOL_ VERSIONS
Functions§
- is_
protocol_ version_ supported - Check if a protocol version is supported
- validate_
protocol_ version - Validate MCP protocol version compatibility