From 5774b4c0ec6dbcae6a95ee3a0a259c27fc2240ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20K=C3=B6lker?= Date: Fri, 11 Apr 2025 04:07:36 +0000 Subject: [PATCH] fix(client): allow interface to be implemented The addition of the unexported `sendRequest` method prevents external packages from implmenting the `MCPClient` interface. Since it is only used by the unexported `listByPage`, create an unexported `mcpClient` interface, which embeds the exported `MCPClient` as well as the `sendRequest` method. Add build time checking that internal implementations implement the unexported interface. --- client/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/client.go b/client/client.go index cdea0201d..ba03b5828 100644 --- a/client/client.go +++ b/client/client.go @@ -108,13 +108,17 @@ type MCPClient interface { // OnNotification registers a handler for notifications OnNotification(handler func(notification mcp.JSONRPCNotification)) +} + +type mcpClient interface { + MCPClient sendRequest(ctx context.Context, method string, params interface{}) (*json.RawMessage, error) } func listByPage[T any]( ctx context.Context, - client MCPClient, + client mcpClient, request mcp.PaginatedRequest, method string, ) (*T, error) {