Local read-only Model Context Protocol server (Go) exposing the .ely_eye memory store to coding agents such as Codex and Claude Code: nine tools over status, cartridges, Evidence Atoms, compiled evidence packs, proof suites, and HashHop proofs. One-line cross-platform install (no Docker), with a prebuilt-binary release workflow.
36 lines
652 B
Go
36 lines
652 B
Go
package store
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
func optionalJSONValue(value string) (any, error) {
|
|
if value == "" || value == "null" {
|
|
return nil, nil
|
|
}
|
|
return decodeJSONValue(value)
|
|
}
|
|
|
|
func requiredJSONValue(value string) (any, error) {
|
|
if value == "" {
|
|
return map[string]any{}, nil
|
|
}
|
|
return decodeJSONValue(value)
|
|
}
|
|
|
|
func readJSONValue(data []byte) (any, error) {
|
|
if !json.Valid(data) {
|
|
return nil, errors.New("invalid JSON")
|
|
}
|
|
var value any
|
|
if err := json.Unmarshal(data, &value); err != nil {
|
|
return nil, err
|
|
}
|
|
return value, nil
|
|
}
|
|
|
|
func decodeJSONValue(value string) (any, error) {
|
|
return readJSONValue([]byte(value))
|
|
}
|