@@ -41,21 +41,24 @@ func ConnectHTTP(ctx context.Context, url string, headers map[string]string) (*M
4141
4242// initialize performs the MCP initialize handshake.
4343func (c * McpClient ) initialize (ctx context.Context ) error {
44- params , _ := json .Marshal (map [string ]interface {}{
44+ params , err := json .Marshal (map [string ]interface {}{
4545 "protocolVersion" : "2024-11-05" ,
4646 "capabilities" : map [string ]interface {}{},
4747 "clientInfo" : map [string ]interface {}{
4848 "name" : "iteragent" ,
4949 "version" : "0.1.0" ,
5050 },
5151 })
52+ if err != nil {
53+ return fmt .Errorf ("marshal initialize params: %w" , err )
54+ }
5255 req := JsonRpcRequest {
5356 JSONRPC : "2.0" ,
5457 Method : "initialize" ,
5558 Params : params ,
5659 }
57- _ , err := c .Transport .Send (ctx , req )
58- return err
60+ _ , sendErr := c .Transport .Send (ctx , req )
61+ return sendErr
5962}
6063
6164// ListTools returns the list of tools advertised by the MCP server.
@@ -82,10 +85,13 @@ func (c *McpClient) ListTools(ctx context.Context) ([]Tool, error) {
8285
8386// CallTool invokes a tool by name with the given arguments.
8487func (c * McpClient ) CallTool (ctx context.Context , name string , args map [string ]interface {}) (* CallToolResult , error ) {
85- paramsRaw , _ := json .Marshal (map [string ]interface {}{
88+ paramsRaw , err := json .Marshal (map [string ]interface {}{
8689 "name" : name ,
8790 "arguments" : args ,
8891 })
92+ if err != nil {
93+ return nil , fmt .Errorf ("marshal call params: %w" , err )
94+ }
8995 req := JsonRpcRequest {
9096 JSONRPC : "2.0" ,
9197 Method : "tools/call" ,
0 commit comments