Skip to content

Commit 6b923f6

Browse files
authored
fix(client): allow interface to be implemented (#135)
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.
1 parent cc777fc commit 6b923f6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

client/client.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,17 @@ type MCPClient interface {
108108

109109
// OnNotification registers a handler for notifications
110110
OnNotification(handler func(notification mcp.JSONRPCNotification))
111+
}
112+
113+
type mcpClient interface {
114+
MCPClient
111115

112116
sendRequest(ctx context.Context, method string, params interface{}) (*json.RawMessage, error)
113117
}
114118

115119
func listByPage[T any](
116120
ctx context.Context,
117-
client MCPClient,
121+
client mcpClient,
118122
request mcp.PaginatedRequest,
119123
method string,
120124
) (*T, error) {

0 commit comments

Comments
 (0)