Feat/ts server cli#135
Open
kartikloops wants to merge 62 commits into
Open
Conversation
…none serialization
* add vscode workspace settings for typescript sdk path * add plan doc * add core session state and error models * add interactive session error models * add circular buffer for pty output * add pty handler for managing node-pty processes * add interactive session manager * add tests for circular buffer * add tests for command validation * add tests for pty handler * add tests for interactive session * update eslint config with coverage ignore and stricter rules * fix pending waiters, env cast and resolver types in pty handler * guard read chunk size against zero in session onData handler * add test for cleanup resolving pending waitForExit waiters * add real openroad repl integration check script * code cleanup * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kartik Mittal <100078751+kartikloops@users.noreply.github.com> * added case for READ_CHUNK_SIZE is larger than limit Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kartik Mittal <100078751+kartikloops@users.noreply.github.com> * fix isAlive signaling shutdown when process death is detected * add test for isAlive shutdown signal on process death * fix force terminate returning before alive flag clears * update tests for force terminate waiting for exit * fix terminate not disposing pty listeners and pending waiters * update terminate tests to assert pty cleanup is called * fix clear not waking pending waitForData callers * add regression test for clear waking pending waitForData callers * signal shutdown in readOutput drain path so writer task does not loop indefinitely * add regression test for readOutput signaling shutdown on dead session * fix waitForData not re-checking dataAvailable under mutex after runExclusive * add regression test for waitForData race between fast-path check and mutex * handle append rejection in onData handler to avoid silent data loss * add regression test for append rejection transitioning session to terminated * move MacOSPTYHandler to production and add create_pty_handler factory * use create_pty_handler so macOS gets the keepalive and drain subclass * remove duplicate MacOSPTYHandler from test file and import from production * remove MacOSPTYHandler and create_pty_handler — not needed for PoC * await SIGKILL exit in terminateProcess so cleanup cannot race the exit listener * block path traversal sequences in validateCommand argument check * reject absolute paths in python validateCommand to match typescript behavior * truncate single oversized chunk to maxSize to enforce capacity invariant * throw on unrecognised boolean env vars and lazily init settings to prevent silent security disable * fix ansi decoder escape coverage, annotate mode cr handling, mode validation and pre-compile sequence patterns * wait for exit after kill() throw to observe natural death rather than returning blind * bound waitForExit after SIGKILL to 5s to prevent indefinite hang on D-state processes * revert python absolute path change and align typescript to accept absolute paths via basename check * revert python pty handler and integration test to main --------- Signed-off-by: Kartik Mittal <100078751+kartikloops@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
…none serialization
…xecution from python
…ave the pty marked alive
…ent double kill and stale exit codes
…r is not discarded
…pe sequences is not reinterpreted
…rtup failure cannot leave a creating zombie
… creates are not lost
…lock all creation
…ion is not leaked
…ches in TerminateSessionTool
…ot silently dropped
…te-transition side effect
…trics avoids a second pidusage call
… the dead session from the map
…flect post-loop state
…eady empties the map
…s not retried with SIGTERM
… does not produce a silent 256x256 output
…ive CommandHistoryEntry field
… commands are not exempt
…t can map config and interrupt failures to distinct exit codes
…exit timer so a hung graceful shutdown still exits after FORCE_EXIT_DELAY_SECONDS
…wn idempotence, and the force-exit timer
… --transport is http
…host/port validation error
…otations ported from server.py
…shuts down on signal or transport close
…re asserted to enumerate with correct annotations
…ing logging and server so settings validate before any logger is built and the CLI log level applies first
…ncurrent stateless clients do not collide on JSON-RPC request ids
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the layer that actually boots the MCP server. The engine and all 10 tools already existed on
feat/ts-tools; this connects them to MCP transports, a CLI, and graceful shutdown so thatnode dist/main.js(and laternpx openroad-mcp) runs as a real server.The work is split across four files.
src/server.tsregisters all 10 tools with their Zod schemas and behavior annotations (ported straight from the Pythonserver.py) and runs them over either stdio or HTTP.src/config/cli.tsparses the command-line flags and rejects--host/--portunless you're on HTTP.src/utils/cleanup.tshandles SIGTERM/SIGINT, signals shutdown, and force-exits if a graceful stop hangs.src/main.tsties it together: parse the CLI, set up logging, run the server, and exit with sensible codes. Tests cover the CLI, the cleanup manager, and an in-memory server boot that confirms all 10 tools show up.HTTP runs in stateless mode with a fresh transport and server per request, because the SDK forbids reusing one transport and two clients numbering their requests from the same id would otherwise collide. Session continuity still works since sessions are keyed by our own
session_id, not the MCP transport. Inmain.ts, logging and server are imported dynamically (not statically) so that a bad env var fails cleanly instead of crashing during module load, and so the CLI log level is applied before any logger is built. Lastly,tsconfig.jsonflipsskipLibCheckto true: the SDK's HTTP transport types don't satisfy our strictexactOptionalPropertyTypes, so lib checking has to be skipped to use it. Our own source stays fully type-checked.Everything is verified: typecheck and lint are clean, all 420 tests pass with 85.7% line coverage, and the server was tested live in Cursor and it boots over stdio, lists all 10 tools, spawns a real OpenROAD process and runs commands, handles concurrent HTTP requests without collisions, and shuts down cleanly on Ctrl-C. A bad env var produces a clear configuration error and exit code 1.
To run it, build with
cd typescript && npm run build, then point your MCP client at it:{
"mcpServers": {
"openroad-mcp": {
"command": "node",
"args": ["/absolute/path/to/typescript/dist/main.js"]
}
}
}