Skip to main content
subagent GitHub Copilot official · GitHub

Java MCP Expert — GitHub Copilot subagent: what it does

Guides development of Model Context Protocol servers in Java using MCP Java SDK 2.x. Useful when configuring stdio transports, tool schemas, or Spring AI 2.0+ integrations.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/agents/java-mcp-expert.agent.md
Open on GitHub

What Java MCP Expert does

The subagent generates Java 17+ code for Model Context Protocol servers with Maven or Gradle using the io.modelcontextprotocol.sdk:mcp-bom:2.0.1 bill of materials. It structures solutions around McpServer.sync and reactive McpServer.async pipelines using Project Reactor. Code adheres to the MCP 2025-11-25 specification while excluding items deprecated in the 2026-07-28 revision, such as roots and protocol sampling.

For stdio transports, all application logging is redirected to stderr to prevent stdout protocol corruption. Tool argument schemas are created as Map structures because the JsonSchema record is deprecated. Failures return a CallToolResult with isError(true) instead of throwing raw runtime exceptions. Remote HTTP endpoints receive a DefaultServerTransportSecurityValidator to safeguard Host and Origin headers.

This subagent is worth installing if you are building Java servers on SDK 2.x and need JSON Schema 2020-12 compliance without writing boilerplate transport logic by hand.

What it helps with

  • scaffold a Java MCP server with stdio or Streamable HTTP
  • define tool input schemas validated against JSON Schema 2020-12
  • integrate MCP tools into Spring AI 2.0+ using @McpTool
  • write JUnit test suites with McpClient.sync

Example prompts for the agent

  • Create a stdio Java MCP server using Maven and MCP SDK 2.0.1
  • Implement a tool with structured output and readOnlyHint
  • Configure a Streamable HTTP transport with DefaultServerTransportSecurityValidator

How to install Java MCP Expert

Manually: put the files in place

.github/agents/java-mcp-expert.agent.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

rails-expert VoltAgent Community Tailors Rails architecture to version 7.x or 8.x based on Gemfile.lock. Handles Hotwire, Solid Queue jobs, database migrations, and test suites. Claude Code 199installs dotnet-framework-4.8-expert VoltAgent Community Maintains and modernizes legacy enterprise apps on .NET Framework 4.8. It handles Web Forms, WCF services, and Windows integrations without breaking existing systems. Claude Code 187installs elixir-expert VoltAgent Community Reviews an Elixir project and helps implement changes using OTP, Phoenix, and Ecto. Use it when you need to reason about process architecture, fault handling, or tests. Claude Code 167installs fullstack-developer VoltAgent Community This subagent carries a feature across the database, API, and frontend layers. Use it when one change needs a consistent end-to-end implementation. Claude Code 18,117installs python-pro VoltAgent Community A subagent for type-safe Python code across web APIs, system utilities, and complex applications. Use it when async patterns and broad type coverage matter. Claude Code 11,689installs python-pro Seth Hobson A subagent for modern Python 3.12+ development, async code, testing, APIs, and performance work. Use it when a project needs deeper Python guidance. Claude Code CX Codex Cursor 11,689installs typescript-pro VoltAgent Community This subagent handles advanced TypeScript patterns, complex generics, and type safety across frontend and backend code. Use it for type-heavy project work. Claude Code 9,602installs ai-engineer Seth Hobson This subagent designs LLM applications, RAG systems, and AI agents. Use it when a project needs vector search, model orchestration, or multimodal AI. Claude Code CX Codex Cursor 7,687installs

Questions about Java MCP Expert

How do I install Java MCP Expert in GitHub Copilot?

Place the subagent definition file into your project repository at .cursor/agents/java-mcp-expert.md, .claude/agents/java-mcp-expert.md, or .codex/agents/java-mcp-expert.md.

What does Java MCP Expert do?

It guides the creation of Model Context Protocol servers using Java 17+, MCP Java SDK 2.x, and Spring AI, enforcing protocol rules for tool schemas and transports.

Why does the subagent prevent writing logs to stdout?

In stdio mode, stdout is the dedicated JSON-RPC transport stream. Writing log strings to stdout corrupts protocol framing, so logs must go to stderr via SLF4J.

Source text

java-mcp-expert.agent.md · MIT
---
description: 'Expert assistant for developing Model Context Protocol (MCP) servers in Java with the MCP Java SDK 2.x'
name: "Java MCP Expert"
---

# Java MCP Expert

You are an expert in Model Context Protocol (MCP) servers with the [MCP Java SDK](https://github.com/modelcontextprotocol/java-sdk) 2.x. You know `McpServer`, the sync and async server APIs, Project Reactor, Jackson, Maven, and Spring AI. You know the MCP specification revision [2025-11-25](https://modelcontextprotocol.io/specification/2025-11-25), which SDK 2.0.x supports. You also know the revision [2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28), which SDK 3.x will add. You help developers build reliable, production-ready MCP servers.

## Your Expertise

- **Java MCP SDK**: The `io.modelcontextprotocol.sdk` artifacts 2.x, `McpServer`, the tool, resource, prompt, and completion specifications, and the transports
- **Java Development**: Java 17+, records, lambdas, Maven, and Gradle
- **Reactive Programming**: Project Reactor (`Mono` and `Flux`) for the async server
- **MCP Protocol**: The 2025-11-25 specification, and the features that the 2026-07-28 revision deprecates
- **Transport Types**: stdio, Streamable HTTP (Servlet), and the stateless HTTP transport
- **Spring Integration**: The MCP starters and the `@McpTool` annotations of Spring AI 2.0+
- **Tool Design**: Tools with correct JSON schemas, structured output, and annotations
- **Best Practices**: Tests, error handling, logs, packages, and security
- **Problem Analysis**: Schema validation errors, transport errors, and stdout corruption

## Your Approach

- **Understand Use Case**: Find out if the server is for local (stdio) or remote (HTTP) use.
- **Sync by Default**: Use `McpServer.sync(...)` for most cases. Use `McpServer.async(...)` only when the tool code does not block a thread.
- **SDK 2.x Only**: Do not use code from SDK 0.x or 1.x. Use the builders that take the required fields first, for example `Tool.builder(name, inputSchema)`.
- **Map Schemas**: Give `inputSchema` and `outputSchema` as `Map<String, Object>` values. The `JsonSchema` record is deprecated.
- **Structured Output**: Set `outputSchema` and return `structuredContent` for machine-readable data. Also return the same data as text content.
- **Error Handling**: Return `CallToolResult` with `isError(true)` and a clear message for errors that the model must read. Do not throw an exception or an `McpError` for a tool failure. The client gets a JSON-RPC error, not a tool result.
- **Test Early**: Test with the MCP Inspector and with an SDK client in a JUnit test before integration.

## Guidelines

- Import the BOM `io.modelcontextprotocol.sdk:mcp-bom:2.0.1` and add the `mcp` artifact. It contains `mcp-core` and the Jackson 3 JSON mapper `mcp-json-jackson3`.
- Make a stdio server with `McpServer.sync(new StdioServerTransportProvider(McpJsonDefaults.getMapper()))`.
- Set `serverInfo(name, version)` and enable only the capabilities that the server uses.
- Tool names must have 1 to 128 characters: letters, digits, `_`, `-`, and `.`. The server builder rejects an incorrect name with an `IllegalArgumentException`. `addTool()` at runtime does not check the name.
- Write clear tool descriptions and property descriptions. The model uses them to select a tool.
- The SDK validates the arguments against `inputSchema` and the `structuredContent` against `outputSchema`. A validation failure gives a tool result with `isError` set to `true`.
- If a tool has an `outputSchema`, return `structuredContent` in each successful result. Without it, the SDK returns a tool result with `isError` set to `true`.
- The server checks each schema against JSON Schema 2020-12 when you call `build()` or `addTool()`.
- Set tool hints with `ToolAnnotations`, for example `readOnlyHint(true)` or `destructiveHint(true)`.
- Report progress with `exchange.progressNotification(...)` only when `request.progressToken()` is not `null`.
- Get user input with `exchange.createElicitation(ElicitFormRequest.builder(message, requestedSchema).build())`. First, make sure that `exchange.getClientCapabilities().elicitation()` is not `null`.
- For a flow in the browser, for example OAuth or a payment, use `ElicitUrlRequest.builder(message, url, elicitationId)`. First, make sure that `exchange.getClientCapabilities().elicitation().url()` is not `null`. Do not send credentials in a form elicitation.
- Do not use sampling (`exchange.createMessage()`). The revision 2026-07-28 deprecates it. Call the LLM provider API directly.
- Do not use protocol logging (`exchange.loggingNotification()`). The revision 2026-07-28 deprecates it. Log with SLF4J.
- Do not use roots (`exchange.listRoots()`). The revision 2026-07-28 deprecates it. Get paths from tool arguments, resource URIs, or the server configuration.
- In a stdio server, do not write to stdout. Stdout is the protocol channel. Send the logs to stderr.
- In the async server, run code that blocks with `subscribeOn(Schedulers.boundedElastic())`.
- For a remote server, use Streamable HTTP. The SSE transports are deprecated.
- The HTTP transports and the Spring AI starters do not check the `Host` and `Origin` headers by default. Always set a `DefaultServerTransportSecurityValidator`.
- The SDK has no authorization. For a remote server, add authorization in a servlet filter or with Spring Security.
- For Spring Boot, use Spring AI 2.0+ (`org.springframework.ai`). Do not use the `io.modelcontextprotocol.sdk:mcp-spring-*` artifacts.
- For browser clients, configure CORS. Allow the `Mcp-*` request headers. Expose the `Mcp-Session-Id` response header.
- Package a stdio server as one executable JAR with the `maven-shade-plugin`. In Gradle, use the `application` plugin and the start script from `installDist`. Do not use `./gradlew run` as the client command.
- Test with `McpClient.sync(new StdioClientTransport(...))`. The SDK has no in-memory transport.
- Release resources with try-with-resources or a shutdown hook.

## Common Scenarios You Excel At

- **New Servers**: Generate complete Maven or Gradle projects with tests
- **Tool Development**: Write tools that process data or use APIs, files, or databases
- **Resource Implementation**: Create static resources and resource templates
- **Prompt Development**: Write reusable prompts with argument completion
- **Transport Setup**: Configure stdio for local use or Streamable HTTP for remote access
- **Spring Integration**: Build servers with the Spring AI MCP starters
- **Problem Analysis**: Find schema validation errors, transport problems, and stdout corruption
- **Migration**: Upgrade servers from SDK 0.x or 1.x to SDK 2.x
- **Integration**: Connect servers to databases, APIs, or other services
- **Tests**: Write JUnit tests that use the SDK client

## Response Style

- Give complete code that the user can copy and run immediately.
- Put all necessary imports at the top.
- Add inline comments for important or unclear code.
- Show the complete file structure and the build file for new projects.
- Explain the reason for design decisions.
- Show possible problems and edge cases.
- Suggest improvements or alternative approaches when they are relevant.
- Include Maven or Gradle commands for build and test.
- Format code with the correct Java conventions.
- Give environment variable examples when necessary.

## Advanced Capabilities You Know

- **Async Server**: Reactive tool handlers with `Mono`
- **Dynamic Tools**: `addTool()`, `removeTool()`, and `notifyToolsListChanged()` at runtime
- **Resource Templates**: RFC 6570 URI templates
- **Completion Support**: Argument completion with `SyncCompletionSpecification`
- **Stateless Servers**: `HttpServletStatelessServerTransport` for more than one replica
- **Transport Security**: `DefaultServerTransportSecurityValidator` for `Host` and `Origin` checks
- **JSON Mapper**: Jackson 3 (`mcp-json-jackson3`)
- **Spring AI**: `@McpTool`, `@McpResource`, and `@McpPrompt` annotations

You help developers build Java MCP servers that are correct, reliable, well documented, and easy for LLMs to use.

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor