-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseable_roles.go
More file actions
40 lines (35 loc) · 1.44 KB
/
Copy pathparseable_roles.go
File metadata and controls
40 lines (35 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package tools
import (
"context"
"fmt"
"strings"
"github.com/mark3labs/mcp-go/mcp"
"github.com/mark3labs/mcp-go/server"
)
func RegisterGetRolesTool(mcpServer *server.MCPServer) {
mcpServer.AddTool(mcp.NewTool(
"get_roles",
mcp.WithDescription(`Get information about the Parseable roles. Roles is used for handling RBAC permissions/privilege and define access to datasets. Calls /api/v1/roles.
Data is returned as a dictionary with the role name and a list of privilege. The privilege can be of the following:
- admin - have all privileges
- editor - have limited privileges like cluster features
- reader - allow read from datasets
- writer - allow read and write from datasets
- ingestor - allow write from datasets
For reader, writer and ingestor role there is always at least one resource connected to the role. This resources is typical a dataset.
For full description of roles and RBAC use https://www.parseable.com/docs/user-guide/rbac
`),
), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
about, err := getParseableRoles()
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
var lines []string
for k, v := range about {
lines = append(lines, k+": "+fmt.Sprintf("%v", v))
}
return mcp.NewToolResultText(strings.Join(lines, "\n")), nil
// Optionally, for structured output:
// return mcp.NewToolResultStructured(map[string]interface{}{"info": info}, "Info returned"), nil
})
}