(t *testing.T)
| 21 | } |
| 22 | |
| 23 | func TestScanReadOnlyHint(t *testing.T) { |
| 24 | t.Parallel() |
| 25 | |
| 26 | const compliant = `package fixture |
| 27 | |
| 28 | import "github.com/modelcontextprotocol/go-sdk/mcp" |
| 29 | |
| 30 | var Tool = mcp.Tool{ |
| 31 | Name: "compliant_tool", |
| 32 | Annotations: &mcp.ToolAnnotations{ |
| 33 | ReadOnlyHint: true, |
| 34 | }, |
| 35 | } |
| 36 | ` |
| 37 | |
| 38 | const missingHint = `package fixture |
| 39 | |
| 40 | import "github.com/modelcontextprotocol/go-sdk/mcp" |
| 41 | |
| 42 | var Tool = mcp.Tool{ |
| 43 | Name: "missing_hint", |
| 44 | Annotations: &mcp.ToolAnnotations{ |
| 45 | Title: "no hint", |
| 46 | }, |
| 47 | } |
| 48 | ` |
| 49 | |
| 50 | const missingAnnotations = `package fixture |
| 51 | |
| 52 | import "github.com/modelcontextprotocol/go-sdk/mcp" |
| 53 | |
| 54 | var Tool = mcp.Tool{ |
| 55 | Name: "missing_annotations", |
| 56 | } |
| 57 | ` |
| 58 | |
| 59 | const nonLiteralAnnotations = `package fixture |
| 60 | |
| 61 | import "github.com/modelcontextprotocol/go-sdk/mcp" |
| 62 | |
| 63 | func annotations() *mcp.ToolAnnotations { return &mcp.ToolAnnotations{ReadOnlyHint: true} } |
| 64 | |
| 65 | var Tool = mcp.Tool{ |
| 66 | Name: "non_literal", |
| 67 | Annotations: annotations(), |
| 68 | } |
| 69 | ` |
| 70 | |
| 71 | const unkeyedTool = `package fixture |
| 72 | |
| 73 | import "github.com/modelcontextprotocol/go-sdk/mcp" |
| 74 | |
| 75 | var Tool = mcp.Tool{"unkeyed", "desc", nil, nil, nil, nil} |
| 76 | ` |
| 77 | |
| 78 | const aliasedImport = `package fixture |
| 79 | |
| 80 | import sdk "github.com/modelcontextprotocol/go-sdk/mcp" |
nothing calls this directly
no test coverage detected