Free tools Windows power users keep installed
One-click scans. No signup required.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Yes—you can build an MCP server in Java with either the framework-agnostic MCP Java SDK or Spring AI. For a minimal Spring application, expose a service method with @McpTool, add the matching Spring AI MCP server starter, and choose a transport such as STDIO, SSE, or Streamable HTTP. This guide shows a runnable weather-tool example, explains dependency and transport choices, and covers deployment problems that commonly affect Java MCP servers.
What a Java MCP server does
The Model Context Protocol (MCP) standardizes how AI applications discover and use external capabilities. An MCP server can expose callable tools, URI-based resources, prompt templates, completions, structured logging, and protocol operations. Clients negotiate protocol versions and capabilities, discover available tools, and invoke them through the selected transport.
The official Java SDK describes the server as “a foundational component in the Model Context Protocol (MCP) architecture that provides tools, resources, and capabilities to clients.” In practical terms, your Java code supplies operations such as weather lookup, database access, document retrieval, or business actions while the MCP client handles the AI-facing connection.
Choose the Java implementation
Spring AI
Spring AI is the shortest route when your application already uses Spring Boot. Its annotations turn ordinary Spring services into MCP tools, and its starters provide transport integrations for WebMVC, WebFlux, STDIO, SSE, Streamable HTTP, and stateless Streamable HTTP.
Official Java MCP SDK
The framework-agnostic SDK provides synchronous and asynchronous client and server implementations. The core io.modelcontextprotocol.sdk:mcp convenience module includes the standard transports without requiring an external web framework. You can instead use mcp-core with the appropriate Jackson 2 or Jackson 3 modules when you need finer dependency control.
Coordinates and package locations are release-sensitive. Spring AI 2.0 moved the Spring-specific mcp-spring-webflux and mcp-spring-webmvc artifacts into the org.springframework.ai group. Use the BOM and coordinates for the release line already used by your project rather than copying an older tutorial unchanged.
Minimal Spring AI MCP server
The following service follows the official weather example. It returns a deterministic value so that the protocol wiring is easy to verify; replace the method body with a real weather client in production.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
package com.example.mcp;
import org.springframework.ai.mcp.annotation.McpTool;
import org.springframework.ai.mcp.annotation.McpToolParam;
import org.springframework.stereotype.Service;
@Service
public class WeatherService {
@McpTool(description = "Get current temperature for a location")
public String getTemperature(
@McpToolParam(description = "City name", required = true)
String city) {
return String.format("Current temperature in %s: 22°C", city);
}
}
@Service registers the class with Spring. @McpTool publishes the method as a discoverable MCP tool, including its description. @McpToolParam supplies the parameter description and marks city as required. Keep descriptions precise: clients use them to decide when a tool is appropriate and how to form arguments.
Dependency and configuration
Add the Spring AI MCP server starter that matches your transport. For a WebMVC Streamable HTTP server, the current starter name is:
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
</dependency>
Manage Spring AI versions with the matching BOM in your build. The exact version is intentionally not hard-coded here because coordinates and package locations vary by release line.
Rank #2
Set Streamable HTTP in application.properties:
spring.ai.mcp.server.protocol=STREAMABLE
Start the Spring Boot application. The starter creates the MCP endpoint and exposes getTemperature during tool discovery. The weather method itself is illustrative; the official example has not been presented as a runtime benchmark.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Complete transport decision: STDIO, SSE, or Streamable HTTP
| Transport | Best fit | Important behavior | Spring options |
|---|---|---|---|
| STDIO | Local process integration | The MCP client launches or connects to the server process through standard input and output. Do not write diagnostic text to standard output because it can corrupt protocol messages. | STDIO starter |
| SSE | HTTP clients and browser/proxy-friendly streaming | Uses server-sent events for streaming over HTTP. Existing HTTP infrastructure can be useful, but verify proxy buffering and connection timeouts. | WebMVC SSE or WebFlux variants |
| Streamable HTTP | Modern bidirectional HTTP sessions | Designed for current HTTP-based MCP communication and can be stateful or stateless depending on the server setup. | WebMVC Streamable HTTP, WebFlux Streamable HTTP, or stateless Streamable HTTP |
Choose STDIO when one client owns the server process. Choose SSE when compatibility with HTTP streaming and existing proxy infrastructure is the priority. Choose Streamable HTTP for a network service that needs modern HTTP sessions. Then decide whether state should be retained: stateful servers preserve session context, while stateless Streamable HTTP is easier to scale horizontally because requests do not depend on a particular instance.
Using the framework-agnostic Java SDK
If Spring is not part of your application, start with the io.modelcontextprotocol.sdk:mcp convenience module. It supplies server implementations and the STDIO, SSE, and Streamable HTTP transports. The quickstart also documents a lower-level arrangement using mcp-core plus Jackson 2 or Jackson 3 modules.
Use the SDK when you need direct control over connection management, synchronous versus asynchronous execution, capability negotiation, or a non-Spring runtime. Use Spring AI when dependency injection, Boot configuration, and annotation-based tool registration are more valuable than minimal framework overhead. In either case, import a BOM or otherwise pin a coherent set of MCP and Jackson versions.
Build a useful tool instead of a demo constant
Validate inputs
Reject blank locations and malformed identifiers before calling downstream services. A required MCP parameter prevents omission, but it does not validate business rules.
Recommended Free Tools
Return stable, model-friendly output
Use predictable field names and units. If a tool returns JSON, keep the schema stable and document nullable fields. For a text result, include the location and unit explicitly rather than relying on context.
Keep side effects explicit
Read-only tools such as weather lookup are safer defaults. For tools that create, delete, or purchase resources, describe the side effect and require the confirmation policy expected by your client.
Handle concurrency
The SDK supports concurrent connection management. Ensure downstream clients, connection pools, and rate limits are sized for concurrent tool calls; do not assume that one MCP session means one request at a time.
Testing and observing the server
- Start the application with the selected transport and confirm that the process remains alive.
- Connect an MCP client and run tool discovery. Verify that the tool name, description, required parameter, and input schema appear as expected.
- Invoke
getTemperaturewith a normal city name and with an empty value. The first should return the formatted temperature; the second should be rejected by your validation layer. - Exercise a client reconnect. For stateful HTTP, verify that session behavior matches your design; for stateless HTTP, verify that any request can reach any instance.
- Send logs to a proper logger. With STDIO, keep protocol traffic on standard output and diagnostics on standard error or another configured sink.
Troubleshooting common failures
The tool does not appear during discovery
Confirm the class is under Spring component scanning, the method has @McpTool, and the MCP starter matches your Spring AI release. A package moved between release lines can compile differently or fail to register.
Dependency resolution fails
Check that all Spring AI artifacts use the same BOM and that you have not mixed pre-2.0 coordinates with 2.0-era coordinates. For the standalone SDK, use the documented mcp module or align mcp-core and Jackson modules explicitly.
The client connects but receives malformed messages
This is commonly caused by writing banners, debug output, or stack traces to STDIO. Redirect diagnostics away from the protocol stream and inspect the client/server logs separately.
HTTP streaming stops behind a proxy
Check proxy buffering, idle timeouts, connection limits, and any gateway rule that assumes a short request/response cycle. SSE and Streamable HTTP both require infrastructure that permits long-lived streaming connections.
Sessions behave inconsistently across instances
A stateful transport requires session affinity or shared session state. If you do not need retained state, use the stateless Streamable HTTP variant and keep tool requests self-contained.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #4
A tool call hangs
Inspect downstream HTTP timeouts, database pool exhaustion, and blocking work on event-loop threads when using WebFlux. Add bounded timeouts and return a clear MCP error rather than leaving the connection open indefinitely.
Performance, reliability, and security considerations
No authoritative documentation in this guide establishes a numeric throughput or latency figure, so size capacity with measurements from your own workload. Profile tool execution, downstream calls, serialization, and concurrent sessions separately. Cache only data whose freshness requirements permit it.
- Set timeouts for every remote dependency.
- Limit concurrency and apply back-pressure where downstream systems require it.
- Authenticate HTTP deployments at the edge or in the application, and restrict tools to the capabilities each client needs.
- Validate all tool arguments; MCP discovery metadata is not a substitute for authorization.
- Record tool name, duration, outcome, and correlation information without logging secrets.
- For stateful deployments, plan session storage and failover before adding replicas.
Or skip the browser setup
If your MCP tools need website screenshots, you can avoid managing browser automation with ScreenshotNeo. It accepts one GET request and returns PNG, JPEG, WebP, or PDF. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response reports the result in X-Page-Verdict and X-Billed headers.
Use the API from Java or any MCP tool implementation with this cURL request (see the ScreenshotNeo API documentation):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Equivalent 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)
Equivalent 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}`);
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Features include full-page lazy-image capture, CSS-selector element capture, dark mode, device presets, custom viewport and retina scale, PDF controls, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable cache TTL, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. The parameter names used by other screenshot APIs also work for easier migration.
The Free plan includes 1,000 screenshots each month without a card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account.
FAQ
Can one Java MCP server expose both tools and resources?
Yes. The MCP model includes tools, URI-based resources, prompt templates, completions, and logging; implement the capabilities your client and application actually require.
Best Value
Should I use synchronous or asynchronous Java APIs?
Use synchronous APIs for simple, bounded operations. Prefer asynchronous implementations when tool calls involve high-latency I/O or many concurrent connections, provided your downstream clients support non-blocking operation.
Is Streamable HTTP always stateful?
No. Spring AI provides both stateful and stateless Streamable HTTP variants. Select based on whether requests need retained session context.
Can an existing Spring MVC application add MCP later?
Usually, yes: add the matching Spring AI MCP server starter, register annotated services, configure the protocol, and verify that your existing security and proxy configuration permits the chosen transport.
Frequently Asked Questions
Can one Java MCP server expose both tools and resources?
Yes. MCP supports tools, URI-based resources, prompt templates, completions, and logging; implement only the capabilities your client needs.
Should I use synchronous or asynchronous Java APIs?
Synchronous APIs suit bounded operations; asynchronous APIs are better for high-latency I/O or many concurrent connections when downstream clients are non-blocking.
Is Streamable HTTP always stateful?
No. Spring AI offers stateful and stateless Streamable HTTP variants.
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.

