About Client Support #14
Replies: 1 comment 3 replies
|
What do you think about how the client support should be designed? Does it need to be annotation-driven? In fact, I think the official SDK's design is also easy to use, but when I use it, I need to handle a lot of classes, so I must understand them. Also, the documentation in the code is too sparse to understand what I can do and what I should do. I envision a client design approach based on interface proxy + annotation-driven, where the core idea is that users declare remote MCP operations using interfaces, and the SDK generates implementations via JDK dynamic proxies. For example: @McpClientApplication(host="127.0.0.1", port=8080, token="...", ...) // set connection info in code
public interface CalculatorClient {
@McpClientTool(name = "add")
int add(@McpToolParam(name = "a") int a, @McpToolParam(name = "b") int b);
@McpClientResource(uri = "system://info")
Map<String, String> getSystemInfo();
@McpClientPrompt(name = "generate-code")
String generateCode(@McpPromptParam(name = "language") String lang,
@McpPromptParam(name = "task") String task);
}or: public interface CalculatorClient extends McpClient {
Map<String, Object> params = Map.of("host", "127.0.0.1", ...); // set the connection info
// Keep it as it is
}and usage: // One-line creation, type-safe
CalculatorClient client = McpClientFactory.create(CalculatorClient.class);
int sum = client.add(3, 5);or // create method extends McpClient.create()
CalculatorClient client = CalculatorClient.create();Using this approach requires adding some new classes and annotations, which I plan to place under the package |
Uh oh!
There was an error while loading. Please reload this page.
This thread will be where I share all my ongoing development thoughts, progress updates, and any questions I have while implementing the MCP client feature. I’ll organize all content clearly here to keep our communication efficient and easy to follow.
All reactions