mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-10-09 06:46:28 +00:00
feat(resolvemcp)!: make the server read-only by default
Tests / Integration Tests (push) Skipped
Build , Vet Test, and Lint / Build (push) Successful in 1m33s
Tests / Unit Tests (push) Successful in 2m1s
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Successful in 2m36s
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in 2m38s
Build , Vet Test, and Lint / Lint Code (push) Successful in 2m49s
Tests / Race Detector (push) Successful in 4m31s
Tests / Integration Tests (push) Skipped
Build , Vet Test, and Lint / Build (push) Successful in 1m33s
Tests / Unit Tests (push) Successful in 2m1s
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Successful in 2m36s
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in 2m38s
Build , Vet Test, and Lint / Lint Code (push) Successful in 2m49s
Tests / Race Detector (push) Successful in 4m31s
BREAKING CHANGE: Config.ReadOnly is now a *bool and unset means read-only. Use ReadOnly: resolvemcp.Bool(false) to enable insert/update/delete, annotations and function calls. Adds the Bool helper and updates docs.
This commit is contained in:
@@ -51,17 +51,20 @@ type Config struct {
|
||||
// host, with at most 32 distinct base URLs cached; prefer setting BaseURL.
|
||||
AllowedHosts []string
|
||||
|
||||
// ReadOnly disables every write. The insert, update, delete and annotation tools are not
|
||||
// registered, list_tables and describe_table report only the select operation (no
|
||||
// writable columns), a write attempted anyway is refused with a "forbidden" error, and
|
||||
// the server instructions tell the agent it cannot write. list_functions/call_function
|
||||
// are also off, because a registered function may change data, unless AllowFunctionCalls
|
||||
// is set.
|
||||
ReadOnly bool
|
||||
// ReadOnly disables every write and is ON when left nil: set it to Bool(false) to allow
|
||||
// writes. When on, the insert, update, delete and annotation tools are not registered,
|
||||
// list_tables and describe_table report only the select operation (no writable columns),
|
||||
// a write attempted anyway is refused with a "forbidden" error, and the server
|
||||
// instructions tell the agent it cannot write. list_functions/call_function are also
|
||||
// off, because a registered function may change data, unless AllowFunctionCalls is set.
|
||||
ReadOnly *bool
|
||||
|
||||
// readOnly is ReadOnly after defaults (nil means true).
|
||||
readOnly bool
|
||||
|
||||
// AllowFunctionCalls keeps list_functions and call_function available on a ReadOnly
|
||||
// server. Only set it for functions that do not change data; pair it with
|
||||
// AllowedFunctions to name them. It has no effect when ReadOnly is false (functions are
|
||||
// AllowedFunctions to name them. It has no effect when writes are enabled (ReadOnly set to Bool(false)) (functions are
|
||||
// always available then).
|
||||
AllowFunctionCalls bool
|
||||
|
||||
@@ -77,6 +80,9 @@ type Config struct {
|
||||
EnableAnnotations bool
|
||||
}
|
||||
|
||||
// Bool returns a pointer to v, for the optional boolean fields of Config.
|
||||
func Bool(v bool) *bool { return &v }
|
||||
|
||||
// withDefaults fills the zero limit fields.
|
||||
func (c Config) withDefaults() Config {
|
||||
def := func(v *int, d int) {
|
||||
@@ -93,6 +99,7 @@ func (c Config) withDefaults() Config {
|
||||
if c.DefaultLimit > c.MaxLimit {
|
||||
c.DefaultLimit = c.MaxLimit
|
||||
}
|
||||
c.readOnly = c.ReadOnly == nil || *c.ReadOnly
|
||||
if c.QueryTimeout <= 0 {
|
||||
c.QueryTimeout = 30 * time.Second
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user