Files
engine/docs/MCP/transports.md
zeekay cc24390182 chore: complete brand cleanup — remove upstream references
Replace all upstream project references (EricLBuehler/mistral.rs) with
hanzoai/engine across 99 files. Changes are metadata, docs, and branding
only — no code changes.

- Cargo.toml: homepage/repository URLs -> github.com/hanzoai/engine
- Cargo.toml: add Hanzo AI as primary author, keep original for attribution
- Dockerfiles: WORKDIR /mistralrs -> /engine
- docs/book.toml: title, authors, URLs updated
- docs/*.md: all GitHub links repointed, product name -> Hanzo Engine
- crate README.md files: rebranded to Hanzo Engine
- hanzo-engine-dso/Cargo.toml: candle deps -> hanzo-ml workspace paths
- .github/workflows/release.yml: remove upstream reference in changelog
- Remove broken upstream GitHub asset link from ANYMOE.md
- Replace ericlbuehler.github.io docs URLs with docs.hanzo.ai
- Replace upstream Docker image refs with ghcr.io/hanzoai/engine
- Replace raw.githubusercontent.com URLs with hanzoai/engine/main
- Replace master branch refs with main in docs links

Preserved:
- LICENSE file (legally required original copyright)
- Cargo crate names (mistralrs-*) — renaming would break builds
- Rust/Python module names in code examples
- Environment variable names (MISTRALRS_*) from source code
- pyproject.toml package name (tied to pyo3 module name)
2026-02-26 10:01:17 -08:00

3.7 KiB

MCP Transport Types

Hanzo Engine supports three transport types for connecting to MCP servers, each optimized for different use cases.

HTTP Transport

Best for public APIs, RESTful services, and servers behind load balancers.

Configuration

{
  "source": {
    "type": "Http",
    "url": "https://api.example.com/mcp",
    "timeout_secs": 30,
    "headers": {
      "X-API-Version": "v1",
      "User-Agent": "hanzo-engine/0.7.0"
    }
  },
  "bearer_token": "your-api-token"
}

Features

  • Server-Sent Events (SSE) support for streaming responses
  • Custom headers for API versioning or client identification
  • Bearer token authentication (added as Authorization: Bearer <token>)
  • Configurable timeouts
  • Standard HTTP semantics

Example: Hugging Face MCP

McpServerSource::Http {
    url: "https://hf.co/mcp".to_string(),
    timeout_secs: Some(30),
    headers: None,
}

WebSocket Transport

Best for real-time applications, bidirectional communication, and low-latency requirements.

Configuration

{
  "source": {
    "type": "WebSocket",
    "url": "wss://realtime.example.com/mcp",
    "timeout_secs": 60,
    "headers": {
      "Origin": "https://engine.hanzo.ai",
      "Sec-WebSocket-Protocol": "mcp"
    }
  },
  "bearer_token": "your-websocket-token"
}

Features

  • Persistent connections reduce handshake overhead
  • Server-initiated notifications
  • Lower latency for frequent tool calls
  • Automatic reconnection handling
  • WebSocket-specific headers support

Example: Real-time Data Feed

McpServerSource::WebSocket {
    url: "wss://data.example.com/mcp".to_string(),
    timeout_secs: Some(60),
    headers: Some(headers),
}

Process Transport

Best for local tools, development servers, and sandboxed environments.

Configuration

{
  "source": {
    "type": "Process",
    "command": "mcp-server-filesystem",
    "args": ["--root", "/tmp", "--readonly"],
    "work_dir": "/home/user/workspace",
    "env": {
      "MCP_LOG_LEVEL": "info",
      "MCP_TIMEOUT": "30"
    }
  }
}

Features

  • No network overhead
  • Process isolation for security
  • Direct stdin/stdout communication
  • Environment variable configuration
  • Working directory control
  • No authentication needed (process inherits permissions)

Example: Filesystem Server

McpServerSource::Process {
    command: "mcp-server-filesystem".to_string(),
    args: vec!["--root".to_string(), "/tmp".to_string()],
    work_dir: None,
    env: None,
}

Transport Selection Guide

Use Case Recommended Transport Why
Public APIs HTTP Standard auth, caching, load balancing
Local tools Process No network, process isolation
Real-time data WebSocket Low latency, server push
Corporate proxies HTTP Proxy support, standard ports
Development Process Easy debugging, no network setup
Interactive apps WebSocket Bidirectional, persistent connection

Security Considerations

HTTP

  • Always use HTTPS in production
  • Bearer tokens transmitted with each request
  • Consider token rotation strategies

WebSocket

  • Use WSS (WebSocket Secure) in production
  • Bearer token sent during handshake
  • Connection persists with authenticated state

Process

  • Inherits user permissions
  • Sandboxing via work_dir and env
  • No network exposure

Performance Tips

  1. HTTP: Enable keep-alive, use connection pooling
  2. WebSocket: Reuse connections, handle reconnection gracefully
  3. Process: Minimize startup time, use long-running processes

Error Handling

All transports implement automatic retry with exponential backoff:

  • Initial retry: 1 second
  • Max retry: 60 seconds
  • Max attempts: 5

Custom retry behavior can be configured per server.