Documentation
¶
Overview ¶
Package state exposes the Dapr state management building block as MCP tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterTools ¶
func RegisterTools(server *mcp.Server, client StateClient, metrics *telemetry.ToolMetrics)
RegisterTools registers the save_state, get_state, delete_state and execute_transaction tools on server. metrics may be nil.
Types ¶
type DeleteStateArgs ¶
type DeleteStateArgs struct {
StoreName string `json:"storeName" jsonschema:"The name of the Dapr state store component (e.g., 'statestore')."`
Key string `json:"key" jsonschema:"The key to delete."`
}
DeleteStateArgs are the arguments of the delete_state tool.
type ExecuteTransactionArgs ¶
type ExecuteTransactionArgs struct {
StoreName string `json:"storeName" jsonschema:"The name of the Dapr state store component."`
Items []TransactionItem `json:"items" jsonschema:"A list of save and/or delete operations to execute atomically."`
}
ExecuteTransactionArgs are the arguments of the execute_transaction tool.
type GetStateArgs ¶
type GetStateArgs struct {
StoreName string `json:"storeName" jsonschema:"The name of the Dapr state store component (e.g., 'statestore')."`
Key string `json:"key" jsonschema:"The key whose value should be retrieved."`
}
GetStateArgs are the arguments of the get_state tool.
type SaveStateArgs ¶
type SaveStateArgs struct {
StoreName string `json:"storeName" jsonschema:"The name of the Dapr state store component (e.g., 'statestore')."`
Key string `json:"key" jsonschema:"The key under which to save the state."`
Value string `json:"value" jsonschema:"The value (typically a JSON string) to save."`
}
SaveStateArgs are the arguments of the save_state tool.
type StateClient ¶
type StateClient interface {
SaveState(ctx context.Context, storeName, key string, data []byte, meta map[string]string, so ...dapr.StateOption) error
GetState(ctx context.Context, storeName, key string, meta map[string]string) (*dapr.StateItem, error)
DeleteState(ctx context.Context, storeName, key string, meta map[string]string) error
ExecuteStateTransaction(ctx context.Context, storeName string, meta map[string]string, ops []*dapr.StateOperation) error
}
StateClient defines the interface for state operations. This allows for easier testing with mocks.
type TransactionItem ¶
type TransactionItem struct {
Key string `json:"key" jsonschema:"The state key."`
Value string `json:"value,omitempty" jsonschema:"The value to set (or empty for delete)."`
IsDelete bool `json:"isDelete,omitempty" jsonschema:"Set to true to delete the key, false to save/update it."`
}
TransactionItem is one save or delete operation within execute_transaction.