From 9da25a149d993f1bb4cd7c38ec8dde2880101e47 Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 23 Feb 2026 19:59:07 +0000 Subject: [PATCH] story-kit: create 93_story_expose_server_logs_to_agents_via_mcp --- ...ry_expose_server_logs_to_agents_via_mcp.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .story_kit/work/1_upcoming/93_story_expose_server_logs_to_agents_via_mcp.md diff --git a/.story_kit/work/1_upcoming/93_story_expose_server_logs_to_agents_via_mcp.md b/.story_kit/work/1_upcoming/93_story_expose_server_logs_to_agents_via_mcp.md new file mode 100644 index 0000000..c6fbeaf --- /dev/null +++ b/.story_kit/work/1_upcoming/93_story_expose_server_logs_to_agents_via_mcp.md @@ -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