mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 09:40:12 +00:00
feat(auth): split inventory scope out of server scope
Carve a new nezha:inventory:{read,delete,*} resource family out of
nezha:server:*. Listing and deleting servers/server-groups (GET /server,
/server-group, /ws/server, batch-delete/server[-group], MCP server.list)
now require nezha:inventory:*, while nezha:server:* covers per-server
runtime operations (get, exec, fs, config, metrics, batch-move,
force-update).
Also declare MCP tool OutputSchema for exec/fs/meta/server/transfer and
wrap server.list output in {servers,count} so strict MCP clients accept
the structured result. Correct the /file all-of scope entry and the stale
server:read documentation.
This commit is contained in:
@@ -14,6 +14,22 @@ import (
|
||||
|
||||
const fsCallTimeout = 30 * time.Second
|
||||
|
||||
func fsEntrySchema() map[string]any {
|
||||
return map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"name": map[string]any{"type": "string"},
|
||||
"type": map[string]any{"type": "string"},
|
||||
"size": map[string]any{"type": "integer"},
|
||||
"mode": map[string]any{"type": "string"},
|
||||
"mtime": map[string]any{"type": "integer"},
|
||||
"is_symlink": map[string]any{"type": "boolean"},
|
||||
"link_target": map[string]any{"type": "string"},
|
||||
},
|
||||
"required": []string{"name", "type", "size", "mode", "mtime"},
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerMCPTool(&mcpTool{
|
||||
Name: "fs.list",
|
||||
@@ -27,6 +43,15 @@ func init() {
|
||||
},
|
||||
"required": []string{"server_id", "path"},
|
||||
},
|
||||
OutputSchema: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"entries": map[string]any{"type": "array", "items": fsEntrySchema()},
|
||||
"truncated": map[string]any{"type": "boolean"},
|
||||
"total": map[string]any{"type": "integer"},
|
||||
},
|
||||
"required": []string{"entries"},
|
||||
},
|
||||
RequiredScope: model.ScopeServerRead,
|
||||
Handler: handleFsList,
|
||||
})
|
||||
@@ -45,6 +70,17 @@ func init() {
|
||||
},
|
||||
"required": []string{"server_id", "path"},
|
||||
},
|
||||
OutputSchema: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"content": map[string]any{"type": "string"},
|
||||
"encoding": map[string]any{"type": "string"},
|
||||
"size": map[string]any{"type": "integer"},
|
||||
"sha256": map[string]any{"type": "string"},
|
||||
"truncated": map[string]any{"type": "boolean"},
|
||||
},
|
||||
"required": []string{"content", "encoding", "size"},
|
||||
},
|
||||
RequiredScope: model.ScopeServerRead,
|
||||
Handler: handleFsRead,
|
||||
})
|
||||
@@ -65,6 +101,14 @@ func init() {
|
||||
},
|
||||
"required": []string{"server_id", "path", "content"},
|
||||
},
|
||||
OutputSchema: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"size": map[string]any{"type": "integer"},
|
||||
"sha256": map[string]any{"type": "string"},
|
||||
},
|
||||
"required": []string{"size", "sha256"},
|
||||
},
|
||||
RequiredScope: model.ScopeServerWrite,
|
||||
Handler: handleFsWrite,
|
||||
})
|
||||
@@ -81,6 +125,13 @@ func init() {
|
||||
},
|
||||
"required": []string{"server_id", "path"},
|
||||
},
|
||||
OutputSchema: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"deleted_count": map[string]any{"type": "integer"},
|
||||
},
|
||||
"required": []string{"deleted_count"},
|
||||
},
|
||||
RequiredScope: model.ScopeServerDelete,
|
||||
Handler: handleFsDelete,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user