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 Java SDK, io.modelcontextprotocol.sdk:mcp, to build an MCP server, then choose a transport that fits how its client will connect. For a small server, configure only the capability you need, register a narrowly scoped tool, validate its inputs, and shut the server down cleanly. If the server will be reached over HTTP, plan authentication and deployment security separately; the SDK’s security hooks are not a complete authorization system.
What a Java MCP server does
A Model Context Protocol (MCP) server makes selected application functions or data available to an MCP client through protocol operations. A server can expose tools, resources, prompts, or other supported operations. It should advertise and register only the capabilities it actually implements.
The direct Java route is the official Java SDK. Its repository describes it as “The official Java SDK for Model Context Protocol servers and clients.” The SDK provides synchronous and asynchronous server APIs, and supports more than one transport. Those choices affect how the process starts, how clients connect, and how the application is deployed.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Choose the SDK dependency and version
For a small Maven or Gradle project, begin with the convenience artifact io.modelcontextprotocol.sdk:mcp. The official quickstart says it combines core functionality with Jackson 3 JSON support. If you need to choose your JSON implementation, the documented alternatives include mcp-core and mcp-json-jackson2 for Jackson 2.x.
Keep related SDK artifacts aligned with the SDK BOM rather than independently selecting versions. The quickstart shows a BOM example using version 2.0.0, but explicitly directs users to use the latest version available from Maven Central. The SDK documentation’s version selector lists v2.0.1 as released and displays 2.1.0-SNAPSHOT separately. These are not interchangeable claims: the sample BOM coordinate is not identified as the latest release. Check Maven Central and the compatibility documentation when choosing a version to pin.
No JDK compatibility matrix is established here, so verify the requirements for the release you select instead of assuming a Java baseline from an older example. When using multiple SDK artifacts, use the BOM to reduce accidental version mismatches.
Select a transport for the client and deployment
| Transport | How the client connects | When it fits | Important consideration |
|---|---|---|---|
| STDIO | The host launches the server as a process and communicates over standard input and output. | A client that manages a local server process. | Keep standard output reserved for protocol messages; send diagnostics through a logging channel. |
| Streamable HTTP | The server is hosted at an HTTP endpoint. | A service intended to be reached over HTTP. The SDK’s Servlet example configures /mcp. |
Decide authentication, authorization, and deployment boundaries as part of the application. |
| SSE | An HTTP-with-SSE transport documented by the SDK. | Compatibility with a client or deployment that requires it. | The server reference labels this transport “Legacy.” Check current client and protocol compatibility before choosing it for a new service. |
The SDK’s core documentation covers STDIO, SSE, and Streamable HTTP. Servlet support is provided by the Java SDK; Spring WebFlux and WebMVC transports are separate Spring AI integrations. A process-local STDIO server and an HTTP-hosted server are different deployment models, not merely alternate settings for the same launch configuration. Similarly, the SDK’s synchronous and asynchronous APIs are distinct programming models.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Configure the server and register a tool
Start with one predictable tool that has a narrow purpose. Give it a clear name and description, define an input schema, validate input values, and return useful text or structured content. A tool should not expose broad application authority just because it is convenient to implement.
Rank #2
The official server reference shows the core shape of a synchronous server:
McpSyncServer server = McpServer.sync(transportProvider)
.serverInfo("example-server", "1.0.0")
.capabilities(ServerCapabilities.builder()
.tools(true)
.build())
.build();
server.addTool(toolSpecification);
This is an API-shape example, not a complete copy-and-run program: transportProvider and toolSpecification must be created for the selected transport and handler. The available implementation details vary with that choice; do not paste this fragment into an empty project and expect it to launch a server.
Follow the Java SDK server guide for the concrete tool-specification, schema-validation, result-content, and error-handling APIs for the SDK version you use. Keep the tool contract explicit: what it accepts, what it returns, and what happens when input is invalid or the requested operation cannot be completed.
Distinguish tool errors from server failures
An expected failure while carrying out a valid tool request—for example, a requested record not being found—should be represented as a meaningful tool-level result where the SDK’s result model supports it. A malformed request, broken transport, or server defect is a different class of failure. Preserve that distinction so clients can tell whether to correct their input, retry an operation, or report an infrastructure problem. Avoid returning stack traces or sensitive internal details as tool output.
Choose synchronous or asynchronous APIs
The Java SDK offers both McpServer.sync(...) and McpServer.async(...) server APIs. Choose based on the application’s execution model and the work the tool performs; the names alone do not imply that one is universally faster or more reliable.
With the asynchronous API, registrations return reactive results. Those results must be subscribed to or composed into the application’s lifecycle handling; creating a reactive result without arranging for it to run is not a completed operation. Whichever model you choose, include server shutdown in the application lifecycle and close the server cleanly.
Add resources and prompts only when the server needs them
Tools are not the only MCP capability. A server can also provide URI-addressed resources, resource templates, and prompts. Enable each capability in the server configuration and register its specifications only when the application has a real use for it. Advertising a capability the server does not implement creates a misleading contract for clients.
For an initial implementation, a single tool is often easier to validate than a broad collection of tools and data sources. Add resources or prompts when they solve a client-facing problem, and define their access rules with the same care as tool inputs.
Rank #4
Use Spring AI for Spring transports
If the application uses Spring, treat Spring integration as a separate choice from selecting the standalone Java SDK. Current Spring WebFlux and WebMVC MCP transports and server boot starters belong to Spring AI 2.0+, not to modules shipped by the standalone SDK. Check the Spring AI documentation for the version matching your project before copying configuration. Older examples online may reflect earlier module ownership or APIs.
Secure and operate the server
The SDK documentation describes pluggable authorization hooks and DNS rebinding protection using Host/Origin validation. Those hooks do not amount to a complete authorization system supplied by the core SDK. Apply the application’s established authentication and authorization approach, and restrict each tool to the minimum effect and data it needs.
- Validate tool inputs at the server boundary, even if the client also validates them.
- Do not expose sensitive resources or powerful operations by default.
- For STDIO, document how the host launches the process and supplies configuration. Keep protocol output separate from diagnostics.
- For HTTP, document the endpoint and its authentication requirements, and define the boundary at which the service is reachable.
- Arrange graceful shutdown and close the server as part of application termination.
Transport choice is also an operational decision. STDIO ties communication to a launched process; HTTP requires an endpoint that the intended client can reach and a security policy appropriate to that exposure. Select stateful or stateless operation according to the host and client requirements rather than treating those modes as automatically interchangeable.
Troubleshoot common implementation problems
| Symptom | Likely cause | What to check |
|---|---|---|
| The client cannot launch or connect to the server. | The client’s expected transport does not match the server’s configured transport, or the launch/endpoint details are wrong. | Confirm whether the client expects a process over STDIO or an HTTP endpoint; verify the launch configuration or endpoint path. |
| STDIO clients receive malformed protocol output. | Application logs or other text are being written to standard output. | Reserve stdout for protocol messages and route diagnostics to a logging channel. |
| A registered tool is not available to the client. | The server may not advertise the tools capability, or the tool specification may not be registered. | Check both capability configuration and tool registration in the server setup. |
| An asynchronous operation appears not to run. | A reactive result may have been created but not subscribed to or composed into lifecycle handling. | Ensure the result is actually subscribed to or composed as required by the application. |
| An old Spring example does not match current dependencies. | The example may predate the current Spring AI 2.0+ ownership of WebFlux and WebMVC transport integrations. | Use documentation matching the project’s Spring AI version. |
| Unexpected access is possible through an HTTP tool. | SDK hooks may have been mistaken for a complete authorization policy. | Integrate application authentication and authorization, narrow tool effects, and validate every input. |
| The selected dependency version cannot be resolved or conflicts with another SDK artifact. | A sample version may have been copied as if it were the current release, or artifacts may use mismatched versions. | Check current Maven Central metadata and align related SDK artifacts using the BOM. |
Or skip the browser setup
If one of your Java server’s tools needs a website screenshot, you can call ScreenshotNeo instead of setting up and maintaining a browser capture stack. It is a screenshot API and MCP server; it is not a Java MCP SDK or a replacement for implementing your application’s own server.
Best Value
For example, this cURL request captures a page as WebP:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Use the ScreenshotNeo API documentation for request details. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
Recommended Free Tools
Frequently Asked Questions
Is the Java SDK the same thing as Spring AI’s MCP integration?
No. The standalone Java SDK and Spring AI integrations are separate routes; current Spring WebFlux and WebMVC transports are provided through Spring AI 2.0+.
Can an MCP server expose only tools?
Yes. Configure and register only the capabilities the application implements; resources and prompts are optional.
Quick Recap
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.

