MCPcopy Index your code
hub / github.com/github/github-mcp-server / GetToolScopeMapFromInventory

Function GetToolScopeMapFromInventory

pkg/scopes/map.go:52–69  ·  view source on GitHub ↗

GetToolScopeMapFromInventory builds a tool scope map from an inventory. This extracts scope information from ServerTool.RequiredScopes and ServerTool.AcceptedScopes.

(inv *inventory.Inventory)

Source from the content-addressed store, hash-verified

50// GetToolScopeMapFromInventory builds a tool scope map from an inventory.
51// This extracts scope information from ServerTool.RequiredScopes and ServerTool.AcceptedScopes.
52func GetToolScopeMapFromInventory(inv *inventory.Inventory) ToolScopeMap {
53 result := make(ToolScopeMap)
54
55 // Get all tools from the inventory (both enabled and disabled)
56 // We need all tools for scope checking purposes
57 allTools := inv.AllTools()
58 for i := range allTools {
59 tool := &allTools[i]
60 if len(tool.RequiredScopes) > 0 || len(tool.AcceptedScopes) > 0 {
61 result[tool.Tool.Name] = &ToolScopeInfo{
62 RequiredScopes: tool.RequiredScopes,
63 AcceptedScopes: tool.AcceptedScopes,
64 }
65 }
66 }
67
68 return result
69}
70
71// HasAcceptedScope checks if any of the provided user scopes satisfy the tool's requirements.
72func (t *ToolScopeInfo) HasAcceptedScope(userScopes ...string) bool {

Callers 1

Calls 1

AllToolsMethod · 0.80

Tested by

no test coverage detected