diff --git a/client.go b/client.go index f37f4c6..672e217 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "github.com/metoro-io/mcp-golang/internal/protocol" - "github.com/metoro-io/mcp-golang/internal/tools" "github.com/metoro-io/mcp-golang/transport" "github.com/pkg/errors" ) @@ -60,7 +59,7 @@ func (c *Client) Initialize(ctx context.Context) (*InitializeResponse, error) { } // ListTools retrieves the list of available tools from the server -func (c *Client) ListTools(ctx context.Context, cursor *string) (*tools.ToolsResponse, error) { +func (c *Client) ListTools(ctx context.Context, cursor *string) (*ToolsResponse, error) { if !c.initialized { return nil, errors.New("client not initialized") } @@ -79,7 +78,7 @@ func (c *Client) ListTools(ctx context.Context, cursor *string) (*tools.ToolsRes return nil, errors.New("invalid response type") } - var toolsResponse tools.ToolsResponse + var toolsResponse ToolsResponse err = json.Unmarshal(responseBytes, &toolsResponse) if err != nil { return nil, errors.Wrap(err, "failed to unmarshal tools response") diff --git a/server.go b/server.go index 884cef7..af6f1ec 100644 --- a/server.go +++ b/server.go @@ -12,7 +12,6 @@ import ( "github.com/invopop/jsonschema" "github.com/metoro-io/mcp-golang/internal/datastructures" "github.com/metoro-io/mcp-golang/internal/protocol" - "github.com/metoro-io/mcp-golang/internal/tools" "github.com/metoro-io/mcp-golang/transport" "github.com/pkg/errors" ) @@ -630,17 +629,17 @@ func (s *Server) handleListTools(ctx context.Context, request *transport.BaseJSO } } - toolsToReturn := make([]tools.ToolRetType, 0) + toolsToReturn := make([]ToolRetType, 0) for i := startPosition; i < endPosition; i++ { - toolsToReturn = append(toolsToReturn, tools.ToolRetType{ + toolsToReturn = append(toolsToReturn, ToolRetType{ Name: orderedTools[i].Name, Description: &orderedTools[i].Description, InputSchema: orderedTools[i].ToolInputSchema, }) } - return tools.ToolsResponse{ + return ToolsResponse{ Tools: toolsToReturn, NextCursor: func() *string { if s.paginationLimit != nil && len(toolsToReturn) >= *s.paginationLimit { diff --git a/server_test.go b/server_test.go index 9f93f49..2da0c82 100644 --- a/server_test.go +++ b/server_test.go @@ -6,7 +6,6 @@ import ( "github.com/metoro-io/mcp-golang/internal/protocol" "github.com/metoro-io/mcp-golang/internal/testingutils" - "github.com/metoro-io/mcp-golang/internal/tools" "github.com/metoro-io/mcp-golang/transport" ) @@ -191,7 +190,7 @@ func TestHandleListToolsPagination(t *testing.T) { t.Fatal(err) } - toolsResp, ok := resp.(tools.ToolsResponse) + toolsResp, ok := resp.(ToolsResponse) if !ok { t.Fatal("Expected tools.ToolsResponse") } @@ -215,7 +214,7 @@ func TestHandleListToolsPagination(t *testing.T) { t.Fatal(err) } - toolsResp, ok = resp.(tools.ToolsResponse) + toolsResp, ok = resp.(ToolsResponse) if !ok { t.Fatal("Expected tools.ToolsResponse") } @@ -239,7 +238,7 @@ func TestHandleListToolsPagination(t *testing.T) { t.Fatal(err) } - toolsResp, ok = resp.(tools.ToolsResponse) + toolsResp, ok = resp.(ToolsResponse) if !ok { t.Fatal("Expected tools.ToolsResponse") } @@ -272,7 +271,7 @@ func TestHandleListToolsPagination(t *testing.T) { t.Fatal(err) } - toolsResp, ok = resp.(tools.ToolsResponse) + toolsResp, ok = resp.(ToolsResponse) if !ok { t.Fatal("Expected ToolsResponse") } diff --git a/tool_response_types.go b/tool_response_types.go index affbb36..f9e8345 100644 --- a/tool_response_types.go +++ b/tool_response_types.go @@ -144,3 +144,19 @@ type baseCallToolRequestParams struct { // Name corresponds to the JSON schema field "name". Name string `json:"name" yaml:"name" mapstructure:"name"` } + +// Definition for a tool the client can call. +type ToolRetType struct { + // A human-readable description of the tool. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // A JSON Schema object defining the expected parameters for the tool. + InputSchema interface{} `json:"inputSchema" yaml:"inputSchema" mapstructure:"inputSchema"` + + // The name of the tool. + Name string `json:"name" yaml:"name" mapstructure:"name"` +} +type ToolsResponse struct { + Tools []ToolRetType `json:"tools" yaml:"tools" mapstructure:"tools"` + NextCursor *string `json:"nextCursor,omitempty" yaml:"nextCursor,omitempty" mapstructure:"nextCursor,omitempty"` +}