MCPcopy
hub / github.com/github/github-mcp-server / buildStaticInventoryFromTools

Function buildStaticInventoryFromTools

pkg/http/handler_test.go:759–784  ·  view source on GitHub ↗

buildStaticInventoryFromTools is a test helper that mirrors buildStaticInventory but uses the provided mock tools instead of calling github.AllTools.

(cfg *ServerConfig, tools []inventory.ServerTool)

Source from the content-addressed store, hash-verified

757// buildStaticInventoryFromTools is a test helper that mirrors buildStaticInventory
758// but uses the provided mock tools instead of calling github.AllTools.
759func buildStaticInventoryFromTools(cfg *ServerConfig, tools []inventory.ServerTool) ([]inventory.ServerTool, []inventory.ServerResourceTemplate, []inventory.ServerPrompt) {
760 if !hasStaticConfig(cfg) {
761 return tools, nil, nil
762 }
763
764 b := inventory.NewBuilder().
765 SetTools(tools).
766 WithReadOnly(cfg.ReadOnly).
767 WithToolsets(github.ResolvedEnabledToolsets(cfg.EnabledToolsets, cfg.EnabledTools))
768
769 if len(cfg.EnabledTools) > 0 {
770 b = b.WithTools(github.CleanTools(cfg.EnabledTools))
771 }
772
773 if len(cfg.ExcludeTools) > 0 {
774 b = b.WithExcludeTools(cfg.ExcludeTools)
775 }
776
777 inv, err := b.Build()
778 if err != nil {
779 return tools, nil, nil
780 }
781
782 ctx := context.Background()
783 return inv.AvailableTools(ctx), inv.AvailableResourceTemplates(ctx), inv.AvailablePrompts(ctx)
784}
785
786func TestCrossOriginProtection(t *testing.T) {
787 jsonRPCBody := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"0.1"}}}`

Calls 13

NewBuilderFunction · 0.92
ResolvedEnabledToolsetsFunction · 0.92
CleanToolsFunction · 0.92
hasStaticConfigFunction · 0.85
WithToolsetsMethod · 0.80
WithReadOnlyMethod · 0.80
SetToolsMethod · 0.80
WithToolsMethod · 0.80
WithExcludeToolsMethod · 0.80
BuildMethod · 0.80
AvailableToolsMethod · 0.80

Tested by

no test coverage detected