Solon's Streamlined MCP Server Development

The AI tooling ecosystem is rapidly evolving, with MCP (Model Context Protocol) emerging as a crucial standard. Often compared to "the USB-C for AI," MCP standardizes how AI models interact with external tools and data sources. However, building an MCP server from scratch using the official SDK can be a complex and time-consuming process. Developers typically need to manually configure transports, handle capability negotiation, and define tool specifications. This overhead can be a significant barrier, especially for quick prototyping or simple integrations.

Solon, a modern Java framework, offers a dramatically simplified approach. By leveraging the @McpServerEndpoint annotation, developers can define an entire MCP server within a single annotated class. This approach eliminates much of the boilerplate code typically associated with MCP server implementation, allowing for rapid development and deployment of AI-powered services.

Building a Basic MCP 'Hello World' Server

To illustrate Solon's efficiency, let's walk through building a minimal MCP server. This server will expose a single tool named hello. The setup will be as follows:

  • The server will listen on port 8080.
  • It will expose an MCP endpoint at the /mcp path.
  • It will utilize the STREAMABLE transport, which is the modern and recommended MCP protocol.
  • The server will provide a simple hello tool that returns a greeting.

This streamlined process stands in stark contrast to the manual configuration required by other SDKs, which often involves dozens of lines of code just to establish basic connectivity and define a single tool.

The Solon Codebase

Creating this server with Solon is remarkably concise. The core of the implementation involves a single Java class annotated with @McpServerEndpoint. This annotation signals to Solon that this class will serve as the entry point for our MCP server.

Within this class, we define the methods that will act as our MCP tools. For our 'Hello World' example, we need a method that implements the hello tool. This method will accept a name as input and return a personalized greeting. Solon's framework automatically handles the underlying MCP protocol details, such as request parsing, tool dispatching, and response serialization.

The @McpServerEndpoint annotation takes several parameters to configure the server's behavior. These include the port number (port = 8080), the context path for the MCP endpoint (path = "/mcp"), and the transport protocol to use (transport = Transport.STREAMABLE). By setting these parameters, Solon configures the server's network listeners and communication protocols automatically.

Here's a conceptual look at the Solon code:


import org.no.solon.annotation.McpServerEndpoint;
import org.no.solon.mcp.Transport;

@McpServerEndpoint(port = 8080, path = "/mcp", transport = Transport.STREAMABLE)
public class HelloWorldMcpServer {

    @McpTool("hello") // Declares this method as the 'hello' tool
    public String sayHello(String name) {
        return "Hello, " + name + "!";
    }

    // Other MCP tools can be defined here
}

This snippet encapsulates the entire server logic. The @McpTool("hello") annotation marks the sayHello method as the implementation for the 'hello' tool, making it discoverable and callable via the MCP protocol. The method signature public String sayHello(String name) clearly defines the tool's input (a String named name) and its output (a String).

The magic happens behind the scenes. Solon inspects the @McpServerEndpoint and @McpTool annotations at runtime, dynamically setting up the necessary network infrastructure, protocol handlers, and tool routing logic. This drastically reduces the developer's burden, allowing them to focus on the core business logic of their AI tools rather than the intricacies of the communication protocol.

Running and Testing the Server

To run this Solon-based MCP server, you would typically integrate it into a Solon application context. If you're using Solon's Maven or Gradle plugins, setting up a basic project is straightforward. Once the application is running, the MCP server will be accessible at http://localhost:8080/mcp.

Testing the hello tool can be done using any MCP-compatible client. For instance, you could use a simple cURL command or a dedicated MCP client library. A typical test request might look like this:


curl -X POST http://localhost:8080/mcp \
     -H "Content-Type: application/json" \
     -d '{"tool_name": "hello", "args": {"name": "World"}}'

The expected response from the server would be:


"Hello, World!"

This simple test demonstrates the end-to-end functionality of the Solon-built MCP server. The speed at which this can be set up and verified is a testament to Solon's design philosophy.

Why This Matters

Solon's approach to MCP server development represents a significant leap in developer experience for AI tool integration. By abstracting away the complexities of the MCP protocol and transport layer configuration, Solon empowers developers to build and deploy AI services faster. This is particularly valuable in fast-paced AI development environments where rapid iteration and experimentation are key.

The contrast between Solon's single-annotation approach and the manual wiring required by other SDKs is striking. It’s akin to comparing building a custom car engine from individual parts versus using a pre-assembled, plug-and-play engine unit. For developers focused on creating intelligent agents and integrating AI models with external systems, this reduction in boilerplate and setup time is not just convenient; it's a critical factor in accelerating innovation.

What remains to be seen is how this simplified model scales to more complex scenarios involving multiple tools, intricate capability negotiation, and advanced error handling. While 'Hello World' is a clear win, the true test will be in production-grade applications with demanding requirements. However, the foundation laid by Solon's annotation-driven approach suggests a promising future for streamlined AI service development.