agentic_memory_mcp/protocol/
validator.rs1use crate::types::{JsonRpcRequest, McpError, McpResult, JSONRPC_VERSION};
4
5pub fn validate_request(request: &JsonRpcRequest) -> McpResult<()> {
7 if request.jsonrpc != JSONRPC_VERSION {
8 return Err(McpError::InvalidRequest(format!(
9 "Expected jsonrpc version \"{JSONRPC_VERSION}\", got \"{}\"",
10 request.jsonrpc
11 )));
12 }
13
14 if request.method.is_empty() {
15 return Err(McpError::InvalidRequest(
16 "Method name must not be empty".to_string(),
17 ));
18 }
19
20 Ok(())
21}