There are three communication methods for MCP:
aisle | illustrate | Remark |
---|---|---|
stdio | Local in-process communication | existing |
sse http | Remote http communication | existing |
streamable http | Remote http communication | (MCP has just passed the decision, mcp-java-sdk has not been implemented yet) |
It can also be divided into two categories:
- Local inter-process communication
- Remote communication (such as for front-end use, or for remote interfaces).
At present, the industry has accumulated the largest stdio mcp-server. There are also open source projects that provide proxy conversion, such as: mcpo, mcp-proxy, etc. If it is Java, you can use solon-ai-mcp to develop similar agents.
<dependency>
<groupId></groupId>
<artifactId>solon-ai-mcp</artifactId>
<version>3.2.1-M3</version>
</dependency>
There are two configuration methods that can be borrowed (or can be built with manual cabinet):
1. Load using the classic mcpServers configuration format
This configuration format is currently very common for mcp proxy. This configuration will also be provided by various projects of stdio mcp-server. Add the sample configuration (or find a mcp-server to copy), we copied a copy from a project in gitee and named itmcp/mcpServers.
:
{
"mcpServers": {
"gitee": {
"command": "mcp-gitee-ent",
"env": {
"GITEE_ENT_API_BASE": "/enterprises",
"GITEE_ENT_MCP_ACCESS_TOKEN": "<your mcp ent access token>",
}
}
}
}
solon-ai-mcp provides a quick way to parse this configuration format directly. Here is an example of creating a proxy server:
@McpServerEndpoint(sseEndpoint = "/mcp/proxy/gitee")
public class McpServerTool implements ToolProvider {
McpClientToolProvider toolProvider = McpClientToolProvider
.fromMcpServers("classpath:mcp/mcpServers.")
.get("gitee")
@Override
public Collection<FunctionTool> getTools() {
return ();
}
}
The mcpServers configuration supports multi-service configuration, so it will be a map after parsing. In principle, we load mcpServers using McpClientToolProvider and provide it as a tool to output McpServerEndpoint, forming a proxy effect.
2. Use yaml format to configure loading
This specification requires reference to the corresponding McpClientProperties entity properties. Add the mcp-client configuration in the configuration.
:
mcp:
client:
gitee: # McpClientProperties Entity Properties
channel: "stdio"
serverParameters:
command: "mcp-gitee-ent"
env:
GITEE_ENT_API_BASE: "/enterprises"
GITEE_ENT_MCP_ACCESS_TOKEN: "<your mcp ent access token>"
Create a proxy server
@McpServerEndpoint(sseEndpoint = "/mcp/proxy/gitee")
public class McpServerTool implements ToolProvider {
@Inject("${}") //Configuration, you can directly inject it
McpClientToolProvider toolProvider;
@Override
public Collection<FunctionTool> getTools() {
return ();
}
}
3. You can also reverse proxy
In fact, we can also proxy sse mcp-server to output in stdio:
@McpServerEndpoint(channel = )
public class McpServerTool implements ToolProvider {
McpClientToolProvider sseToolProvider = ()
.apiUrl("http://localhost:8081/mcp/sse")
.build();
@Override
public Collection<FunctionTool> getTools() {
return ();
}
}
After packaging, it can be configured through mcpServers and used by other tools:
{
"mcpServers": {
"demo1": {
"command": "java",
"args": ["-jar", "/demo-mcp-stdio/target/"]
}
}
}
If it is java, you can also use solon-ai-mcp. Example:
McpClientToolProvider mcpClient = ()
.channel() // means to use stdio
.serverParameters(("java")
.args("-jar", "/demo-mcp-stdio/target/")
.build())
.build();
4. Summary
Solon AI MCP can also be used to develop MCP Proxy! Especially in the Java environment, we also support java8, java11, java17, java21, and java24.