Add local MCP dogfood testing workflow - #49
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a local dogfood testing workflow: a new ChangesDogfood Local Testing Runner
✨ Finishing Touches✨ Simplify code
Comment |
SPerekrestova
left a comment
There was a problem hiding this comment.
Reviewed for correctness. Two concrete issues to address in scripts/dogfood-local.ts:
stderr: "pipe"is set onStdioClientTransportbut never drained — risk of the server deadlocking once stderr exceeds the pipe buffer (~64 KB), especially during Go/Java runs.homeandfixtureDiraremkdtemp'd beforeclient.connect(), but a connect failure bypassesmain'sfinally { cleanup }, leaving temp dirs (and possibly the child process) leaked.
Rest LGTM — fixture/preload reuse is clean, the runtime-availability gate is sensible, and the typed JSON unwrap is solid.
Generated by Claude Code
| args: [SERVER_BIN], | ||
| env, | ||
| cwd: REPO_ROOT, | ||
| stderr: "pipe" |
There was a problem hiding this comment.
Deadlock risk: stderr: "pipe" without a consumer.
When StdioClientTransport is configured with stderr: "pipe", the child's stderr is piped to a Readable that the caller is expected to drain. This script never reads from transport.stderr, so once the child writes ~64 KB of stderr the OS pipe buffer fills and the server blocks on its next write. That can hang the smoke (notably on the Go/Java runs, where compilation diagnostics or logger output land on stderr).
The existing e2e harness (tests/e2e/harness/spawn-server.ts:114) uses stderr: "inherit" precisely to avoid this. Recommend matching that, or alternatively piping transport.stderr to process.stderr after connect.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 1655a2b: switched the dogfood transport to stderr: "inherit", matching the e2e harness so server stderr is continuously drained by the parent process.
| home, | ||
| cleanup: async () => { | ||
| try { | ||
| await client.close(); |
There was a problem hiding this comment.
Temp directories leak if client.connect fails.
spawnDogfoodServer mkdtemps home and fixtureDir (and writes fixture.json) before calling client.connect(transport). If connect throws (transport spawn failure, handshake error, preload exit-1 from a bad fixture), the function rejects without returning the SpawnedDogfoodServer, so main's finally { await spawned.cleanup() } never runs and both temp dirs are leaked in os.tmpdir() for every failed run. The spawned child process can also leak depending on how the SDK handles a partial start.
The e2e harness handles this with try { await client.connect(transport); } catch (e) { await cleanup(); throw e; } — worth mirroring here.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 1655a2b: spawnDogfoodServer() now builds a cleanup closure before client.connect(), calls it on connect failure, and then rethrows so temp dirs are removed even if spawn/handshake/preload setup fails.
Summary
Adds a deterministic dogfood path that runs the built MCP server exactly like a client would:
npm run dogfood:localbuildsbuild/index.js, spawns it over stdio withStdioClientTransport, injects the existing e2enockpreload fixture, isolatesHOME, and drives a user-like flow through:The smoke covers available local runners (
python3,go,java) without requiring LeetCode credentials or live network access, so Devin/CI-like environments can validate the MCP behavior directly. It also documents a second path for a real local Claude/agent setup, including the MCP config command and a copy-paste prompt for testing the server as a practicing user while avoiding accidental live submissions.Verified locally with
npm run build,npm run test:types,npx prettier --check .,npm run dogfood:local,npm test, andnpm run test:e2e.Link to Devin session: https://app.devin.ai/sessions/3e6f3e63f6e54852b9bf6da1c792774f
Requested by: @SPerekrestova