state

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func ToolNames added in v0.0.2

func ToolNames() []string

ToolNames returns the names of the tools RegisterTools adds.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL