Skip to content

feat(examples): add debug-server for comprehensive SDK testing#332

Closed
ochafik wants to merge 2 commits intomainfrom
ochafik/debug-server-v2
Closed

feat(examples): add debug-server for comprehensive SDK testing#332
ochafik wants to merge 2 commits intomainfrom
ochafik/debug-server-v2

Conversation

@ochafik
Copy link
Contributor

@ochafik ochafik commented Jan 23, 2026

Superseded by #321

Summary

Adds a debug-server example that exercises all MCP Apps SDK capabilities for testing and debugging purposes.

Features

  • Event log with expandable entries showing all SDK callbacks
  • Callback tracking table showing registration status and invocation counts
  • Host info display showing context, capabilities, container dimensions, and styles
  • Message actions - send text and image messages
  • Logging actions - debug, info, warning, error levels
  • Model context updates - text, structured, and image content
  • Display mode controls - inline, fullscreen, PiP
  • Size controls - auto-resize toggle and manual resize buttons
  • Server tool calls - configurable debug-tool with multiple content types

Code Quality Improvements

Addresses issues from code review:

Issue Fix
Memory leak: setInterval Store interval ID, cleanup in onteardown
Memory leak: auto-resize Cleanup autoResizeCleanup in onteardown
Event listeners re-added on render Use event delegation instead
XSS: incomplete HTML escaping Added escapeHtml() that escapes & < > " '
Duplicated base64 constant Extracted TEST_RED_PNG constant
Fire-and-forget sendLog Added await and try/catch
package.json: runtime deps in devDeps Moved cors/express to dependencies
package.json: missing fields Added main, types, bin, exports

Testing

  • Added to E2E tests in servers.spec.ts with dynamic masks for event log, callback table, and current size
  • Added to generate-grid-screenshots.spec.ts for grid cell generation
  • All E2E tests passing in Docker

Screenshots

debug-server screenshot

- Adds debug-server example that exercises all MCP Apps SDK capabilities
- Includes event log with expandable entries for debugging
- Model context updates (text, structured, image)
- Server tool calls and callback tracking
- Display mode and auto-resize controls

Fixes from code review:
- Fix memory leaks: clean up interval and auto-resize in onteardown
- Use event delegation for log entry toggling (no listener re-adding)
- Fix XSS: escape all HTML entities (& " ')
- Extract duplicated TEST_RED_PNG constant
- Fix package.json: move cors/express to dependencies, add proper exports
- Add await for sendLog calls
@ochafik ochafik requested review from antonpk1 and removed request for antonpk1 January 23, 2026 12:01
@ochafik ochafik closed this Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant