Repository navigation
Expose all technical diagnostics over MCP - #1723
Conversation
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Summary
Testing
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94890d1a15
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "/api/support/dump": true, | ||
| "/api/support/report": true, | ||
| "/api/ocpp/chargers": true, | ||
| "/api/backups/{id}": true, |
There was a problem hiding this comment.
Keep full backups outside diagnostic reads
An agent granted only ftw.diag.run can enumerate /api/backups and then read /api/backups/{id} through this allowlist. That endpoint was deliberately classified Local because the archive contains the unmasked configuration and state.db; unlike /api/config, the backup path does not redact stored credentials. This turns a diagnostic grant into a complete secrets and persistent-state export, so backups should remain unavailable through this scope or require a separate explicit backup permission.
Useful? React with 👍 / 👎.
| var once sync.Once | ||
| free := func() { once.Do(func() { h.apiBusy.Store(false) }) } | ||
| defer free() | ||
| ctx, cancel := context.WithTimeout(h.ctx, apiHandlerTimeout) |
There was a problem hiding this comment.
Avoid the 15-second deadline for paged exports
For every page, ServeAgentRead regenerates and hashes the entire response before returning the retained slice, but this context cancels the operation after 15 seconds. Consequently, sufficiently large support dumps, research exports, or other advertised unlimited-size reads cannot return even their first page (and later pages repeat the same full scan); this is especially likely for archive handlers whose normal HTTP path explicitly permits long-running downloads. Use an export-appropriate lifetime or a snapshot/streaming pagination design that does not require processing the whole answer within the ordinary API timeout.
Useful? React with 👍 / 👎.
Contract-pair: srcfl/ftw-webapp@codex/mcp-read-api
MCP exposes a few summaries today. It cannot collect the full energy ledger, original driver measurements, incident planner inputs, source code or support files needed to explain faults and report bugs.
Add
api.readfor the full technical read API. The connected box builds its catalogue from its router: all 63 Read routes and 10 local diagnostic reads, including configuration, driver source and logs, OCPP state, support exports, backups and agent audit. New Read routes appear without another Cloud release. Existing handlers validate their query parameters. OAuth exchanges, scan/update actions, writes and hardware commands keep their existing paths.The owner's diagnostic grant (
ftw.diag.run) covers every technical read. There is no second data-scope gate or identity filter: names, addresses, hardware ids, exact numbers, paths and source code stay as the handler returns them. Saved credentials retain the handler's existing masking. Full backup exports can include unmasked credentials and the state database; the full diagnostic grant intentionally covers those bytes without a separate backup permission. Core checks the live grant before each response frame; revocation or expiry stops the answer. The grant's shared description now says it covers the full read API.Large answers use byte pages with SHA-256 checks to detect changed content, without a total-byte cutoff. JSON, CSV, text and binary data remain available. An assistant can also list ZIP/tar.gz members and read their contents on the box, so support files need no external tool. Each call keeps one bounded page in memory; archive inspection uses a private temporary file and removes it on return. The follow-up #1726 gives exports five minutes and preserves encoded path parameters. Calls keep the session's rate limits. Generated exports may change between reads; member reads hash the selected content.
api_catalogalso supplies the Core version, source links for the declared release or recorded build, related repositories, and a workflow for gathering bug evidence. It marks an unknown source version or local changes. Routine status, history and control keep their existing MCP tools. A bug-report draft should include times and timezone, reproduction steps, expected and observed results, versions, queries, logs, snapshots and evidence gaps.Paired PRs: Cloud #35, webapp #98, native #91. This capability needs a Core beta with this code and the Cloud counterpart. The minor changeset needs owner approval.
Validation:
GOWORK=off make verify.internal/api,internal/appprotoandinternal/apiauth.No physical-box or real assistant-account test has run for this new capability.