29 lines
675 B
Go
29 lines
675 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
mcp "github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
// Client is a Robinhood Agentic MCP client.
|
|
type Client struct {
|
|
URL, Token, Name, Version string
|
|
HTTP *http.Client
|
|
Hook Caller
|
|
session *mcp.ClientSession
|
|
}
|
|
|
|
// Call invokes an MCP tool by name and returns its JSON result.
|
|
func (c *Client) Call(ctx context.Context, name string, args map[string]any) (json.RawMessage, error) {
|
|
if c.Hook != nil {
|
|
return c.Hook.Call(ctx, name, args)
|
|
}
|
|
if c.session != nil {
|
|
return c.sessionCall(ctx, name, args)
|
|
}
|
|
return c.rpcCall(ctx, name, args)
|
|
}
|