Large Language Models (LLMs) are only as powerful as the tools they can access. While internal tools are easy to wire directly into a Java application, the real challenge begins when you need your AI agents to reach out — to call REST APIs, query databases, invoke third-party services, or even communicate with other AI systems.
Hardcoding every external dependency creates a fragile architecture. Every new tool requires code changes, new dependencies, and new configurations. This is where the Model Context Protocol (MCP) comes in.
In this article, we explore how Solon AI v4.0.5 implements MCP to solve one of the hardest problems in AI engineering: How do we let agents access external tool ecosystems in a standardized, reusable, and secure way?
The Problem: Tool Sprawl in AI Applications
Imagine you're building a financial analysis agent. Initially, it needs access to:
- Stock price APIs
- Company financial report databases
- Real-time news feeds
- Regulatory filing systems
- Risk scoring models
If you hardcode all of these, every new tool requires:
- New Maven dependencies
- New service classes
- New tool registration code
- New configuration properties
- New error handling logic
And if you want to share these tools across different applications or with other teams? You'd have to copy-paste entire codebases or rebuild everything from scratch.
This is exactly the problem MCP solves. By adopting an open protocol, tools become composable, shareable, and reusable — just like Linux executables or npm packages.
What is MCP?
Model Context Protocol (MCP) is an open standard for connecting AI applications to external data sources and tools. Think of it as USB-C for AI agents — a universal connector that lets any client talk to any server using a common language.
The protocol defines three core primitives:
-
Tools: Functions the agent can call (like
get_weather(city)) -
Resources: Data the agent can read (like
weather://forecast/{city}) -
Prompts: Reusable template instructions (like
summarize_report)
Originally developed by Anthropic and now maintained by the MCP Open Source Project, the protocol has gained massive adoption. As of 2025, over 1,200 MCP servers exist across 30+ categories — from file systems and databases to email, calendars, and code repositories.
Solon AI's MCP Integration
Solon AI v4.0.5 adds deep MCP support through the solon-ai-mcp module. Let's look at how it works.
Server Side: Exposing Tools via MCP
To expose a Java service as an MCP server, you only need to:
- Add the
solon-ai-mcpdependency - Annotate your tool class with
@McpServerEndpoint - Use
@ToolMappingfor tools,@ResourceMappingfor resources
Here's a complete example:
@McpServerEndpoint(
channel = McpChannel.STREAMABLE,
mcpEndpoint = "/mcp/weather"
)
public class WeatherTool {
@ToolMapping(description = "Get current weather for a city")
public String getWeather(@Param String city) {
// Call external weather API
return fetchWeatherData(city);
}
@ResourceMapping(
uri = "weather://forecast/{city}",
description = "Get weather forecast"
)
public String getForecast(@Param String city) {
return buildForecastJson(city);
}
}
That's it. Solon AI automatically:
- Registers the tools and resources with the MCP server
- Handles JSON-RPC message serialization/deserialization
- Manages the transport layer (HTTP, SSE, or Stdio)
- Supports the
notifications/tools/list_changedevent for dynamic updates
Client Side: Using Remote Tools as Local Beans
The real power shines on the client side. Once a tool is exposed via MCP, any Solon AI agent can use it as if it were a local bean:
@Configuration
public class MyAppConfig {
@Bean
public McpTalentClient weatherClient(McpClientProvider provider) {
return new McpTalentClient(provider);
}
@Bean
public ReActAgent agent(McpTalentClient weatherTool) {
return ReActAgent.builder()
.system("You are a travel assistant...")
.defaultToolAdd(weatherTool) // Inject MCP tool
.build();
}
}
The McpTalentClient acts as a bridge between your agent and the remote MCP server. When the agent calls getWeather(), the call is routed over the network to the server, executed, and the result is returned — all transparently.
Transport Options
Solon AI supports four transport channels via McpChannel:
| Channel | Use Case |
|---|---|
STDIO |
Local CLI tools, subprocess invocation |
SSE |
Long-running server connections |
STREAMABLE |
Modern HTTP-based (recommended) |
STREAMABLE_STATELESS |
Stateless HTTP, no session management |
For production systems, STREAMABLE is recommended because it provides both HTTP/2 multiplexing and session management.
Real-World Use Case: Multi-Source Financial Analysis
Let's build a practical example. Imagine a compliance agent that needs to:
- Query a company database for financial records
- Call a risk scoring API
- Fetch regulatory updates from an external feed
- Generate a compliance report
With MCP, each data source becomes a separate MCP server that can be developed, deployed, and updated independently:
# app.yml
solon:
ai:
mcp:
client:
financial-db:
channel: streamable
url: http://localhost:8081/mcp
risk-api:
channel: streamable
url: http://localhost:8082/mcp
regulatory-feed:
channel: streamable
url: http://localhost:8083/mcp
The compliance agent doesn't know (or care) which server provides which tool. It just declares what it needs:
@ToolMapping(description = "Query company financials")
public FinancialData queryFinancials(@Param String ticker);
@ToolMapping(description = "Calculate risk score")
public RiskScore calculateRisk(@Param FinancialData data);
@ToolMapping(description = "Fetch regulatory updates")
public List<String> getRegulatoryUpdates(@Param String category);
When the agent runs, it automatically discovers and calls the appropriate tools. If you need to update the risk API, you only change the server code — the agent remains untouched.
Advanced: Stateful vs Stateless Servers
Solon AI v4.0.5 supports both stateful and stateless MCP servers:
-
Stateful servers (
McpServerHost): Maintain connection state, support streaming, ideal for long-running services -
Stateless servers (
StatelessMcpServerHost): No connection state, simpler deployment, better for microservice architectures
For most enterprise applications, stateless servers are preferred because they're easier to scale horizontally.
Security Considerations
When exposing tools via MCP, security is paramount:
- Authentication: Use HTTP headers or JWT tokens to authenticate clients
- Authorization: Implement role-based access control at the tool level
- Input Validation: Always validate tool parameters to prevent injection attacks
- Rate Limiting: Protect backend services from abuse
- Audit Logging: Log all tool calls for compliance
Solon AI's McpPlugin supports custom ServerTransportSecurityValidator implementations for advanced security scenarios.
The Bigger Picture
MCP is not just a technical solution — it's a cultural shift in how we build AI applications. Instead of every developer reinventing the wheel for each new tool, we now have a shared ecosystem where:
- Tool creators can build once and deploy everywhere
- Agent developers can discover and compose tools without knowing implementation details
- Enterprise IT can manage tool access centrally with consistent security policies
As the MCP ecosystem grows, we'll see more specialized servers emerge — from code review tools to database query optimizers to legal document reviewers. The possibilities are limited only by our imagination.
Getting Started
To add MCP support to your Solon AI project:
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-ai-mcp</artifactId>
<version>4.0.5</version>
</dependency>
Then follow the patterns shown in this article. The full source code examples are available in the Solon AI GitHub repository.
Conclusion
MCP is solving one of the most fundamental challenges in AI engineering: How do we make tools composable and reusable?
By implementing MCP support, Solon AI gives you:
- Standardized integration — connect to any MCP server using a common protocol
- Tool reuse — build once, deploy everywhere
- Security — enterprise-grade authentication and authorization
- Flexibility — support for multiple transport channels
The future of AI is not about building bigger models — it's about connecting smarter tools. And MCP is the protocol that makes that possible.
Ready to explore? Check out the Solon AI documentation and join the MCP community.
Top comments (0)