Skip to content

Commit 681d493

Browse files
simongdaviesCopilotCopilot
authored
feat: add MCP server example for sandboxed JavaScript execution (#35)
* feat: add MCP server example for sandboxed JavaScript execution Add an MCP (Model Context Protocol) server that exposes an execute_javascript tool, allowing AI agents to run arbitrary JavaScript inside an isolated Hyperlight micro-VM sandbox with strict CPU time limits and automatic snapshot/restore recovery after timeouts. Includes server implementation, demo scripts (PowerShell and Bash), vitest test suite, and documentation. Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * fix: address review comments on MCP server example - Factor NDJSON transport helpers into shared tests/helpers.js module to eliminate duplicated reader logic across all 4 test files (#1) - Remove confusing BBP parenthetical comment; the implementation uses Machin's formula throughout (#9) - Replace Math.random() with seeded PRNG (mulberry32) in test code constants for deterministic, non-flaky test results (#10) - Tighten timing assertion from executeMs > 0 to > 1 for meaningful validation (#10) Note: Issues #2-8 and #11 from the review were already addressed in the current code (setScratchSize, safe JSON.stringify, shell script portability, PowerShell cleanup, timing log correctness, u32 bounds check, Node >= 20 in README + engines, correct JSDoc path). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * copilot review changes Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * fix formatting Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * review feedback Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> --------- Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9c6c15c commit 681d493

14 files changed

Lines changed: 7046 additions & 0 deletions

src/js-host-api/eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default [
2020
clearTimeout: 'readonly',
2121
setInterval: 'readonly',
2222
clearInterval: 'readonly',
23+
performance: 'readonly',
2324
},
2425
},
2526
rules: {

0 commit comments

Comments
 (0)