Skip to content

feat: render all rpc-messages.jsonl message types in gateway preview step summary#22427

Merged
pelikhan merged 3 commits intomainfrom
copilot/review-mcpg-rpc-messages-format
Mar 23, 2026
Merged

feat: render all rpc-messages.jsonl message types in gateway preview step summary#22427
pelikhan merged 3 commits intomainfrom
copilot/review-mcpg-rpc-messages-format

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Summary

With mcpg v0.2.0 (merged in #22388), the MCP gateway writes all messages to a single rpc-messages.jsonl file instead of separate gateway.md/gateway.log streams. The gateway preview step (parse_mcp_gateway_log.cjs) only extracted DIFC_FILTERED events from this file, so REQUEST and RESPONSE messages were never shown in the step summary.

Changes

actions/setup/js/parse_mcp_gateway_log.cjs

  • parseRpcMessagesJsonl(content) — parses all entries from rpc-messages.jsonl, returning categorized {requests, responses, other} (DIFC_FILTERED excluded as it is handled separately)
  • getRpcRequestLabel(entry) — extracts a human-readable label: tool name for tools/call requests, method name otherwise
  • generateRpcMessagesSummary(entries, difcFilteredEvents) — renders a step summary with:
    • A collapsible tool-calls table (Time, Server, Tool/Method)
    • Other message type counts (e.g. SESSION_START, SESSION_END) if present
    • The existing DIFC_FILTERED details section when there are blocked events
  • main() — when gateway.md is absent (v0.2.0) but rpc-messages.jsonl exists, parses all message types and writes the full summary; the existing gateway.log/stderr.log legacy fallback is preserved

actions/setup/js/parse_mcp_gateway_log.test.cjs

  • Added test suites for parseRpcMessagesJsonl, getRpcRequestLabel, and generateRpcMessagesSummary
  • Updated import to include the three new exported functions

Security Summary

No security vulnerabilities found or introduced.

Copilot AI and others added 2 commits March 23, 2026 12:38
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3ea26947-eade-4fa3-82a0-8c31a58d544b
@pelikhan pelikhan marked this pull request as ready for review March 23, 2026 14:04
Copilot AI review requested due to automatic review settings March 23, 2026 14:04
@pelikhan pelikhan merged commit ccbccb5 into main Mar 23, 2026
92 of 109 checks passed
@pelikhan pelikhan deleted the copilot/review-mcpg-rpc-messages-format branch March 23, 2026 14:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the MCP gateway preview-step log parser to support the unified rpc-messages.jsonl format (mcpg v0.2.0+), so the step summary can surface more than just DIFC-filtered events.

Changes:

  • Added parsing/categorization of rpc-messages.jsonl into {requests, responses, other} (excluding DIFC_FILTERED, which is still handled separately).
  • Added summary rendering for MCP activity (tool/method request table) and “other” message type counts, plus reusing the existing DIFC-filtered section.
  • Added unit tests covering the new parsing/labeling/summary helpers and updated exports/imports.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
actions/setup/js/parse_mcp_gateway_log.cjs Adds JSONL parsing + summary rendering for unified rpc-messages logging and integrates it into main() when gateway.md is absent.
actions/setup/js/parse_mcp_gateway_log.test.cjs Adds/updates tests for the new exported parsing and rendering helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +168 to +172
const time = req.timestamp ? req.timestamp.replace("T", " ").replace(/\.\d+Z$/, "Z") : "-";
const server = req.server_id || "-";
const label = getRpcRequestLabel(req);
callLines.push(`| ${time} | ${server} | \`${label}\` |`);
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Values interpolated into the markdown table for REQUESTs (server_id, and the label from getRpcRequestLabel) are not escaped for table-breaking characters like | or newlines. generateDifcFilteredSummary already escapes reason for |, so it would be more robust to similarly escape server_id (and optionally the label) before writing table rows.

Copilot uses AI. Check for mistakes.
Comment on lines +268 to +275
const rpcSummary = generateRpcMessagesSummary(rpcEntries, difcFilteredEvents);
if (rpcSummary.length > 0) {
core.summary.addRaw(rpcSummary).write();
}
} else {
core.info("rpc-messages.jsonl is present but contains no renderable messages");
}
return;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core.summary.addRaw(rpcSummary).write() is not awaited. Since main() returns immediately afterward, the step summary write can be dropped/flaky depending on event loop timing. Please await core.summary.addRaw(rpcSummary).write(); (and keep summary writes consistent across branches).

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +166
* Generates a markdown step summary for rpc-messages.jsonl entries (mcpg v0.2.0+ format).
* Shows a table of REQUEST entries (tool calls), a count of RESPONSE entries, any other
* message types, and the DIFC_FILTERED section if there are blocked events.
* @param {{requests: Array<Object>, responses: Array<Object>, other: Array<Object>}} entries
* @param {Array<Object>} difcFilteredEvents - DIFC_FILTERED events parsed separately
* @returns {string} Markdown summary, or empty string if nothing to show
*/
function generateRpcMessagesSummary(entries, difcFilteredEvents) {
const { requests, responses, other } = entries;
const blockedCount = difcFilteredEvents ? difcFilteredEvents.length : 0;
const totalMessages = requests.length + responses.length + other.length + blockedCount;

if (totalMessages === 0) return "";

const parts = [];

// Tool calls / requests table
if (requests.length > 0) {
const blockedNote = blockedCount > 0 ? `, ${blockedCount} blocked` : "";
const callLines = [];
callLines.push("<details>");
callLines.push(`<summary>MCP Gateway Activity (${requests.length} request${requests.length !== 1 ? "s" : ""}${blockedNote})</summary>\n`);
callLines.push("");
callLines.push("| Time | Server | Tool / Method |");
callLines.push("|------|--------|---------------|");

Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateRpcMessagesSummary parses and counts responses, but the rendered step summary never mentions RESPONSE messages (only requests table + other type counts + DIFC section). This seems to conflict with the PR goal/description of rendering REQUEST and RESPONSE message types. Consider including at least a response count in the summary (or a collapsible section), or update the PR description/title if responses are intentionally omitted.

Copilot uses AI. Check for mistakes.
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.

3 participants