MCP Server: PostgreSQL Ops for Ambari Integration
Manage Hadoop clusters with the MCP server for Ambari: perform PostgreSQL-backed service ops, config management, status monitoring, and request tracking.
npx -y @call518/MCP-PostgreSQL-OpsOverview
The MCP (Model Context Protocol) server for Ambari provides a lightweight HTTP API to manage Hadoop clusters using Ambari while persisting operation state and metadata in PostgreSQL. It acts as an intermediary between orchestration systems and Ambari, recording service operations, configuration changes, and status updates in a durable store so you can audit, retry, and analyze cluster activity.
This approach is useful when you need reliable, observable control of Ambari-driven operations: long-running requests can survive restarts, failed actions can be retried from stored context, and downstream systems (analytics, dashboards, alerting) can query a single PostgreSQL-backed source of truth instead of polling Ambari directly.
Features
- PostgreSQL-backed persistence for all Ambari service operations and requests
- API for submitting, tracking, and querying service operations (start/stop/restart, config changes)
- Configuration management with versioned change records and diff capability
- Status monitoring endpoints to aggregate Ambari service health and node state
- Request/state tracking with timestamps, statuses, and retry metadata
- Lightweight HTTP interface suitable for orchestration integrations and automation
Installation / Configuration
You can run MCP server locally or in Docker. Below are common setup steps — adapt environment variables to your environment.
Clone the repository:
Option A — Docker (recommended for quick start)
# Build image
# Run (example)
Option B — Local (Python environment)
# Configure environment
# Initialize DB (if migrations provided)
# Start server
Common environment variables (examples)
- DATABASE_URL — PostgreSQL connection URL
- AMBARI_URL — Ambari API base URL
- AMBARI_USER / AMBARI_PASS — Ambari credentials or API key
- SERVER_PORT — HTTP server port (default 8080)
Available Resources
API endpoints (examples)
- POST /ops — Submit a new operation (start/stop/config-update)
- GET /ops/:id — Get operation details and history
- GET /services/:name/status — Retrieve aggregated status for a service
- GET /requests — List recent requests with filters (status, service, time range)
- POST /ops/:id/retry — Retry a failed operation
Example: submit a restart operation
Data model (core tables)
| Table | Purpose |
|---|---|
| operations | Records each requested Ambari operation with status, start/end timestamps |
| requests | High-level user/submission records mapping to one or more operations |
| configs | Stored cluster configuration change records and metadata |
| statuses | Aggregated service/node status snapshots |
| retries | Retry metadata and counts for failed operations |
Logs and metrics
- Stores operation events to PostgreSQL for auditability
- Exposes basic endpoints suitable for Prometheus scraping (if enabled)
- Integrates with Ambari audit/logs to correlate system events
Use Cases
- Auditable rolling restart
- Submit a rolling restart for HDFS via POST /ops. Each host restart is tracked as an operation row in PostgreSQL. If the MCP process restarts mid-run, the server resumes tracking and continues retries based on stored context.
- Zero-downtime config promotion
- Push a new configuration to /configs, validate diff, and promote changes in controlled batches. Each change creates a versioned config row so you can rollback to the prior state if issues are detected.
- Automated health monitoring and remediation
- Schedule a job to call GET /services/HDFS/status; if the service is degraded, submit a remedial operation (e.g., restart failed components) and track it through the MCP API. Since all steps are persisted, you can analyze historical faults and remediation effectiveness.
- External orchestration integration
- Use MCP as the control-plane for higher-level orchestration tools (CI/CD, autoscalers). Instead of invoking Ambari directly, those tools post requests to MCP and consume operation states from the unified PostgreSQL store.
Notes and Best Practices
- Secure the Ambari credentials and database access; use network-level controls and secrets management.
- Back up PostgreSQL regularly to preserve operation history and audit logs.
- Tune retry policies and timeouts for long-running Ambari operations to avoid duplicate side effects.
- Consider enabling metrics/exporters if you want operational telemetry for MCP itself (request latency, queue depth, failure rates).
For the source code, issues, and contribution guidelines, see the project repository: https://github.com/call518/MCP-PostgreSQL-Ops.