🔧 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 useserde_json::to_string()instead offormat!("{:?}") - ✅ Now populates
structured_contentfield 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.rswith 8 comprehensive tests- Structured types (nested structs, vectors)
Result<T, E>return types- Simple types (string, number, bool, vector)
- Verification of
structured_contentfield 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_contentfield 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 typespulseengine-mcp-logging- Logging infrastructurepulseengine-mcp-auth- Authentication/authorizationpulseengine-mcp-security- Security middlewarepulseengine-mcp-security-middleware- Security middleware layerpulseengine-mcp-monitoring- Metrics collectionpulseengine-mcp-transport- Transport layers (stdio/HTTP/WebSocket)pulseengine-mcp-cli- CLI frameworkpulseengine-mcp-cli-derive- CLI derive macrospulseengine-mcp-server- Server orchestrationpulseengine-mcp-macros- Procedural macrospulseengine-mcp-external-validation- External validation tools
🔗 Links
- Issue Fixed: #62
- Pull Request: #63
- Full Changelog: CHANGELOG.md
📚 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