feat: Add inlined-server-java example — Java MCP App with inlined HTML UI#452
Draft
feat: Add inlined-server-java example — Java MCP App with inlined HTML UI#452
Conversation
Single-file Java server using the MCP Java SDK (v0.17.2) with embedded Jetty. Registers a "get-time" tool whose inline HTML UI loads the @modelcontextprotocol/ext-apps SDK from CDN. Supports both HTTP/SSE and stdio transports. https://claude.ai/code/session_01UoPpdpXv9J26uSJadaMy8n
Use the correct versioned path used in the reference gist: https://unpkg.com/@modelcontextprotocol/ext-apps@1.0.1/dist/src/app-with-deps.js https://claude.ai/code/session_01UoPpdpXv9J26uSJadaMy8n
- Split Main.java into Server.java (MCP content: tool, resource, HTML) and Main.java (transport wiring: stdio / Jetty HTTP) - Add package.json so run-all.ts picks it up alongside other examples (build: mvn package, start/dev: mvn package && java -jar) - Add Java to CI: actions/setup-java@v4 in build matrix; openjdk-17 + maven in build-wsl WSL step - Add Java to README: starter templates list, prerequisites section, MCP client config snippets (both npx-style and local dev) https://claude.ai/code/session_01UoPpdpXv9J26uSJadaMy8n
…essionIdGenerator: undefined)
@modelcontextprotocol/ext-apps
@modelcontextprotocol/server-basic-react
@modelcontextprotocol/server-basic-vanillajs
@modelcontextprotocol/server-budget-allocator
@modelcontextprotocol/server-cohort-heatmap
@modelcontextprotocol/server-customer-segmentation
@modelcontextprotocol/server-map
@modelcontextprotocol/server-pdf
@modelcontextprotocol/server-scenario-modeler
@modelcontextprotocol/server-shadertoy
@modelcontextprotocol/server-sheet-music
@modelcontextprotocol/server-system-monitor
@modelcontextprotocol/server-threejs
@modelcontextprotocol/server-transcript
@modelcontextprotocol/server-video-resource
@modelcontextprotocol/server-wiki-explorer
commit: |
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.
Summary
Adds a minimal Java MCP App server (
inlined-server-java) that demonstrates a different pattern from thebasic-server-*examples: the UI is inlined as a Java text block string with the SDK loaded from CDN — no frontend build step required.What it shows
Stringliteral inServer.java, importing@modelcontextprotocol/ext-appsfrom unpkg CDNHttpServletStatelessServerTransport+ embedded Jetty (matches JS examples'sessionIdGenerator: undefined)--stdioflag)content(text) andstructuredContent(typed map)Files
Server.javacreate()overloaded for stateful (stdio) and stateless (HTTP)Main.javapom.xmlpackage.jsonrun-all.tsDependencies
0.17.2(stateless HTTP transport, Jackson JSON mapper)12.0.16(embedded servlet container)Test Plan
EXAMPLE=inlined-server-java npm start— starts Java server + basic-host, opens athttp://localhost:8080inlined-server-javaserver,get-timetool, click "Call Tool" → UI displays current server timenpm run build:all— all examples including Java build successfully