story-kit: create 93_story_expose_server_logs_to_agents_via_mcp

This commit is contained in:
Dave
2026-02-23 19:59:07 +00:00
parent 1a7948b15a
commit 9da25a149d

View File

@@ -0,0 +1,35 @@
---
name: "Expose server logs to agents via MCP"
---
# Story 93: Expose server logs to agents via MCP
## User Story
As a coder agent, I want to read recent server logs via an MCP tool, so that I can verify runtime behavior (WebSocket events, MCP call flow, PTY interactions) without relying on a human to check.
## Context
Agents currently have no visibility into runtime server behavior. They can run `cargo test` and `cargo clippy`, but for bugs involving runtime flow (e.g. events not reaching the frontend, MCP tools not triggering), they can't verify their fix works end-to-end. Exposing server logs lets agents self-diagnose issues and confirm runtime behavior matches expectations.
## Approach
- Add a bounded ring buffer (e.g. 1000 lines) that captures `eprintln!` / `tracing` output in-process
- Expose an MCP tool `get_server_logs(lines?, filter?)` that returns recent log entries
- `lines`: number of recent lines to return (default 100)
- `filter`: optional substring filter (e.g. `"watcher"`, `"permission"`, `"mcp"`)
- The ring buffer lives in `AppContext` so it's accessible from the MCP handler
## Acceptance Criteria
- [ ] Server captures log output in a bounded in-memory ring buffer
- [ ] `get_server_logs` MCP tool exists with optional `lines` and `filter` parameters
- [ ] Tool returns recent log lines as a newline-separated string
- [ ] Buffer does not grow unbounded (fixed capacity, oldest entries evicted)
- [ ] cargo clippy and cargo test pass
## Out of Scope
- Per-worktree log isolation (agents see the main server's logs)
- Log levels / structured logging migration (can use raw eprintln output for now)
- Log persistence to disk