PulseEngine MCP Macros
Procedural macros for the PulseEngine MCP Framework that dramatically simplify server and tool development.
Quick Start
Add to your Cargo.toml:
[]
# Core macros
= "0.7.1"
# Required dependencies for generated code
= "0.7.1"
= "0.7.1"
= "0.7.1"
= "0.1"
= "1.0"
= { = "1.0", = ["full"] }
# For STDIO transport (recommended)
= "0.1"
= "0.3"
Basic Server Example
use ;
;
async
Required Dependencies
Always Required
These dependencies are always required when using #[mcp_server]:
= "0.7.1"
= "0.7.1"
= "0.7.1"
= "0.1"
= "1.0"
= { = "1.0", = ["full"] }
Feature-Based Dependencies
STDIO Logging (stdio-logging feature)
For STDIO transport compatibility:
= { = "0.7.1", = ["stdio-logging"] }
= "0.3"
Authentication (auth feature + auth parameter)
Important: Authentication is opt-in. By default, servers have no authentication.
When using auth = "memory", auth = "file", etc.:
= { = "0.7.1", = ["auth"] }
= "0.7.1"
Macros
#[mcp_server]
Generates a complete MCP server from a struct:
;
Generated methods:
MyServer::with_defaults()- Create instanceMyServer::serve_stdio()- Start STDIO transportMyServer::serve_http(port)- Start HTTP transportMyServer::configure_stdio_logging()- Fix STDIO logging
#[mcp_tools]
Automatically discovers public methods as MCP tools:
Note: Currently passthrough - full implementation coming soon.
Transport Types
STDIO (Default)
For MCP clients like Claude Desktop:
// CRITICAL: Configure logging first!
configure_stdio_logging;
let server = with_defaults.serve_stdio.await?;
HTTP
For web-based clients:
let server = with_defaults.serve_http.await?;
WebSocket
For real-time clients:
let server = with_defaults.serve_websocket.await?;
Authentication
By default, servers have no authentication. To enable authentication, add the auth parameter:
// Memory-based (development)
// File-based (production)
// Explicitly disabled (same as default)
// No auth parameter = no authentication (default)
Requires: pulseengine-mcp-auth dependency and auth feature only when auth parameter is specified.
STDIO Transport Critical Note
⚠️ CRITICAL: For STDIO transport, you MUST configure logging to go to stderr, not stdout. Stdout is reserved for JSON-RPC messages only.
// Always call this before serve_stdio()
configure_stdio_logging;
Failure to do this will break MCP client compatibility with errors like:
Error from MCP server: SyntaxError: Unexpected token '2025-0"... is not valid JSON
Complete Example
See examples/hello-world-stdio-fixed/ for a working example with proper STDIO logging configuration.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.