mcp.servers

MCP Server Management Package.

This package provides comprehensive server management infrastructure for Model Context Protocol (MCP) servers with full Pydantic validation, type safety, and runtime monitoring. The package has been refactored to use a modern Pydantic-based architecture while maintaining complete backward compatibility with existing code.

Key Components

Server Management
  • MCPServerManager - Pydantic-enhanced server manager with validation and type safety

  • MCPServerConfig - Configuration management with Pydantic models

  • MCPServerModels - Data models for server state and operations

  • MCPCompatibilityManager - Backward compatibility layer

Server Types
  • HTTP Server: RESTful MCP server implementation

  • Dataflow Server: Integration with haive-dataflow processing

  • Simple Server: Lightweight server for basic operations

  • Non-Interactive Server: Batch processing server

Usage Examples

Basic Server Management

from haive.mcp.servers import MCPServerManager, MCPServerConfig

# Create server configuration
config = MCPServerConfig(
    name="filesystem_server",
    transport="stdio",
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem"]
)

# Initialize server manager
manager = MCPServerManager()
await manager.start_server(config)

# Monitor server health
status = await manager.get_server_status("filesystem_server")
print(f"Server status: {status}")

HTTP Server Setup

from haive.mcp.servers import HTTPMCPServer

# Create HTTP-based MCP server
server = HTTPMCPServer(
    host="localhost",
    port=8080,
    tools=["file_operations", "web_search"]
)

# Start server
await server.start()

Available Classes

Manager Classes

  • MCPServerManager - Primary server lifecycle management

  • MCPServerManagerV2 - Enhanced version with additional features

  • MCPServerManagerRefactored - Latest refactored implementation

Configuration

  • MCPServerConfig - Server configuration model

  • MCPServerModels - Data models for server operations

  • MCPCompatibilityManager - Compatibility management

Server Implementations

  • HTTPMCPServer - HTTP-based server

  • DataflowMCPServer - Dataflow integration server

  • SimpleMCPServer - Lightweight server

  • NonInteractiveMCPServer - Batch processing server

Note

This package uses modern Pydantic-based architecture for type safety and validation while maintaining full backward compatibility with existing server implementations.

Submodules

Attributes

Package Contents

mcp.servers.SSEServerTransport = None