Letting an AI coding assistant read production logs without giving it a shell

Ways to give an AI agent access to container logs for debugging while keeping it away from shells, secrets and write actions.

Peon

2. November 2026November 2, 2026 · 2 Min. Lesezeit2 min read

Logs are where an AI coding assistant is most useful in production: it can read a stack trace, find the matching code and propose a fix. Giving it SSH so it can run docker logs is far more access than it needs. A read only path to logs gets most of the benefit with little of the risk.

What the agent actually needs#

It does not need to run commands, read environment variables, or open a terminal.

Option 1: export logs to a tool it can query#

If logs already go to Loki, Elasticsearch or a hosted log service, create a read only API token scoped to the relevant streams. Give the agent that token through its tool configuration. The worst a leaked token can do is read logs.

Option 2: a narrow MCP tool#

An MCP server exposing a single get_logs(app, since, level) tool is a few dozen lines. Internally it calls the Docker API or your platform's API with a service account that can only read logs. Keep a fixed allowlist of apps and cap the number of lines returned.

Option 3: platform roles#

If your deployment platform has roles, create a viewer role for the agent's token. Many platforms separate viewing logs from opening a terminal, which is exactly the line you want.

Scrub secrets before the agent sees them#

Logs leak more than people expect: connection strings in error messages, tokens in request URLs, email addresses. Add a redaction step for common patterns before logs reach the agent, and fix the application code that prints secrets.

Keep an audit trail#

Record which tool calls the agent made and when. If something odd happens, you want to know what it looked at.

What to keep for humans#

Restarting services, running migrations and opening a terminal should stay with people, or at minimum require an explicit human approval step.

Peon's documentation on logs and terminal access in Peon shows how log viewing and terminal access are handled per app.

Disclosure: I help build Peon (https://peon.sh/), a deployment platform with role based access for people and agents.

#ai#devops#logs

Written by

Comments

No comments yet. Start the conversation.

Contents

7 sections

  1. What the agent actually needs
  2. Option 1: export logs to a tool it can query
  3. Option 2: a narrow MCP tool
  4. Option 3: platform roles
  5. Scrub secrets before the agent sees them
  6. Keep an audit trail
  7. What to keep for humans