- Update prompt model frontmatter in code-review and feature-add prompts to Claude Sonnet 4.6 (copilot) - Add a save_report implementation plan prompt to support next-session delivery and clearer handoff context
3.0 KiB
3.0 KiB
Plan: Add save_report Tool to nexus-mcp
TL;DR
Add a new save_report MCP tool that accepts a title and markdown content, then writes it as a .md file to the configured reports directory (./documentation/output-reports/). Implemented as a new reports.py shard — consistent with the existing shard pattern and aligned with the pre-staged generate_* tools referenced in the README. All dependencies (aiofiles, ReportConfig) are already present.
Branch Identity
- Branch name:
feat/add-save-report-tool
Steps
Phase 1 — Create the shard
- Create
nexus-mcp/src/shards/reports.py- Define
register(mcp: FastMCP) -> None - Inside, define
save_report(title, content, subfolder, filename)as@mcp.tool()async fn - Use
ReportConfigfromlib/config.pyforoutput_dir - Slugify title → safe filename; add ISO timestamp suffix to avoid collisions
mkdir(parents=True, exist_ok=True)on resolved path- Write file using
aiofiles.open(..., "w") - Return
{"status": "saved", "path": str(abs_path), "filename": final_filename, "size_bytes": N}
- Define
Phase 2 — Register the shard in main.py
- In
nexus-mcp/src/main.py:- Import the new shard:
from shards import reports - Add conditional registration block (matches existing pattern):
if os.getenv("ENABLE_REPORTS", "true").lower() == "true": reports.register(mcp) - Placement: after the existing shard registrations, before audit middleware wrapping
- Import the new shard:
Phase 3 — Environment config
- Add
ENABLE_REPORTS=truetonexus-mcp/.env(if file exists; else note it as optional)
Relevant Files
nexus-mcp/src/shards/reports.py— NEW file to createnexus-mcp/src/main.py— add shard import + conditional registrationnexus-mcp/lib/config.py— reuseReportConfig(specificallyoutput_dir: Path)nexus-mcp/.env— addENABLE_REPORTS=truenexus-mcp/pyproject.toml— no changes needed (aiofiles, jinja2, tabulate already listed)
Verification
- Restart nexus-mcp server; tool list should include
save_report - Call
save_report(title="Test Report", content="# Hello\nThis is a test.")from Claude - Verify file appears at
nexus-mcp/reports/test-report-<timestamp>.md - Call
nexus_audit_recentand confirm asave_reportentry was logged - Run existing tests:
cd nexus-mcp && python -m pytest tests/
Decisions
- New shard (
reports.py) over adding tomain.py— keeps built-ins minimal, aligns with plannedgenerate_*tools aiofilesfor async writes — already a dependency, correct for async tool context- Timestamp in filename — prevents silent overwrite collisions
- Default
ENABLE_REPORTS=true— safe; no external API calls, pure local I/O - Scope: only
save_report— user requested this one tool;generate_*stubs are out of scope
Out of Scope
- Implementing planned
generate_*tools - A
list_reportsordelete_reporttool - Any templating (Jinja2) or formatting logic beyond saving raw markdown