Skip to content
GlxymeshDocs
glxymesh.com
Select theme
Open console
Reading time 1 min

Store state between tool calls

Persist data across calls in a Glxymesh MCP tool with the built-in key/value store. Get, put, delete and list by prefix, scoping, and size limits.

Each call runs in a fresh WebAssembly instance, so package variables are reset every time. To keep data between calls, use host.KV.

import "glxymesh.com/mcp-core/host"
err := host.KV.Put("counter", []byte("41"))
value, found, err := host.KV.Get("counter") // found is false for a missing key; that's not an error
err = host.KV.Delete("counter")
keys, err := host.KV.List("session:") // every key that starts with the prefix

Keys are strings and values are bytes. Encode structured data yourself, for example with encoding/json.

Each tool has its own keyspace, keyed by organization, project and tool name. Two tools can use the same key without collisions, and no tool can read another tool’s data. Renaming a tool gives it a new, empty keyspace.

Key up to 512 bytes
Value up to 1 MiB

Keys aren’t locked between calls. If two calls update the same key at the same time, the last write wins.