Skip to content

Federation: log every MCP call at both ends - #39

Merged
alisman merged 1 commit into
masterfrom
session/federation
Oct 18, 2026
Merged

alisman merged 1 commit into
masterfrom
session/federation

Conversation

@alisman

@alisman alisman commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Every federated MCP call now writes one log line on each side. That makes it visible in the server's output (on Vercel, the runtime logs) that a study really was answered over MCP:

[federation →] federated_aggregates study=nsclc_public_genie_bpc peer=https://cbiolab.vercel.app/api/mcp (this app, as its simulated peer) 214ms ok 0.9 kB
[federation ←] federated_aggregates study=nsclc_public_genie_bpc caller=this app (answered as its simulated peer) 89ms HTTP 200 answered 1.1 kB
[federation ←] federated_patient_timeline study=nsclc_public_genie_bpc (patient-level) caller=outside 461ms HTTP 200 REFUSED
  • → (lib/federation-remote.ts): this app asking a peer. Logs the tool, study, peer, duration and size, or why the call failed.
  • ← (app/api/[transport]/route.ts): the /api/mcp endpoint answering. Logs who called (this app or outside), the duration once the response has been written, and whether the call was refused.
  • Arguments are never logged, so a patient never appears. Patient-level tools are marked as such, together with the table they read.
  • The README's Federation section explains how to read the lines.

Verified: scripts/gate.sh green, with 1258 unit tests and 253 e2e checks. The federation stage's production build logged 44 outgoing and 46 incoming calls, each once; the extra two incoming are the e2e suite's outside callers, both refused. No patient id appears in the log.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QLBVrkqBG7J7pqX6Qygx3z

To see that a study really is answered over MCP, every federated call now writes one line where
this app asks a peer and one where its /api/mcp answers (lib/federation-log.ts):

  [federation →] federated_aggregates study=… peer=… (this app, as its simulated peer) 214ms ok 0.9 kB
  [federation ←] federated_aggregates study=… caller=this app (answered as its simulated peer) 89ms HTTP 200 answered 1.1 kB
  [federation ←] federated_patient_timeline study=… (patient-level) caller=outside 461ms HTTP 200 REFUSED

The tool, the study and (patient-level tools) the table — never the arguments, so never a patient.
The answering side logs once the response has been written (a streamed one is not when returned)
and says whether the call was refused; a failed outbound call logs why. README: how to read them.

Verified: scripts/gate.sh green (1258 unit, 253 e2e). The federation stage's production build
logged 44 outgoing and 46 incoming calls (the extra two the e2e's outside callers, both refused),
each once, with no patient id anywhere in the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLBVrkqBG7J7pqX6Qygx3z
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cohort-lab Ready Ready Preview Oct 18, 2026 5:16pm UTC

Request Review

@alisman
alisman merged commit 39ddd9c into master Oct 18, 2026
5 checks passed
@alisman
alisman deleted the session/federation branch October 18, 2026 18:10

This branch was successfully deployed

1 active deployment
Preview — 6854d31a Deployed Oct 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant