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

Function TestScanReadOnlyHint

pkg/toolvalidation/readonlyhint_test.go:23–154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestScanReadOnlyHint(t *testing.T) {
24 t.Parallel()
25
26 const compliant = `package fixture
27
28import "github.com/modelcontextprotocol/go-sdk/mcp"
29
30var Tool = mcp.Tool{
31 Name: "compliant_tool",
32 Annotations: &mcp.ToolAnnotations{
33 ReadOnlyHint: true,
34 },
35}
36`
37
38 const missingHint = `package fixture
39
40import "github.com/modelcontextprotocol/go-sdk/mcp"
41
42var 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
52import "github.com/modelcontextprotocol/go-sdk/mcp"
53
54var Tool = mcp.Tool{
55 Name: "missing_annotations",
56}
57`
58
59 const nonLiteralAnnotations = `package fixture
60
61import "github.com/modelcontextprotocol/go-sdk/mcp"
62
63func annotations() *mcp.ToolAnnotations { return &mcp.ToolAnnotations{ReadOnlyHint: true} }
64
65var Tool = mcp.Tool{
66 Name: "non_literal",
67 Annotations: annotations(),
68}
69`
70
71 const unkeyedTool = `package fixture
72
73import "github.com/modelcontextprotocol/go-sdk/mcp"
74
75var Tool = mcp.Tool{"unkeyed", "desc", nil, nil, nil, nil}
76`
77
78 const aliasedImport = `package fixture
79
80import sdk "github.com/modelcontextprotocol/go-sdk/mcp"

Callers

nothing calls this directly

Calls 2

ScanReadOnlyHintFunction · 0.92
writePackageFunction · 0.85

Tested by

no test coverage detected