housekeeper
CLAUDE.md2 starsChanged 51 days agoMITView on GitHub
Housekeeper is an MCP-first application: by default it runs an HTTP MCP server (streamable HTTP transport) that gives AI assistants read-only access to ClickHouse and Prometheus/Victoria Metrics, plus an optional in-account LLM diagnosis tool. With --analyze, runs a one-shot Gemini-based error analysis (agent.go, slack.go, clickhouse.go) and posts to Slack. Legacy; not used in MCP server deployments. Priority: CLI flags > env vars > config file > defaults. Notable keys beyond connection params: The server is deployment-agnostic: everything operator-facing is set…
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Housekeeper is an MCP-first application: by default it runs an HTTP MCP server (streamable HTTP transport) that gives AI assistants read-only access to ClickHouse and Prometheus/Victoria Metrics, plus an optional in-account LLM diagnosis tool.
MCP tools exposed
- clickhouse_query — read-only queries (structured fields or free-form single SELECT/WITH), restricted to
clickhouse.allowed_databases. Free-form SQL goes through the validator inclickhouse_mcp.go(allowlist of table refs, forbidden keywords, quote/whitespace normalization). - prometheus_query — PromQL range queries against the main Prometheus/VM endpoint.
- clickhouse_diagnose — only registered when
bedrock.region+bedrock.model_idare set. Runs a server-side Bedrock Converse tool-use loop (bedrock.go) with a singlerun_sqltool against the elevatedanalyst_clickhouse.*connection, bounded bybedrock.max_iterationsandbedrock.max_seconds, and returns only a text summary. The system prompt lives indiagnose_mcp.go; deployment-specific context is appended frommcp.extra_tool_description.
Analysis Mode (legacy, optional)
With --analyze, runs a one-shot Gemini-based error analysis (agent.go, slack.go, clickhouse.go) and posts to Slack. Legacy; not used in MCP server deployments.
Development Commands
go run . # MCP server (default)
go run . --config configs/config.yml
go build -o housekeeper
go test ./... # tests exist: validator, query building, prometheus parsing
gofmt -s -w . && go vet ./...
docker-compose up -d # local ClickHouseArchitecture
Core files
- main.go — entry point, pflag definitions, mode selection
- sdk_mcp.go — MCP server (go-sdk), tool registration, tool descriptions, HTTP transport + auth/CORS/logging middleware, row summarization
- clickhouse_mcp.go — query args validation, free-form SQL validator, query building/execution, value normalization
- prometheus_mcp.go — Prometheus/VM clients (default + optional clickhouse endpoint), time-range validation
- diagnose_mcp.go — clickhouse_diagnose tool, analyst connection, diagnose system prompt
- bedrock.go — Bedrock client (default AWS credential chain), Converse tool-use loop with iteration + wall-clock budgets
- config.go — Viper config: defaults,
HOUSEKEEPER_*env vars (dots → underscores), config file search paths - clickhouse.go / agent.go / slack.go — legacy
--analyzemode (Gemini + Slack) - clickhouse_auth.go — ClickHouse password resolution shared by every connection: the
password_filetoken with a static-password fallback
Configuration
Priority: CLI flags > env vars > config file > defaults. Notable keys beyond connection params:
mcp.extra_tool_description— deployment-specific guidance appended to BOTH the clickhouse_query description and the diagnose agent's system promptmcp.query_extra_description— appended ONLY to clickhouse_query (restricted-role caveats the elevated diagnose agent must not see)bedrock.*— enables clickhouse_diagnose (region + model_id), budgets, temperatureanalyst_clickhouse.*— elevated connection for the diagnose agent; falls back toclickhouse.*when unsetclickhouse.password_file/analyst_clickhouse.password_file— a rotating token (a projected ServiceAccount token validated by ch-podauth), re-read on every connect byclickhousePasswordinclickhouse_auth.go. An unreadable or empty file uses the staticpassword, and so does an expired token when apasswordis set
Deployment
The server is deployment-agnostic: everything operator-facing is set via flags, config file, or HOUSEKEEPER_* env vars.
Important Notes
- MCP is the default mode —
--analyzeis legacy and unused in k8s. - Security boundary is server-side — the SQL validator is defense-in-depth; the ClickHouse role/profile (grants, column REVOKEs) is the real boundary. Keep both in mind when changing the validator.
- Tool descriptions are product surface — most operator-facing behavior is prompt text supplied via the
mcp.extra_tool_description/mcp.query_extra_descriptionconfig keys, not Go code. Check deployment config first for instruction changes. - Config security —
configs/config*.ymlare gitignored; only*.sample/*.exampleare tracked. - Tests — table-driven tests in
clickhouse_mcp_test.go,clickhouse_test.go,prometheus_mcp_test.go,clickhouse_auth_test.go. Extend them when touching the validator; bypasses have happened (multiline whitespace).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

