fix: parse MCP result payloads and drop place idempotency_key

Typed result structs replace empty envelopes. Equity place sends
ref_id only so live additionalProperties:false schemas accept the call.
This commit is contained in:
2026-09-01 14:18:39 -05:00
parent f52a19181d
commit a6bf8632ce
22 changed files with 2225 additions and 74 deletions
+70 -6
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"time"
decimal "github.com/alpacahq/alpacadecimal"
"s1d3sw1ped/robinhood-agentic-mcp/client"
"s1d3sw1ped/robinhood-agentic-mcp/internal/wire"
)
@@ -24,8 +25,17 @@ type ChainsRequest struct {
UnderlyingSymbol string
}
// OptionChain is one chain from get_option_chains.
type OptionChain struct {
ID string
UnderlyingSymbol string
ExpirationDates []string
}
// ChainsResult is the parsed get_option_chains payload.
type ChainsResult struct{}
type ChainsResult struct {
Chains []OptionChain
}
// InstrumentsRequest is the argument set for get_option_instruments.
type InstrumentsRequest struct {
@@ -40,16 +50,42 @@ type InstrumentsRequest struct {
Cursor string
}
// OptionInstrument is one contract from get_option_instruments.
type OptionInstrument struct {
ID string
ChainID string
ChainSymbol string
ExpirationDate string
StrikePrice decimal.Decimal
Type string
State string
}
// InstrumentsResult is the parsed get_option_instruments payload.
type InstrumentsResult struct{}
type InstrumentsResult struct {
Instruments []OptionInstrument
NextCursor string
}
// QuotesRequest is the argument set for get_option_quotes.
type QuotesRequest struct {
InstrumentIDs []string
}
// OptionQuote is one contract quote from get_option_quotes.
type OptionQuote struct {
InstrumentID string
Bid decimal.Decimal
Ask decimal.Decimal
Last decimal.Decimal
PrevClose decimal.Decimal
Mark decimal.Decimal
}
// QuotesResult is the parsed get_option_quotes payload.
type QuotesResult struct{}
type QuotesResult struct {
Quotes []OptionQuote
}
// PositionsRequest is the argument set for get_option_positions.
type PositionsRequest struct {
@@ -65,8 +101,22 @@ type PositionsRequest struct {
Cursor string
}
// OptionPosition is one holding from get_option_positions.
type OptionPosition struct {
OptionID string
ChainID string
Type string
OptionType string
Quantity decimal.Decimal
AveragePrice decimal.Decimal
ExpirationDate string
}
// PositionsResult is the parsed get_option_positions payload.
type PositionsResult struct{}
type PositionsResult struct {
Positions []OptionPosition
NextCursor string
}
// OrdersRequest is the argument set for get_option_orders.
type OrdersRequest struct {
@@ -81,7 +131,10 @@ type OrdersRequest struct {
}
// OrdersResult is the parsed get_option_orders payload.
type OrdersResult struct{}
type OrdersResult struct {
Orders []Order
NextCursor string
}
// HistoricalsRequest is the argument set for get_option_historicals.
type HistoricalsRequest struct {
@@ -92,8 +145,19 @@ type HistoricalsRequest struct {
Bounds string
}
// OptionBar is one OHLC bar from get_option_historicals.
type OptionBar struct {
InstrumentID string
Time time.Time
Open, High, Low, Close decimal.Decimal
Volume decimal.Decimal
Interpolated bool
}
// HistoricalsResult is the parsed get_option_historicals payload.
type HistoricalsResult struct{}
type HistoricalsResult struct {
Bars []OptionBar
}
// Chains calls get_option_chains.
func (c *Client) Chains(ctx context.Context, req ChainsRequest) (ChainsResult, error) {