Skip to content

v0.13.0 - JSON Serialization Fix

Latest

Choose a tag to compare

@avrabe avrabe released this 11 Oct 12:02

🔧 Breaking Changes

Fixed: mcp_tools macro now uses JSON serialization (#62)

The #[mcp_tools] macro previously used Rust's Debug format ({:?}) instead of JSON serialization, causing tool responses to contain Rust debug format instead of proper JSON. This has been fixed.

Before:

{
  "content": [{
    "type": "text",
    "text": "SearchResult { items: [...] }"
  }]
}

After:

{
  "content": [{
    "type": "text",
    "text": "{\"items\":[...]}"
  }],
  "structured_content": {"items": [...]}
}

📦 Migration Required

Tool return types should implement Serialize trait for optimal JSON output:

#[derive(Debug, Serialize)]  // Add Serialize
struct MyResult {
    data: Vec<String>,
}

#[mcp_tools]
impl MyServer {
    pub fn my_tool(&self) -> MyResult {
        MyResult { data: vec!["item1".to_string()] }
    }
}

Types without Serialize will gracefully fall back to Debug format.


✨ What's Changed

mcp-macros

  • ✅ Modified generate_error_handling() to use serde_json::to_string() instead of format!("{:?}")
  • ✅ Now populates structured_content field per MCP 2025-06-18 specification
  • ✅ Graceful fallback to Debug format for types without Serialize trait
  • ✅ Added comprehensive test suite (8 tests) covering all scenarios

Testing

  • New: json_serialization_test.rs with 8 comprehensive tests
    • Structured types (nested structs, vectors)
    • Result<T, E> return types
    • Simple types (string, number, bool, vector)
    • Verification of structured_content field population
    • Verification that Debug format markers are absent

📋 MCP Specification Compliance

This release ensures full compliance with MCP 2025-06-18 specification:

  • ✅ Tool responses use proper JSON serialization
  • structured_content field is populated for structured types
  • ✅ Both text content and structured_content contain equivalent data

📦 Published Crates (v0.13.0)

All workspace crates updated to v0.13.0:

  • pulseengine-mcp-protocol - Core MCP protocol types
  • pulseengine-mcp-logging - Logging infrastructure
  • pulseengine-mcp-auth - Authentication/authorization
  • pulseengine-mcp-security - Security middleware
  • pulseengine-mcp-security-middleware - Security middleware layer
  • pulseengine-mcp-monitoring - Metrics collection
  • pulseengine-mcp-transport - Transport layers (stdio/HTTP/WebSocket)
  • pulseengine-mcp-cli - CLI framework
  • pulseengine-mcp-cli-derive - CLI derive macros
  • pulseengine-mcp-server - Server orchestration
  • pulseengine-mcp-macros - Procedural macros
  • pulseengine-mcp-external-validation - External validation tools

🔗 Links


📚 Documentation

See CHANGELOG.md for detailed migration guide and full release notes.

Validation Results

✅ All validation tests passed
✅ Python SDK compatibility verified
✅ JSON-RPC 2.0 compliant
✅ MCP protocol compliant