How do I ask Claude Code to investigate slow database queries with Tares?
Tares lets you ask Claude Code about slow database queries by connecting it over MCP and asking what happened to a service in the last 15 minutes. Claude Code calls the read tool and answers from one correlated timeline of metrics, logs, alerts and findings for that service. The database signals show up in that timeline when the sources that carry them are labeled with the same service.
How it works
Tares exposes an MCP endpoint. Claude Code connects to it, discovers the Tares tools and pulls evidence only when you ask.
- One read, all sources. The
readtool returns a time-ordered timeline across all sources that match a label selector, such as the service label set toapi-server. Logs, metrics, alerts and findings arrive merged on one clock. - Your database signals join the timeline through sources. A Postgres source reads new and changed rows from a table. A Prometheus source can poll database metrics. A logs source can tail a container. Give each a label for the service and they all land in the same per-service timeline.
- Findings come back too. If a Tares agent or an outside agent has already recorded a finding on the service, the read includes it, so Claude Code starts from the previous conclusion instead of from scratch.
- Discovery tools help you orient.
catalog_listshows your sources, triggers and projects.catalog_describeshows one object’s schema, freshness and sample events.
This is the pull side of Tares: you ask, the agent reads. The Build an AI SRE guide shows the push side as well, where a trigger wakes an agent for you.
Set it up
-
Start Tares and the MCP endpoint. On your machine, run the daemon, then start the MCP server in a second terminal. The local endpoint is
http://localhost:8788/mcp.tares up tares mcpOn your own server the endpoint is your domain with
/mcp, and the MCP server is already running. On Tares Cloud the endpoint is shown under Connect in your console. -
Connect Claude Code. The default path is the Tares plugin. In Claude Code, run
/plugin marketplace add glassflow/tares, then/plugin install tares@tares. The install asks for the MCP endpoint, an optional auth token and a capture toggle. The console’s Connect page also generates the exact Claude Code command with your endpoint and token filled in. See Connecting agents (MCP) for every client. -
Add a credential on a secured instance. A secured instance, which includes every server and Tares Cloud instance, needs a scoped API key with the
readscope, sent as an Authorization Bearer header. An open local instance needs none. -
Make sure your database signals are sources with a service label. Add a source for each signal you want in the timeline, such as a Postgres table, Prometheus metrics or container logs, and give every one the same primary service label. You can also ask Claude Code to set them up with the
discover_source,test_sourceandcreate_sourcetools. -
Verify the connection. Ask Claude Code:
Use tares: what are you ingesting right now?
It should call
catalog_listand list your sources, triggers and projects. -
Ask about the slow queries. Name the service that owns the database traffic:
Use tares: what happened to api-server in the last 15 minutes?
Claude Code calls
readwith the service label set toapi-serverand answers from the correlated timeline. Follow up in plain words, for example by asking which metrics moved first, or whether an alert or a deploy came before the slowdown. In the console, Reads lists each read as it happens, taggedclient = mcp.
What you get
- One answer from one read. Claude Code sees latency metrics, database-related logs, alerts and earlier findings side by side in time order, so it can tie a slowdown to specific evidence lines instead of querying each system separately.
- A starting point that improves. Findings recorded on the service are part of the next read, so each investigation leaves the timeline more useful for the next one.
- A record of every read. The console shows each MCP read, so you can see what the agent looked at.
- A path to automation. Once you know what a slow-query incident looks like in the timeline, you can have the agent create a trigger with
create_triggerto be woken when it happens again, and userememberto write back what it found.
When something else fits
- If you want the investigation to start without you asking, use a trigger that wakes a Tares agent or your own agent over a webhook. The Build an AI SRE guide walks through it.
- If you prefer to explore in the browser rather than in Claude Code, the console’s Ask chat uses the same read tools without any client setup.