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

Function mcpAliasesFor

pkg/toolvalidation/readonlyhint.go:153–170  ·  view source on GitHub ↗

mcpAliasesFor returns the set of local identifiers under which the given file imports the MCP go-sdk (MCPImportPath). The default unaliased import resolves to the package name "mcp". Blank (`_`) and dot (`.`) imports are skipped because tool literals cannot meaningfully be qualified through them.

(file *ast.File)

Source from the content-addressed store, hash-verified

151// resolves to the package name "mcp". Blank (`_`) and dot (`.`) imports are
152// skipped because tool literals cannot meaningfully be qualified through them.
153func mcpAliasesFor(file *ast.File) map[string]struct{} {
154 aliases := map[string]struct{}{}
155 for _, imp := range file.Imports {
156 path, err := strconv.Unquote(imp.Path.Value)
157 if err != nil || path != MCPImportPath {
158 continue
159 }
160 if imp.Name != nil {
161 if imp.Name.Name == "_" || imp.Name.Name == "." {
162 continue
163 }
164 aliases[imp.Name.Name] = struct{}{}
165 continue
166 }
167 aliases["mcp"] = struct{}{}
168 }
169 return aliases
170}
171
172// isQualifiedType reports whether expr is a SelectorExpr of the form
173// <alias>.<typeName> where alias is in the provided alias set.

Callers 1

ScanReadOnlyHintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected