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

Function stripMetaKeys

pkg/inventory/builder.go:411–443  ·  view source on GitHub ↗

stripMetaKeys removes the specified Meta keys from a single tool. Returns a modified copy if changes were made, nil otherwise.

(tool ServerTool, keys []string)

Source from the content-addressed store, hash-verified

409// stripMetaKeys removes the specified Meta keys from a single tool.
410// Returns a modified copy if changes were made, nil otherwise.
411func stripMetaKeys(tool ServerTool, keys []string) *ServerTool {
412 if tool.Tool.Meta == nil || len(keys) == 0 {
413 return nil
414 }
415
416 // Check if any of the specified keys exist
417 hasKeys := false
418 for _, key := range keys {
419 if _, ok := tool.Tool.Meta[key]; ok {
420 hasKeys = true
421 break
422 }
423 }
424 if !hasKeys {
425 return nil
426 }
427
428 // Make a shallow copy and remove specified keys
429 toolCopy := tool
430 newMeta := make(map[string]any, len(tool.Tool.Meta))
431 for k, v := range tool.Tool.Meta {
432 if !slices.Contains(keys, k) {
433 newMeta[k] = v
434 }
435 }
436
437 if len(newMeta) == 0 {
438 toolCopy.Tool.Meta = nil
439 } else {
440 toolCopy.Tool.Meta = newMeta
441 }
442 return &toolCopy
443}

Callers 3

stripMCPAppsMetadataFunction · 0.85
TestStripMetaKeysFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestStripMetaKeysFunction · 0.68