feat(public-api): complete session API surface for mcp-acp integration#807
feat(public-api): complete session API surface for mcp-acp integration#807
Conversation
Add PATCH, logs, transcript, and metrics endpoints to the public API so
mcp-acp can operate end-to-end with API keys. Enrich SessionResponse DTO
with displayName, repos, labels, and timeout fields.
Backend changes:
- Add GET /api/.../logs (streaming with 10MB cap, pod log via K8s API)
- Add GET /api/.../metrics (session CR status + usage annotations)
- Fix PatchSession to delete annotations set to nil instead of storing
empty strings
Public API changes:
- Add PATCH /v1/sessions/:id with smart routing (start/stop/update/labels)
- Add GET /v1/sessions/:id/{logs,transcript,metrics} proxy handlers
- Forward labelSelector query params in ListSessions
- Forward displayName in CreateSession
- Validate label keys against reserved internal prefixes on write
- Fix labels-to-annotations mapping on create path for write/read symmetry
- Label PATCH returns full session DTO (follow-up GET for consistency)
Other:
- Fix setup-vertex-kind.sh to restart backend-api after ConfigMap patch
- Add IMAGE_PUBLIC_API substitution in e2e deploy script
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MCP Public API Update — E2E Test PlanResult: 24/24 tests passed Bugs found and fixed during testing:
Initial Setup1. Verify port-forward to public API
2. Create service account with RBAC for testing
3. Generate bearer token
4. Ensure backend-api has Vertex AI configThe
5. Verify token works with public API
Session CRUD — Enriched Fields6. Create a session with displayName, model, and task
7. Get the created session — verify enriched DTO
8. List sessions — verify enriched fields in list
PATCH — Smart Routing9. PATCH stop session (
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…y comments - Use unstructured.NestedString/NestedFloat64 in sessions_metrics.go instead of direct type assertions - Replace raw JSON bind error with generic "Invalid request body" in PatchSession - Add safety comments explaining why raw query forwarding is safe in ListSessions, GetSessionTranscript, and GetSessionLogs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review ResponseThanks for the thorough review. Here's what I addressed and what I'm pushing back on: Fixed (e29b679)Item 1 — Unstructured helpers in Item 5 — Raw JSON bind error: Replaced Item 6 — Query string forwarding comments: Added safety comments on all three Not changingItem 2 — Log injection sanitization: No existing handler in Item 3 — Item 4 — |
This comment has been minimized.
This comment has been minimized.
…ments - Add kubectl.kubernetes.io/ and meta.kubernetes.io/ to internalLabelPrefixes to prevent leaking last-applied-configuration - Align sessions_metrics.go auth check to use k8sClt for consistency with sessions_logs.go - Refine query forwarding comments to note backend validates params Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Response (iteration 2)Fixed (44f9dc9)Item 1 — Auth check consistency: Changed Item 5 — Item 6 — Comment wording: Updated to "Forwarded verbatim to backend; backend enforces its own validation and RBAC via the user's token." Not changingItem 2 — Labels silently dropped on CreateSession: This was already fixed and E2E validated. The backend Item 3 — Hardcoded Item 4 — Fallback response in Item 7 — Usage annotations as strings: By design. K8s annotations are always |
This comment has been minimized.
This comment has been minimized.
|
still needs review to be addressed |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…m into andalton/mcp-update
Review Response (iteration 3)Fixed (b73fded): Sanitized |
|
Claude Code Review SummaryPR #807 completes the public API session surface (PATCH, logs, transcript, metrics endpoints), enriches the Issues by SeverityBlocker IssuesNone. Critical IssuesNone. Major Issues1.
c.Header("Content-Type", "text/plain; charset=utf-8")
c.Status(http.StatusOK)
if _, err := io.Copy(c.Writer, resp.Body); err != nil {
log.Printf("GetSessionLogs: error streaming backend response for %s: %v", sessionID, err)
}Minor Issues1. Backend
2.
3.
Positive Highlights
Recommendations
Generated with Claude Code |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Response (iteration 3)Fixed (11813e0)Major — Public-API Minor 3 — Not changingMinor 1 — 200 vs 204 for missing pod: Changing the HTTP status code is a behavioral change that could break existing callers (MCP clients, CLI). The current 200-with-empty-body is documented and semantically valid — "here are the logs, there are none yet." A 204 would also require callers to handle an additional status code for a non-error case. Minor 2 — Two round-trips for label PATCH: The reviewer acknowledges this is intentional. The PATCH endpoint doesn't return a full session DTO, so the follow-up GET is necessary to give callers a consistent |
This comment has been minimized.
This comment has been minimized.
…d session ID to label fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude Code Review Summary PR 807 adds PATCH, logs, transcript, and metrics endpoints to the public-API, enriching SessionResponse DTO and fixing label write/read symmetry. User-token auth is correctly enforced, log-injection prevention is applied consistently, reserved-prefix validation guards annotation writes, and test coverage is thorough. No blocker or critical issues were found. Issues by Severity BLOCKER: None. CRITICAL: None. MAJOR ISSUES
MINOR ISSUES
POSITIVE HIGHLIGHTS
RECOMMENDATIONS
|
…stamp, add audit logging - GetSessionLogs now checks session CR exists before pod log access (returns 404 for unknown sessions) - Skip durationSeconds/completionTime when completionTime fails RFC3339 parse - Log IsForbidden attempts in both backend handlers for security auditing - Add sessionID context to all patch error log messages - Document follow-up GET race window in patchSessionLabels Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Queue Status
Action needed: Fix failing CI checks
|
Summary
SessionResponseDTO withdisplayName,repos,labels, andtimeoutfieldssetup-vertex-kind.shto restartbackend-apiafter ConfigMap patchTest plan
🤖 Generated with Claude Code