Logo de HAProxy MCP Server

HAProxy MCP Server

Comunidade
tuannvm

A Model Context Protocol (MCP) server for HAProxy implemented in Go, leveraging HAProxy Runtime API and mcp-go.

Publicado portuannvm
Repositóriohaproxy-mcp-server
IdiomaGo
Forks
1
Estrelas
7
Ferramentas disponíveis
0
Tipo de transportestdio
Categorias
Links
  • Conecte ferramentas a fluxos de trabalho de IA

    HAProxy MCP Server disponibiliza recursos MCP que podem ser usados por clientes e agentes de IA compatíveis.

  • 0 ferramentas disponíveis

    Confira abaixo as ações que podem ser chamadas, incluindo nomes e descrições quando fornecidos pelo servidor.

  • Configuração pronta para copiar

    Use os exemplos de instalação para configurar este servidor no seu cliente MCP preferido.

  • Indicadores da comunidade de código aberto

    7 estrelas e 1 forks no repositório vinculado.

HAProxy MCP Server

Build Release Go Report Card GitHub release (latest SemVer) License Docker Pulls

A Model Context Protocol (MCP) server for HAProxy implemented in Go, leveraging HAProxy Runtime API and mcp-go.

Overview

The HAProxy MCP Server provides a standardized way for LLMs to interact with HAProxy's runtime API via the Model Context Protocol (MCP). This enables LLMs to perform HAProxy administration tasks, monitor server status, manage backend servers, and analyze traffic patterns, all through natural language interfaces.

Screenshot-1 Screenshot-2 Screenshot-3

Features

  • Full HAProxy Runtime API Support: Comprehensive coverage of HAProxy's runtime API commands
  • Context-Aware Operations: All operations support proper timeout and cancellation handling
  • Stats Page Integration: Support for HAProxy's web-based statistics page for enhanced metrics and visualization
  • Secure Authentication: Support for secure connections to HAProxy runtime API
  • Multiple Transport Options: Supports both stdio and HTTP transports for flexibility in different environments
  • Enterprise Ready: Designed for production use in enterprise environments
  • Docker Support: Pre-built Docker images for easy deployment

Installation

Homebrew

bash
# Add the tap
brew tap tuannvm/tap

# Install the package
brew install haproxy-mcp-server

From Binary

Download the latest binary for your platform from the releases page.

Using Go

bash
go install github.com/tuannvm/haproxy-mcp-server/cmd/server@latest

Using Docker

bash
docker pull ghcr.io/tuannvm/haproxy-mcp-server:latest
docker run -it --rm \
  -e HAPROXY_HOST=your-haproxy-host \
  -e HAPROXY_PORT=9999 \
  ghcr.io/tuannvm/haproxy-mcp-server:latest

MCP Integration

To use this server with MCP-compatible LLMs, configure the assistant with the following connection details:

HAProxy Runtime API over TCP4:

json
{
  "mcpServers": {
    "haproxy": {
      "command": "haproxy-mcp-server",
      "env": {
        "HAPROXY_HOST": "localhost",
        "HAPROXY_PORT": "9999",
        "HAPROXY_RUNTIME_MODE": "tcp4",
        "HAPROXY_RUNTIME_TIMEOUT": "10",
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

HAProxy Runtime API over Unix Socket:

json
{
  "mcpServers": {
    "haproxy": {
      "command": "haproxy-mcp-server",
      "env": {
        "HAPROXY_RUNTIME_MODE": "unix",
        "HAPROXY_RUNTIME_SOCKET": "/var/run/haproxy/admin.sock",
        "HAPROXY_RUNTIME_TIMEOUT": "10",
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

HAProxy with Stats Page Support:

json
{
  "mcpServers": {
    "haproxy": {
      "command": "haproxy-mcp-server",
      "env": {
        "HAPROXY_STATS_ENABLED": "true",
        "HAPROXY_STATS_URL": "http://localhost:8404/stats",
        "HAPROXY_STATS_TIMEOUT": "5",
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

When using only the stats page functionality, there's no need to define Runtime API parameters like host and port. You can use both Runtime API and Stats Page simultaneously for complementary capabilities, or use only one of them based on your environment's constraints.

Note: For detailed instructions on how to configure HAProxy to expose the Runtime API and Statistics page, see the HAProxy Configuration Guide.

Available MCP Tools

The HAProxy MCP Server exposes tools that map directly to HAProxy's Runtime API commands, organized into the following categories:

  • Statistics & Process Info: Retrieve statistics, server information, and manage counters
  • Topology Discovery: List frontends, backends, server states, and configuration details
  • Dynamic Pool Management: Add, remove, enable/disable servers and adjust their properties
  • Session Control: View and manage active sessions
  • Maps & ACLs: Manage HAProxy maps and ACL files
  • Health Checks & Agents: Control health checks and agent-based monitoring
  • Miscellaneous: View errors, run echo tests, and get help information

For a complete list of all supported tools with their inputs, outputs, and corresponding HAProxy Runtime API commands, see the tools.md documentation.

Configuration

The server can be configured using the following environment variables:

VariableDescriptionDefault
HAPROXY_HOSTHost of the HAProxy instance (TCP4 mode only)127.0.0.1
HAPROXY_PORTPort for the HAProxy Runtime API (TCP4 mode only)9999
HAPROXY_RUNTIME_MODEConnection mode: "tcp4" or "unix"tcp4
HAPROXY_RUNTIME_SOCKETSocket path (Unix mode only)/var/run/haproxy/admin.sock
HAPROXY_RUNTIME_URLDirect URL to Runtime API (optional, overrides other runtime settings)
HAPROXY_RUNTIME_TIMEOUTTimeout for runtime API operations in seconds10
HAPROXY_STATS_ENABLEDEnable HAProxy stats page supporttrue
HAPROXY_STATS_URLURL to HAProxy stats page (e.g., http://localhost:8404/stats)http://127.0.0.1:8404/stats
HAPROXY_STATS_TIMEOUTTimeout for stats page operations in seconds5
MCP_TRANSPORTMCP transport method (stdio/http)stdio
MCP_PORTPort for HTTP transport (when using http)8080
LOG_LEVELLogging level (debug/info/warn/error)info

Note: You can use the Runtime API (TCP4 or Unix socket mode), the Stats API, or both simultaneously. At least one must be properly configured for the server to function.

Security Considerations

  • Authentication: Connect to HAProxy's Runtime API using secure methods
  • Network Security: When using TCP4 mode, restrict connectivity to the Runtime API port
  • Unix Socket Permissions: When using Unix socket mode, ensure proper socket file permissions
  • Input Validation: All inputs are validated to prevent injection attacks

For comprehensive security best practices and configuration examples, see the HAProxy Configuration Guide.

Development

Testing

bash
# Run all tests
go test ./...

# Run tests excluding integration tests
go test -short ./...

# Run integration tests with specific HAProxy instance
export HAPROXY_HOST="your-haproxy-host"
export HAPROXY_PORT="9999"
go test ./internal/haproxy -v -run Test

You can test the HAProxy MCP server locally in several ways:

Direct CLI Testing

Build and run the server directly with environment variables:

bash
# Build the server
go build -o bin/haproxy-mcp-server cmd/server/main.go

# Option 1: Test with TCP connection mode
HAPROXY_HOST=<your-haproxy-host> HAPROXY_PORT=9999 HAPROXY_RUNTIME_MODE=tcp4 HAPROXY_RUNTIME_TIMEOUT=10 LOG_LEVEL=debug MCP_TRANSPORT=stdio ./bin/haproxy-mcp-server

# Option 2: Test with Unix socket mode
HAPROXY_RUNTIME_MODE=unix HAPROXY_RUNTIME_SOCKET=/path/to/haproxy.sock HAPROXY_RUNTIME_TIMEOUT=10 LOG_LEVEL=debug MCP_TRANSPORT=stdio ./bin/haproxy-mcp-server

# Option 3: Test with Stats page integration
HAPROXY_STATS_ENABLED=true HAPROXY_STATS_URL="http://localhost:8404/stats" HAPROXY_STATS_TIMEOUT=5 LOG_LEVEL=debug MCP_TRANSPORT=stdio ./bin/haproxy-mcp-server

# Option 4: Test with both Runtime API and Stats page
HAPROXY_HOST=<your-haproxy-host> HAPROXY_PORT=9999 HAPROXY_RUNTIME_MODE=tcp4 HAPROXY_RUNTIME_TIMEOUT=10 HAPROXY_STATS_ENABLED=true HAPROXY_STATS_URL="http://localhost:8404/stats" HAPROXY_STATS_TIMEOUT=5 LOG_LEVEL=debug MCP_TRANSPORT=stdio ./bin/haproxy-mcp-server

Test Individual MCP Tools

You can test specific MCP tools with JSON-RPC calls:

bash
# Test show_info tool
echo '{"jsonrpc":"2.0","id":1,"method":"callTool","params":{"name":"show_info","arguments":{}}}' | HAPROXY_HOST=<your-haproxy-host> HAPROXY_PORT=9999 HAPROXY_RUNTIME_MODE=tcp4 LOG_LEVEL=debug ./bin/haproxy-mcp-server

# Test show_stat tool
echo '{"jsonrpc":"2.0","id":2,"method":"callTool","params":{"name":"show_stat","arguments":{"filter":""}}}' | HAPROXY_HOST=<your-haproxy-host> HAPROXY_PORT=9999 HAPROXY_RUNTIME_MODE=tcp4 LOG_LEVEL=debug ./bin/haproxy-mcp-server

Technical Implementation

The HAProxy MCP Server includes several technical improvements designed for reliability and robustness:

  • Context-Aware Operations: All API calls support context-based timeout and cancellation, allowing graceful termination of long-running operations.
  • Fallback Mechanisms: Automatic fallback to socat if direct connection fails, ensuring compatibility across different HAProxy deployments.
  • Unified Socket Handling: Common code for both TCP and Unix socket connections, reducing duplication and improving maintainability.
  • Resilient Connection Management: Dynamic buffer management for large responses and proper resource cleanup with deadline handling.
  • Comprehensive Error Handling: Structured error handling and logging for easier troubleshooting.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Instalação

TypingMind
Pré-requisitos:

Node.js 18+

{
  "mcpServers": {
    "tuannvm-haproxy-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "haproxy-mcp-server"
      ]
    }
  }
}

Use o MCP de HAProxy MCP Server com vários modelos de IA

O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho. Assim, após conectar HAProxy MCP Server, é possível usá-lo com diferentes modelos de IA no TypingMind, em vez de configurá-lo separadamente para cada modelo. Este MCP é executado localmente no seu dispositivo por meio do conector MCP do TypingMind.

Guia de configuração para usar o conector local

Use esta opção quando o servidor MCP precisar acessar arquivos locais, aplicativos ou recursos privados no seu computador.

1

Abra as configurações de MCP

No TypingMind, vá até Configurações, Configurações avançadas e depois Model Context Protocol e selecione Configurar conector.

  1. Abra o TypingMind no navegador.
  2. Clique no ícone de Ajustes.
  3. Acesse Configurações avançadas.
  4. Abra a seção Model Context Protocol.
  5. Clique em Configurar conector e selecione Este dispositivo.
Tela de configuração do conector MCP do TypingMind com a opção Este dispositivo selecionada
2

Execute o comando do conector

Selecione Este dispositivo, copie o comando do TypingMind e execute-o no Terminal. Mantenha o processo em execução enquanto usa o MCP.

  1. Copie o comando de configuração exibido pelo TypingMind.
  2. Abra o Terminal no macOS ou o Windows Terminal no Windows.
  3. Cole e execute o comando.
  4. Autorize a instalação do pacote se o Terminal pedir confirmação para continuar.
  5. Mantenha o processo em execução na janela do Terminal enquanto usa as ferramentas MCP.
3

Adicione HAProxy MCP Server como servidor

Quando o status do conector for Pronto, clique em Editar e cole a configuração do servidor MCP.

  1. Aguarde até que o status do conector mostre Pronto.
  2. Clique em Editar.
  3. Cole a configuração do servidor MCP de HAProxy MCP Server.
  4. Salve a lista de servidores.
  5. Atualize para confirmar se o conector ainda está pronto para uso.
Configurações de MCP do TypingMind mostrando um servidor ativo e o botão Editar
{
  "mcpServers": {
    "tuannvm-haproxy-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "haproxy-mcp-server"
      ]
    }
  }
}
4

Use a conexão com diferentes modelos

Salve a lista de servidores, abra Plugins, ative as ferramentas MCP de HAProxy MCP Server, selecione qualquer modelo de IA compatível no TypingMind e use as ferramentas no chat ou atribua-as a um agente de IA.

  1. Abra a página Plugins no TypingMind.
  2. Ative as ferramentas MCP de HAProxy MCP Server.
  3. Inicie um chat e escolha o modelo de IA que deseja usar.
  4. Use as ferramentas MCP no chat ou atribua-as a um agente de IA.
  5. Mude para outro modelo de IA sempre que necessário, sem reconectar o MCP.
Chat do TypingMind usando ferramentas MCP ativadas com um modelo de IA selecionado
Pode usar HAProxy MCP Server para me ajudar nesta tarefa?
HAProxy MCP Server
Claro. Já li.
Veja o que encontrei usando HAProxy MCP Server.

Perguntas frequentes

Para que serve o servidor MCP HAProxy MCP Server?

HAProxy MCP Server é um servidor MCP que permite que aplicativos de IA compatíveis se conectem a ferramentas externas e informações de contexto. No TypingMind, basta adicionar esse servidor MCP uma vez para disponibilizar suas ferramentas no seu espaço de trabalho com IA.

Posso usar o MCP HAProxy MCP Server com vários modelos de IA no TypingMind?

Sim. O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho, permitindo usar HAProxy MCP Server com diferentes modelos de IA, como Claude, ChatGPT, Gemini ou outros modelos configurados no TypingMind, sem configurar o servidor MCP separadamente para cada modelo.

Por que usar o MCP HAProxy MCP Server com o TypingMind?

O TypingMind é uma das melhores interfaces de chat com LLMs porque reúne vários modelos de IA, prompts, plugins, agentes de IA, chaves de API e ferramentas MCP em um só espaço de trabalho. Com HAProxy MCP Server conectado, é possível usar suas ferramentas MCP nos seus modelos preferidos e manter seu fluxo de trabalho de chat organizado no TypingMind.

Como conecto o MCP HAProxy MCP Server ao TypingMind?

HAProxy MCP Server funciona por meio do conector MCP local do TypingMind. Essa é a melhor opção quando o servidor MCP precisa acessar arquivos locais, apps de desktop, ferramentas de linha de comando ou recursos privados no seu computador.

Quais ferramentas o MCP HAProxy MCP Server oferece no TypingMind?

HAProxy MCP Server disponibiliza recursos MCP que podem ser ativados na página Plugins do TypingMind e usados no chat ou atribuídos a agentes de IA.

Preciso compartilhar minhas chaves de API com o TypingMind para usar o MCP HAProxy MCP Server?

Não. O TypingMind prioriza o uso local e permite manter seus provedores de modelos, chaves de API, prompts e configuração MCP sob seu controle. Se HAProxy MCP Server exigir autenticação, adicione os cabeçalhos, as configurações OAuth ou a configuração local exigidos por esse servidor MCP ao criar a conexão.

Servidores MCP relacionados

Ver todos

Crie seu próprio espaço de IA agora

Inscreva-se na nossa newsletter para receber novidades sobre recursos e futuros sorteios 👇