Skip to content

[Prototype, do not merge] feat(samples): add the GitHub triage sample's MCP server and e2e harness - #4341

Closed
josemontespg wants to merge 1 commit into
triage/3-viewsfrom
triage/4-server
Closed

josemontespg wants to merge 1 commit into
triage/3-viewsfrom
triage/4-server

Conversation

@josemontespg

@josemontespg josemontespg commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Internal M1 proof-of-concept sample for @a2ui/embed. It is a prototype for review and is not meant to merge.

Summary

Wires the sample into an MCP server and tests it end to end. The five tools (triage_inbox, issue, pull_request, triage_dashboard, suggest_triage), the actions and the follow-ups go through createA2uiApp. The server's instructions tell the model to reuse the summaries, summarize the triage rules, say writes are dry runs unless enabled, and treat issue text as untrusted. a2ui-embed build builds the app, and the resource declares avatars.githubusercontent.com in its CSP.

The dashboard chart needs #4302 (Vega under a strict CSP). This stack does not include it, so without #4302 the chart fails under the MCP Apps CSP.

Changes

  • app.ts, server.ts, tools.ts: server, instructions, tool definitions, action and follow-up routing.
  • a2ui-embed.config.ts and the build script.
  • scripts/e2e.mjs: Playwright harness with an AppBridge host that loads the app in a sandboxed cross-origin iframe under the resource's CSP, connected to the real server over stdio in fixture mode.
  • In-memory MCP client test of every tool, action and follow-up, and the full README.

Verification

  • yarn install --immutable, tsc, eslint, fix_licenses.py --check, prettier: clean. yarn test: 57 tests in 12 files pass, with live Gemini.
  • e2e in fixture mode, 8 checks. With feat(vegachart): render charts under a strict content security policy #4302: all pass. Without it (this stack): 6 pass, and the dashboard and CSP checks fail on the Vega unsafe-eval error. No other CSP violation. Initial views are 486 to 694 px, and 746 px with the issue form tab open.
  • Real Antigravity run: 10 of 12 checks passed at first. The 2 partials were a Filters dialog clipped after Apply (fixed in feat(embed): render markdown in the app #4334) and frames over the 800 px cap with the issue tabs open. These, and the UX notes (raw markdown in previews, a priority that could not be cleared, a long label list in bulk edit, the slider label, dark label chips), are fixed here and covered by e2e assertions.

@josemontespg
josemontespg added this pull request to stack #4333 November 20, 2026 22:06
@josemontespg josemontespg changed the title feat(samples): add the GitHub triage sample's MCP server and e2e harness [Prototype, do not merge] feat(samples): add the GitHub triage sample's MCP server and e2e harness Nov 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces comprehensive end-to-end and unit testing infrastructure for the GitHub triage MCP server, including a Playwright-based test harness, configuration files, and detailed documentation. The feedback highlights opportunities to improve cross-platform compatibility in the test script by replacing a platform-dependent grep spawn with native Node.js file reading, and to reduce test flakiness by replacing a hardcoded setTimeout with an existing log-waiting helper.

* - A2UI_E2E_CHECKS: comma-separated check letters to run, such as `b,c`. Optional (default: all).
*/

import {spawnSync} from 'node:child_process';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since spawnSync is only used in envFileHasKey and we are refactoring that to use readFileSync for cross-platform compatibility, this import is no longer needed and should be removed to avoid potential lint errors.

Comment on lines +95 to +99
function envFileHasKey() {
if (process.env['GEMINI_API_KEY']) return true;
const result = spawnSync('grep', ['-Eq', '^GEMINI_API_KEY=.+', join(packageRoot, '.env')]);
return result.status === 0;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using spawnSync with grep is not cross-platform (it will fail on Windows) and is less efficient than reading the file directly in Node.js. Since readFileSync is already imported, we can read and test the file content using a regular expression.

function envFileHasKey() {
  if (process.env['GEMINI_API_KEY']) return true;
  try {
    const content = readFileSync(join(packageRoot, '.env'), 'utf8');
    return /^GEMINI_API_KEY=.+/m.test(content);
  } catch {
    return false;
  }
}

Comment on lines +215 to +220
async function recordNaturalHeight(id, view) {
await new Promise(resolve => setTimeout(resolve, 800));
const {sizes} = await hostLog();
const last = sizes.filter(entry => entry.frame === id).at(-1);
(report.naturalHeights ??= {})[view] = last?.params.height;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of using a hardcoded setTimeout of 800ms (which can introduce flakiness or unnecessary delay), we can leverage the existing waitForLog helper to wait until the size change event is recorded for the given frame.

  async function recordNaturalHeight(id, view) {
    const last = await waitForLog('sizes', entry => entry.frame === id && typeof entry.params.height === 'number');
    (report.naturalHeights ??= {})[view] = last.params.height;
  }

Wires the five tools, the actions and the follow-ups into an MCP server
with instructions, builds the app with a2ui-embed build, and adds an
in-memory MCP client test, a Playwright e2e harness with an AppBridge host
under the resource's CSP, and the full README.
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