# salvador-arreola/frugalia-mcp architecture

> Architecture diagram of the GitHub repository salvador-arreola/frugalia-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/salvador-arreola/frugalia-mcp
- Repository: https://github.com/salvador-arreola/frugalia-mcp

## Overview

Frugalia is a GKE FinOps MCP service: scheduled CronJobs and Prometheus alerts initiate an agent workflow, which invokes MCP tools to analyze cluster costs and, with approval, apply resource changes. The runtime dynamically loads tools; sampled source supports Kubernetes and Prometheus access, while the README documents the agent, gateway, billing, Slack, and deployment integrations. Those unsampled capabilities are represented at their documented configuration paths; their internal wiring is not inferred beyond documented flows.

Main entry points: [`src/core/server.py`](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/core/server.py) (Dynamic MCP Server), [`kubernetes/frugalia-agent.yaml`](https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/frugalia-agent.yaml) (Frugalia Agent), [`kubernetes/gateway.yaml`](https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/gateway.yaml) (MCP Gateway), [`src/core/utils.py`](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/core/utils.py) (Prometheus Query Utility)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Initiation and Agent"]
  node_cron["Scheduled CronJobs"]
  node_alerts["Prometheus Alert Rules"]
  node_webhook["Alert Webhook<br/>[main.py]"]
  node_agent["Frugalia Agent"]
end

subgraph group_mcp["MCP Access"]
  node_remote["Remote MCP Server<br/>[remotemcp.yaml]"]
  node_gateway["MCP Gateway<br/>[gateway.yaml]"]
  node_server["Dynamic MCP Server<br/>[server.py]"]
  node_entry["Server Entry Point<br/>[main.py]"]
end

subgraph group_analysis["Cost Analysis"]
  node_rightsizing["Rightsizing Analysis"]
  node_nodeutil["Node Utilization"]
  node_spot["Spot Candidate Safety"]
  node_zombies["Zombie Detection"]
  node_discovery["Resource Discovery"]
  node_metrics["Prometheus Metrics Tool"]
  node_nodepools["Nodepool Check"]
end

subgraph group_changes["Resource Changes"]
  node_patch["Resource Patch Tool"]
end

subgraph group_integrations["Cluster and Integrations"]
  node_prometheus["Prometheus / AlertManager"]
  node_k8s[("Kubernetes API")]
  node_promquery["Prometheus Query Utility<br/>[utils.py]"]
  node_bigquery["Billing MCP"]
  node_slack["Slack MCP<br/>[slack-mcp.yaml]"]
end

node_operator(("AI Agent / Scheduler"))
node_billing_service[("BigQuery")]
node_slack_service["Slack API"]

node_operator -->|"schedules"| node_cron
node_cron -->|"invokes"| node_agent
node_alerts -->|"configures alerts"| node_prometheus
node_prometheus -->|"posts alerts"| node_webhook
node_webhook -->|"invokes"| node_agent
node_operator -->|"requests analysis"| node_agent
node_agent -->|"requests tools"| node_remote
node_remote -->|"routes traffic"| node_gateway
node_gateway -->|"routes requests"| node_server
node_entry -->|"starts"| node_server
node_server -->|"loads tools"| node_rightsizing
node_server -->|"loads tools"| node_nodeutil
node_server -->|"loads tools"| node_spot
node_server -->|"loads tools"| node_zombies
node_server -->|"loads tools"| node_discovery
node_server -->|"loads tools"| node_metrics
node_server -->|"loads tools"| node_patch
node_server -->|"loads tools"| node_nodepools
node_rightsizing -->|"reads workloads"| node_k8s
node_rightsizing -->|"queries usage"| node_promquery
node_nodeutil -->|"reads nodes"| node_k8s
node_nodeutil -->|"queries usage"| node_promquery
node_spot -->|"checks workloads"| node_k8s
node_zombies -->|"scans resources"| node_k8s
node_discovery -->|"lists resources"| node_k8s
node_patch -->|"patches or deletes"| node_k8s
node_metrics -->|"queries metrics"| node_promquery
node_promquery -->|"queries"| node_prometheus
node_nodepools -->|"checks nodepools"| node_k8s
node_gateway -->|"routes tool calls"| node_bigquery
node_gateway -->|"routes tool calls"| node_slack
node_bigquery -.->|"queries billing"| node_billing_service
node_slack -.->|"sends reports"| node_slack_service
node_agent -.->|"requests reports"| node_slack

click node_cron "https://github.com/salvador-arreola/frugalia-mcp/tree/main/kubernetes/cronjobs"
click node_alerts "https://github.com/salvador-arreola/frugalia-mcp/tree/main/kubernetes/prometheus-alerts"
click node_webhook "https://github.com/salvador-arreola/frugalia-mcp/blob/main/event-driven-webhook/main.py"
click node_agent "https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/frugalia-agent.yaml"
click node_remote "https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/remotemcp.yaml"
click node_gateway "https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/gateway.yaml"
click node_server "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/core/server.py"
click node_entry "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/main.py"
click node_rightsizing "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/analyze_rightsizing.py"
click node_nodeutil "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/check_node_utilization.py"
click node_spot "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/identify_spot_candidates.py"
click node_zombies "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/detect_zombie_resources.py"
click node_discovery "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/get_kubernetes_resources.py"
click node_metrics "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/get_prometheus_metrics.py"
click node_patch "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/apply_resource_patch.py"
click node_nodepools "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/check_nodepool_types.py"
click node_promquery "https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/core/utils.py"
click node_bigquery "https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/genai-toolbox-mcp.yaml"
click node_slack "https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/slack-mcp.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cron,node_alerts,node_webhook,node_agent toneBlue
class node_remote,node_gateway,node_server,node_entry,node_billing_service toneAmber
class node_rightsizing,node_nodeutil,node_spot,node_zombies,node_discovery,node_metrics,node_nodepools,node_slack_service toneMint
class node_patch,node_operator toneRose
class node_prometheus,node_k8s,node_promquery,node_bigquery,node_slack toneIndigo
```

## Components

### Initiation and Agent

- [Scheduled CronJobs](https://github.com/salvador-arreola/frugalia-mcp/tree/main/kubernetes/cronjobs): `kubernetes/cronjobs`
- [Prometheus Alert Rules](https://github.com/salvador-arreola/frugalia-mcp/tree/main/kubernetes/prometheus-alerts): `kubernetes/prometheus-alerts`
- [Alert Webhook](https://github.com/salvador-arreola/frugalia-mcp/blob/main/event-driven-webhook/main.py): `event-driven-webhook/main.py`
- [Frugalia Agent](https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/frugalia-agent.yaml): `kubernetes/frugalia-agent.yaml`

### MCP Access

- [Remote MCP Server](https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/remotemcp.yaml): `kubernetes/remotemcp.yaml`
- [MCP Gateway](https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/gateway.yaml): `kubernetes/gateway.yaml`
- [Dynamic MCP Server](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/core/server.py): `src/core/server.py`
- [Server Entry Point](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/main.py): `src/main.py`

### Cost Analysis

- [Rightsizing Analysis](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/analyze_rightsizing.py): `src/tools/analyze_rightsizing.py`
- [Node Utilization](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/check_node_utilization.py): `src/tools/check_node_utilization.py`
- [Spot Candidate Safety](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/identify_spot_candidates.py): `src/tools/identify_spot_candidates.py`
- [Zombie Detection](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/detect_zombie_resources.py): `src/tools/detect_zombie_resources.py`
- [Resource Discovery](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/get_kubernetes_resources.py): `src/tools/get_kubernetes_resources.py`
- [Prometheus Metrics Tool](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/get_prometheus_metrics.py): `src/tools/get_prometheus_metrics.py`
- [Nodepool Check](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/check_nodepool_types.py): `src/tools/check_nodepool_types.py`

### Resource Changes

- [Resource Patch Tool](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/tools/apply_resource_patch.py): `src/tools/apply_resource_patch.py`

### Cluster and Integrations

- **Prometheus / AlertManager**
- **Kubernetes API**
- [Prometheus Query Utility](https://github.com/salvador-arreola/frugalia-mcp/blob/main/src/core/utils.py): `src/core/utils.py`
- [Billing MCP](https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/genai-toolbox-mcp.yaml): `kubernetes/genai-toolbox-mcp.yaml`
- [Slack MCP](https://github.com/salvador-arreola/frugalia-mcp/blob/main/kubernetes/slack-mcp.yaml): `kubernetes/slack-mcp.yaml`

### Other components

- **AI Agent / Scheduler**
- **BigQuery**
- **Slack API**

## Connections

- AI Agent / Scheduler → Scheduled CronJobs: schedules
- Scheduled CronJobs → Frugalia Agent: invokes
- Prometheus Alert Rules → Prometheus / AlertManager: configures alerts
- Prometheus / AlertManager → Alert Webhook: posts alerts
- Alert Webhook → Frugalia Agent: invokes
- AI Agent / Scheduler → Frugalia Agent: requests analysis
- Frugalia Agent → Remote MCP Server: requests tools
- Remote MCP Server → MCP Gateway: routes traffic
- MCP Gateway → Dynamic MCP Server: routes requests
- Server Entry Point → Dynamic MCP Server: starts
- Dynamic MCP Server → Rightsizing Analysis: loads tools
- Dynamic MCP Server → Node Utilization: loads tools
- Dynamic MCP Server → Spot Candidate Safety: loads tools
- Dynamic MCP Server → Zombie Detection: loads tools
- Dynamic MCP Server → Resource Discovery: loads tools
- Dynamic MCP Server → Prometheus Metrics Tool: loads tools
- Dynamic MCP Server → Resource Patch Tool: loads tools
- Dynamic MCP Server → Nodepool Check: loads tools
- Rightsizing Analysis → Kubernetes API: reads workloads
- Rightsizing Analysis → Prometheus Query Utility: queries usage
- Node Utilization → Kubernetes API: reads nodes
- Node Utilization → Prometheus Query Utility: queries usage
- Spot Candidate Safety → Kubernetes API: checks workloads
- Zombie Detection → Kubernetes API: scans resources
- Resource Discovery → Kubernetes API: lists resources
- Resource Patch Tool → Kubernetes API: patches or deletes
- Prometheus Metrics Tool → Prometheus Query Utility: queries metrics
- Prometheus Query Utility → Prometheus / AlertManager: queries
- Nodepool Check → Kubernetes API: checks nodepools
- MCP Gateway → Billing MCP: routes tool calls
- MCP Gateway → Slack MCP: routes tool calls
- Billing MCP → BigQuery: queries billing
- Slack MCP → Slack API: sends reports
- Frugalia Agent → Slack MCP: requests reports
