Created
June 10, 2026 18:46
-
-
Save Timtech4u/901b2914129e98784cb09c205ea48d6a to your computer and use it in GitHub Desktop.
WebMCP operations desk demo — sample code (GDE Agentic Architect sprint)
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
| #!/usr/bin/env bash | |
| # Run the operations desk demo locally (Chrome 149+, WebMCP testing flag enabled). | |
| set -euo pipefail | |
| python3 webmcp-origin-isolated-server.py & | |
| SERVER_PID=$! | |
| trap 'kill "$SERVER_PID" 2>/dev/null || true' EXIT | |
| sleep 1 | |
| open -a "Google Chrome" "http://127.0.0.1:8765/" 2>/dev/null || true | |
| echo "Enable chrome://flags/#enable-webmcp-testing, then check DevTools → Application → WebMCP" | |
| wait "$SERVER_PID" |
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <title>WebMCP Operations Desk — tool registration excerpt</title> | |
| </head> | |
| <body> | |
| <!-- Excerpt: register tools on navigator.modelContext (Chrome 149+) --> | |
| <script> | |
| const mc = navigator.modelContext; | |
| mc.registerTool({ | |
| name: "list_cases", | |
| description: "List support cases in the operations desk", | |
| inputSchema: { type: "object", properties: {} }, | |
| execute: async () => | |
| JSON.stringify(cases.map(({ id, title, status }) => ({ id, title, status }))), | |
| }); | |
| mc.registerTool({ | |
| name: "prepare_status_update", | |
| description: "Prepare a status update that requires explicit confirmation", | |
| inputSchema: { | |
| type: "object", | |
| properties: { | |
| case_id: { type: "string" }, | |
| new_status: { type: "string", enum: ["open", "investigating", "waiting", "resolved"] }, | |
| }, | |
| required: ["case_id", "new_status"], | |
| }, | |
| execute: async ({ case_id, new_status }) => | |
| JSON.stringify(prepareStatusUpdate(case_id, new_status)), | |
| }); | |
| mc.registerTool({ | |
| name: "confirm_status_update", | |
| description: "Confirm a pending status update using the token from prepare_status_update", | |
| inputSchema: { | |
| type: "object", | |
| properties: { token: { type: "string" } }, | |
| required: ["token"], | |
| }, | |
| execute: async ({ token }) => JSON.stringify(confirmStatusUpdate(token)), | |
| }); | |
| </script> | |
| </body> | |
| </html> |
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
| #!/usr/bin/env python3 | |
| """Minimal origin-isolated static server for local WebMCP development.""" | |
| from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer | |
| from pathlib import Path | |
| SERVE_DIR = Path(__file__).resolve().parent | |
| class WebMCPRequestHandler(SimpleHTTPRequestHandler): | |
| def __init__(self, *args, **kwargs): | |
| super().__init__(*args, directory=str(SERVE_DIR), **kwargs) | |
| def end_headers(self) -> None: | |
| self.send_header("Cross-Origin-Opener-Policy", "same-origin") | |
| self.send_header("Cross-Origin-Embedder-Policy", "credentialless") | |
| self.send_header("Permissions-Policy", "tools=*") | |
| super().end_headers() | |
| if __name__ == "__main__": | |
| server = ThreadingHTTPServer(("127.0.0.1", 8765), WebMCPRequestHandler) | |
| print("http://127.0.0.1:8765/") | |
| server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment