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

Function unwrapAnnotationsLiteral

pkg/toolvalidation/readonlyhint.go:224–236  ·  view source on GitHub ↗

unwrapAnnotationsLiteral attempts to extract the *ast.CompositeLit for &mcp.ToolAnnotations{...} or mcp.ToolAnnotations{...} from an expression, resolving the MCP package's local alias per file.

(expr ast.Expr, aliases map[string]struct{})

Source from the content-addressed store, hash-verified

222// &mcp.ToolAnnotations{...} or mcp.ToolAnnotations{...} from an expression,
223// resolving the MCP package's local alias per file.
224func unwrapAnnotationsLiteral(expr ast.Expr, aliases map[string]struct{}) *ast.CompositeLit {
225 if u, ok := expr.(*ast.UnaryExpr); ok && u.Op == token.AND {
226 expr = u.X
227 }
228 cl, ok := expr.(*ast.CompositeLit)
229 if !ok {
230 return nil
231 }
232 if !isQualifiedType(cl.Type, aliases, "ToolAnnotations") {
233 return nil
234 }
235 return cl
236}
237
238// extractToolName returns the literal value of the Name field of an mcp.Tool
239// composite literal, or empty string if the value is not a basic string literal.

Callers 1

checkToolLiteralFunction · 0.85

Calls 1

isQualifiedTypeFunction · 0.85

Tested by

no test coverage detected