-
Notifications
You must be signed in to change notification settings - Fork 17
Make MCP server browser-portable with a Web-standard handler #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Populated by `yarn start` (verbatim assets + synced worker bundle + webpack output) | ||
| dist/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Workflow Server MCP Demo (browser) | ||
|
|
||
| A browser demo for the `@eclipse-glsp/server-mcp` portable Fetch handler. The page opens a | ||
| workflow GLSP session inside an in-page Web Worker and drives the MCP server through a | ||
| Service Worker that intercepts `fetch('/mcp', …)` and proxies the request to the Worker via | ||
| `MessageChannel`. | ||
|
|
||
| This package is **private** — it ships nothing; it's a local demo and manual test bench for | ||
| the portable handler. | ||
|
|
||
| ## Why only a browser demo? | ||
|
|
||
| The browser variant needs a custom harness because **external MCP clients can't reach an | ||
| in-page launcher**: a browser tab doesn't accept inbound network traffic. The Service Worker | ||
| in this demo is what makes the in-page launcher reachable to a same-origin MCP client. | ||
|
|
||
| For the **Node variant**, no demo is needed in this repo — the launcher binds a real HTTP | ||
| listener and announces its URL via stdout (`[GLSP-MCP-Server]:Ready. {…}`). Point any MCP | ||
| client at that URL: | ||
|
|
||
| - The official **[MCP Inspector](https://github.com/modelcontextprotocol/inspector)** is the | ||
| best manual debug tool — runs as a local web UI and lets you exercise tools, prompts and | ||
| resources interactively. | ||
| - **Claude Code**, **Cursor**, or any other MCP-aware client also work. | ||
|
|
||
| The Node path is additionally covered by the automated end-to-end spec at | ||
| `packages/server-mcp/src/node/server/mcp-http-transport-e2e.spec.ts`, which runs an MCP SDK | ||
| `Client` over real HTTP against the launcher. | ||
|
|
||
| ## Running | ||
|
|
||
| From the repository root: | ||
|
|
||
| ```bash | ||
| yarn workspace @eclipse-glsp-examples/workflow-server build | ||
| yarn workspace @eclipse-glsp-examples/workflow-server-mcp-demo start | ||
| ``` | ||
|
|
||
| The `start` script copies the worker bundle from | ||
| `@eclipse-glsp-examples/workflow-server-bundled-web`, builds the page-side bundle, and serves | ||
| the directory on `http://localhost:8000/`. | ||
|
|
||
| Open `http://localhost:8000/` in a Chromium-based browser. Step through the buttons | ||
| top-to-bottom; the workflow auto-renders once MCP is initialized, and **Create task** | ||
| mutates the live session. | ||
|
|
||
| ## What it exercises | ||
|
|
||
| 1. The page acts as a minimal GLSP JSON-RPC client over `postMessage` to the in-page Web | ||
| Worker (using `vscode-jsonrpc/browser`, bundled). | ||
| 2. GLSP `initialize` carries `mcpServer: {}` — the Worker's per-connection child container | ||
| activates `BrowserMcpServerModule`'s launcher as a `GLSPServerInitializer`. | ||
| 3. `initializeClientSession` opens a real workflow GLSP session with | ||
| `diagramType: workflow-diagram`. | ||
| 4. A Service Worker (`mcp-service-worker.js`) intercepts `fetch('/mcp', …)` and proxies the | ||
| request through a `MessageChannel` to the Worker. | ||
| 5. MCP tools (`initialize`, `tools/list`, `session-info`, `query-elements`, `diagram-model`, | ||
| `create-nodes`) round-trip end-to-end against the live session. | ||
|
|
||
| The on-page SVG is a minimal schematic renderer — **not** the GLSP client; its only purpose | ||
| is to make the MCP handlers' output visible so the demo can be eyeballed end-to-end. | ||
|
|
||
| ## Hard reset | ||
|
|
||
| If a stale Service Worker is misbehaving: DevTools → Application → Service Workers → | ||
| Unregister, then close the tab and re-open. The page's Worker bundle URL is cache-busted per | ||
| load, but the SW itself updates only on full lifecycle restart. | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "name": "@eclipse-glsp-examples/workflow-server-mcp-demo", | ||
| "version": "2.7.0-next", | ||
| "private": true, | ||
| "description": "Browser demo that drives the @eclipse-glsp/server-mcp portable Fetch handler against the workflow web server bundle.", | ||
| "homepage": "https://www.eclipse.org/glsp/", | ||
| "bugs": "https://github.com/eclipse-glsp/glsp/issues", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/eclipse-glsp/glsp-server-node.git" | ||
| }, | ||
| "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", | ||
| "author": { | ||
| "name": "Eclipse GLSP" | ||
| }, | ||
| "scripts": { | ||
| "build": "webpack", | ||
| "clean": "rimraf dist", | ||
| "prestart": "node ./scripts/prepare-dist.mjs && yarn build", | ||
| "start": "npx -y serve -l 8000 ./dist" | ||
| }, | ||
| "dependencies": { | ||
| "@eclipse-glsp-examples/workflow-server-bundled-web": "2.7.0-next" | ||
| }, | ||
| "devDependencies": { | ||
| "vscode-jsonrpc": "8.2.0", | ||
| "webpack": "^5.75.0", | ||
| "webpack-cli": "^5.0.1" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn start:mcp-demoshould be fine here right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, switched to yarn start:mcp-demo. Thanks!