Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use the official Model Context Protocol (MCP) Java SDK when a Java application needs to expose tools, resources, prompts, or other MCP capabilities to an AI client. The core SDK supports STDIO, SSE, and Streamable HTTP server transports, with synchronous and asynchronous programming models. As of September 29, 2026, the documentation lists v2.0.1 as the current stable release; 2.1.0-SNAPSHOT is separate and should not be used as a production dependency without a deliberate reason.

What the MCP Server Java SDK provides

MCP is a protocol for connecting AI applications with external context and actions. The Java SDK is a library, not a hosted server: you add it to your application, register capabilities, choose a transport, and run that application wherever your deployment requires.

The server side of the SDK can expose:

  • Tools that clients discover and invoke with structured arguments.
  • Resources and resource templates addressed by URIs.
  • Prompts and prompt requests.
  • Capability negotiation, completions, notifications, structured logging, and server-side protocol operations.
  • Multiple concurrent client connections, depending on the selected transport and deployment.

Capabilities are configurable. Registering the SDK does not automatically publish every feature; advertise only what your server actually implements.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a version before writing code

The stable documentation selector showed 2.0.1 on September 29, 2026. The changelog dates that release to August 19, 2026. The 2.0.x line is active development, while 1.1.x (1.1.4) and 0.18.x (0.18.4) are security-patches-only lines according to the project changelog.

Version 2.0.0 is a major release and includes breaking changes. If you are upgrading from 1.x, use the project’s v2 migration guide rather than copying 1.x examples into a 2.x build. The 2.x line is described by the project as tracking the November 25, 2025 MCP specification and as continuously checked against the MCP conformance suite. Those are project statements, not a guarantee that every application is automatically conformant.

Maven dependency

The convenience core artifact documented by the project is io.modelcontextprotocol.sdk:mcp. Pin the release you have selected and use the matching BOM or dependency documentation for JSON modules and transitive versions:

<dependency>
  <groupId>io.modelcontextprotocol.sdk</groupId>
  <artifactId>mcp</artifactId>
  <version>2.0.1</version>
</dependency>

Check the release documentation before copying this into a build: module names and APIs can change across major versions. The project separates core, JSON implementations, BOM, tests, and the convenience artifact. Its documented convenience setup uses Jackson 3; Jackson 2 and Jackson 3 modules are available as separate choices.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select the server transport

Transport Best fit Important qualification
STDIO A local desktop client launches your server as a child process. Keep stdout reserved for protocol messages; send diagnostics to stderr.
Streamable HTTP A remotely reachable service, gateway, or shared deployment. The 2.x roadmap emphasizes this transport.
SSE Existing deployments that still require the older server-sent-events pattern. It appears in the core transport list, but the 2.x roadmap says SSE is deprecated in favor of Streamable HTTP.

The core SDK documents these transports without requiring an external web framework. Spring-specific WebFlux and WebMVC transports moved to Spring AI 2.0+ and are no longer shipped by this SDK. If your application is already a Spring Boot service, evaluate Spring AI’s MCP integration instead of assuming the core artifact supplies Spring starters.

Build a minimal Java server

The exact builder signatures are release-sensitive, so use the v2 server guide for the final imports and method names. The following shape shows the implementation decisions: create server metadata, advertise only the capabilities you implement, register a tool with a typed request handler, and attach a transport.

import io.modelcontextprotocol.server.McpServer;
import io.modelcontextprotocol.server.McpSyncServer;
import io.modelcontextprotocol.spec.McpSchema;

public final class DemoServer {
  public static void main(String[] args) {
    var info = new McpSchema.Implementation("demo-java-server", "1.0.0");

    var capabilities = McpSchema.ServerCapabilities.builder()
        .tools(true)
        .resources(true)
        .prompts(true)
        .logging(true)
        .build();

    McpSyncServer server = McpServer.sync(info)
        .capabilities(capabilities)
        .build();

    // Register tool, resource and prompt specifications here using
    // the v2 server-guide builders and CallToolRequest handlers.
    // Start the selected STDIO or HTTP transport after registration.
  }
}

For a real tool, define its name, description, JSON input schema, and handler. The guide recommends handlers that receive a CallToolRequest; return structured content and an explicit error result when validation or the downstream operation fails. Do not treat a tool description as authorization: enforce identity, permissions, rate limits, and input validation in your application.

Tool design checklist

  • Give each tool a stable, specific name.
  • Describe side effects and required arguments in the tool metadata.
  • Validate arguments before calling databases, filesystems, networks, or shell commands.
  • Return machine-readable content where the client needs to parse a result.
  • Make retries safe or document when an operation is not idempotent.
  • Log failures without leaking secrets or untrusted prompt content.

Configure resources, prompts, and completions

Resources

Resources expose read-oriented context through URI addresses. Resource templates are useful when the URI contains an identifier, such as customer://{id}. Decide whether clients may subscribe to updates and whether list-change notifications are appropriate; these flags are part of capability configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prompts

Prompt templates let a client request a structured conversation starter from your server. Keep templates narrowly scoped and version them when changing required arguments, because clients may cache names and descriptions.

Completions

Completion handlers can suggest valid values for prompt or resource arguments. They are useful for identifiers, environments, and operation names, but should enforce the same access controls as the underlying resource.

Notifications and logging

Enable structured logging and notifications deliberately. A noisy server can overwhelm a client, while missing notifications can leave a long-lived client with stale state. Never write protocol traffic or arbitrary debug output to STDOUT in a STDIO deployment.

Reactive and synchronous programming models

The SDK’s public APIs use Reactive Streams, with Project Reactor internally, and provide a synchronous facade for blocking applications. Choose the synchronous facade when your existing service is request-per-thread and the operations are naturally blocking. Use the asynchronous APIs when you need controlled concurrency, streaming work, or integration with a reactive pipeline.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The repository describes JDK HttpClient as its default client transport and includes a servlet-based server implementation in core. Those defaults do not replace the transport choices above; verify the selected release’s reference documentation when combining the SDK with an application server.

Security and deployment boundaries

Authorization is not a complete built-in security system in the SDK. The project describes pluggable authorization hooks, which means your application or framework must supply authentication, authorization policy, secret storage, TLS termination, and audit controls.

  • For STDIO, restrict who can launch the process and what files, environment variables, and network destinations it can access.
  • For HTTP, terminate TLS appropriately, authenticate clients, authorize each tool and resource, and apply request-size and rate limits.
  • Do not pass an API key, cookie, or bearer token into a tool description or prompt.
  • Run dangerous tools in a constrained identity or isolated worker.
  • Set bounded HTTP and STDIO read limits. Version 2.0.1 specifically added configurable maximum read sizes.

Testing strategy

Test protocol behavior separately from business logic. Unit-test tool handlers with valid, missing, malformed, and unauthorized arguments. Then run an MCP client against each transport and verify initialization, capability negotiation, listing, invocation, resource reads, prompt retrieval, errors, and disconnect/reconnect behavior.

The project says it validates against the MCP conformance test suite and references suite version 0.1.15. Treat that as the project’s validation statement; your deployment still needs integration, security, load, and failure testing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

Client cannot initialize

Confirm that client and server speak compatible protocol versions and that the server advertises capabilities matching its registered handlers. A 1.x example copied into a 2.x build is a common source of API and negotiation errors.

STDIO client receives invalid JSON

Remove banners, logging, stack traces, and framework startup messages from STDOUT. Send diagnostics to STDERR and leave STDOUT exclusively for MCP frames.

HTTP requests hang or disconnect

Check proxy buffering, idle timeouts, TLS termination, and the selected Streamable HTTP implementation. Confirm that the client is connecting to the transport endpoint rather than a normal health-check route.

Tool appears but invocation fails

Compare the declared JSON schema with the handler’s expected fields and types. Log a redacted request, validate before side effects, and return a protocol error rather than throwing an unhandled exception.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Spring classes are missing

Core SDK 2.x no longer ships the Spring WebFlux/WebMVC transports. Use Spring AI 2.0+ integration when you need those framework transports, or use the core SDK’s documented non-Spring transport.

Dependency conflicts involving Jackson

Use the selected release’s BOM and choose one supported JSON module family. Do not mix Jackson 2 and Jackson 3 artifacts casually; inspect the resolved dependency tree before deployment.

Performance, reliability, and operating cost

The SDK does not publish a universal throughput or latency number in the project materials. Performance depends on transport, serialization, downstream tools, connection count, and deployment. Measure your own workload with realistic payload sizes and concurrent clients.

For reliability, bound reads and downstream timeouts, make retries explicit, close resources on disconnect, and expose health and protocol metrics outside the MCP message stream. For cost control, cache safe read-only resources, limit expensive tools, and reject oversized arguments before invoking downstream services.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If your MCP demo or documentation project also needs clean screenshots of web pages, ScreenshotNeo provides a one-call website screenshot API. It accepts consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo documentation for the remaining capture options. Its MCP server supplies take_screenshot, get_page_info, and capture_pdf tools to Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Frequently Asked Questions

Is the MCP Java SDK a hosted service?

No. It is a library that you embed in a Java application; you operate the resulting server and choose its transport.

Should a new project use SSE?

For a new 2.x deployment, prefer Streamable HTTP for remote HTTP service use. SSE remains documented in the core transport list, but the 2.x roadmap marks it deprecated in favor of Streamable HTTP.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does the SDK provide authentication automatically?

No. Authorization hooks are pluggable. Your application or framework must implement authentication, authorization, TLS, secret handling, and operational policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.