Repository navigation
[Prototype, do not merge] feat(samples): add the GitHub triage sample's MCP server and e2e harness - #4341
[Prototype, do not merge] feat(samples): add the GitHub triage sample's MCP server and e2e harness#4341josemontespg wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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'; |
| 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; | ||
| } |
There was a problem hiding this comment.
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;
}
}| 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; | ||
| } |
There was a problem hiding this comment.
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;
}1b8a779 to
eff6299
Compare
fef152b to
9f76101
Compare
eff6299 to
758cf6e
Compare
94ac386 to
d430ea0
Compare
758cf6e to
2fb69fa
Compare
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.
2fb69fa to
497bbbd
Compare
d430ea0 to
99bdba2
Compare
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 throughcreateA2uiApp. The server'sinstructionstell 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 buildbuilds the app, and the resource declaresavatars.githubusercontent.comin 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.tsand 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.Verification
yarn install --immutable,tsc,eslint,fix_licenses.py --check, prettier: clean.yarn test: 57 tests in 12 files pass, with live Gemini.unsafe-evalerror. No other CSP violation. Initial views are 486 to 694 px, and 746 px with the issue form tab open.