Crates.io | pulseengine-mcp-protocol |
lib.rs | pulseengine-mcp-protocol |
version | 0.10.0 |
created_at | 2025-06-28 08:18:11.174061+00 |
updated_at | 2025-08-15 04:19:33.313263+00 |
description | Core Model Context Protocol types and validation - PulseEngine MCP Framework |
homepage | https://github.com/pulseengine/mcp |
repository | https://github.com/pulseengine/mcp |
max_upload_size | |
id | 1729633 |
size | 180,168 |
Core types and validation for the Model Context Protocol in Rust
This crate provides the fundamental types and validation logic for building MCP (Model Context Protocol) servers and clients in Rust. It's been developed as part of a working Loxone home automation MCP server and handles the protocol details so you can focus on your application logic.
use pulseengine_mcp_protocol::{Tool, Content, CallToolResult};
use serde_json::json;
// Define a tool with proper 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"]
}),
};
// Create a tool response
let result = CallToolResult {
content: vec![Content::text("Current weather: 22°C, sunny".to_string())],
is_error: Some(false),
};
This crate is currently used in production by:
Stable core functionality - The basic protocol types and validation work well. We've tested this with real MCP clients and it handles the protocol correctly.
What works:
What's still developing:
Add this to your Cargo.toml
:
[dependencies]
pulseengine-mcp-protocol = "0.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
use pulseengine_mcp_protocol::Tool;
use serde_json::json;
let tool = Tool {
name: "calculate".to_string(),
description: "Perform basic calculations".to_string(),
input_schema: json!({
"type": "object",
"properties": {
"expression": {
"type": "string",
"description": "Mathematical expression to evaluate"
}
},
"required": ["expression"]
}),
};
use pulseengine_mcp_protocol::{CallToolRequestParam, CallToolResult, Content};
// Parse a tool call request
let request = CallToolRequestParam {
name: "calculate".to_string(),
arguments: Some(json!({"expression": "2 + 2"})),
};
// Create a response
let response = CallToolResult {
content: vec![Content::text("4".to_string())],
is_error: Some(false),
};
use pulseengine_mcp_protocol::Error;
// Create standard MCP errors
let error = Error::invalid_params("Missing required parameter: location");
let internal_error = Error::internal_error("Database connection failed");
This crate works well with other parts of the MCP framework:
This crate is part of the larger MCP framework for Rust. The Loxone MCP server serves as our main testing ground for new features and improvements.
If you find issues or have suggestions:
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Repository: https://github.com/avrabe/mcp-loxone
Note: This crate is part of a larger MCP framework that will be published as a separate repository.