Crates.io | pulseengine-mcp-transport |
lib.rs | pulseengine-mcp-transport |
version | 0.10.0 |
created_at | 2025-06-28 08:19:55.274034+00 |
updated_at | 2025-08-15 04:21:18.963755+00 |
description | Transport layer implementations for MCP servers (HTTP/SSE, WebSocket, stdio) - PulseEngine MCP Framework |
homepage | https://github.com/pulseengine/mcp |
repository | https://github.com/pulseengine/mcp |
max_upload_size | |
id | 1729635 |
size | 362,603 |
Transport layer implementations for MCP servers
This crate handles the network transport layer for MCP servers. It provides multiple transport options (stdio, HTTP, WebSocket) so your MCP server can work with different types of clients.
Different MCP clients need different ways to connect:
This crate handles all of these so you don't have to worry about transport details.
This transport layer has been thoroughly tested with:
The HTTP transport was specifically debugged and fixed to work with MCP Inspector's content negotiation requirements.
[dependencies]
pulseengine-mcp-transport = "0.2.0"
pulseengine-mcp-protocol = "0.2.0"
tokio = { version = "1.0", features = ["full"] }
use pulseengine_mcp_transport::{TransportConfig, create_transport};
use pulseengine_mcp_protocol::{Request, Response};
// Create HTTP transport on port 3001
let config = TransportConfig::Http { port: 3001 };
let mut transport = create_transport(config)?;
// Define your request handler
let handler = Box::new(|request: Request| {
Box::pin(async move {
// Process the MCP request and return response
Response::success(serde_json::json!({"result": "handled"}))
})
});
// Start the transport
transport.start(handler).await?;
use mcp_transport::TransportConfig;
// Simple stdio configuration
let config = TransportConfig::Stdio;
let mut transport = create_transport(config)?;
// ... same handler setup as above
use mcp_transport::TransportConfig;
// WebSocket on port 3001
let config = TransportConfig::WebSocket { port: 3001 };
let mut transport = create_transport(config)?;
// ... handler setup
Solid foundation with known limitations. The core transport functionality works well in production, but there are areas for improvement.
What works reliably:
Areas that need work:
The HTTP transport supports both traditional request/response and Server-Sent Events:
// Handles both:
// POST /mcp with Content-Type: application/json
// POST /mcp with Accept: text/event-stream
MCP Inspector compatibility: We specifically fixed content negotiation issues to work with MCP Inspector's mixed Accept headers (application/json, text/event-stream
).
Clean integration with Claude Desktop and other stdio-based MCP clients:
// Reads JSON-RPC from stdin, writes responses to stdout
// Handles proper buffering and line-based communication
Real-time bidirectional communication:
// Full-duplex communication over WebSocket
// Supports both text and binary frames
// Handles connection lifecycle properly
This crate integrates cleanly with other framework components:
use mcp_server::{McpServer, ServerConfig};
use mcp_transport::TransportConfig;
let config = ServerConfig {
transport_config: TransportConfig::Http { port: 3001 },
// ... other config
};
// The server handles transport setup automatically
let server = McpServer::new(backend, config).await?;
The crate includes several working examples:
Run an example:
cargo run --example test_http_sse
If you're having connectivity issues:
RUST_LOG=debug cargo run --example test_mcp_inspector
Transport layer improvements often come from real-world integration issues. The most helpful contributions:
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.