MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / TestServerConformance

Function TestServerConformance

mcp/conformance_test.go:61–95  ·  view source on GitHub ↗

TODO(rfindley): add client conformance tests.

(t *testing.T)

Source from the content-addressed store, hash-verified

59// TODO(rfindley): add client conformance tests.
60
61func TestServerConformance(t *testing.T) {
62 var tests []*conformanceTest
63 dir := filepath.Join("testdata", "conformance", "server")
64 if err := filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
65 if err != nil {
66 return err
67 }
68 if strings.HasSuffix(path, ".txtar") {
69 test, err := loadConformanceTest(dir, path)
70 if err != nil {
71 return fmt.Errorf("%s: %v", path, err)
72 }
73 tests = append(tests, test)
74 }
75 return nil
76 }); err != nil {
77 t.Fatal(err)
78 }
79
80 for _, test := range tests {
81 t.Run(test.name, func(t *testing.T) {
82 // We use synctest here because in general, there is no way to know when the
83 // server is done processing any notifications. As long as our server doesn't
84 // do background work, synctest provides an easy way for us to detect when the
85 // server is done processing.
86 //
87 // By comparison, gopls has a complicated framework based on progress
88 // reporting and careful accounting to detect when all 'expected' work
89 // on the server is complete.
90 synctest.Test(t, func(t *testing.T) {
91 runServerTest(t, test)
92 })
93 })
94 }
95}
96
97type structuredInput struct {
98 In string `jsonschema:"the input"`

Callers

nothing calls this directly

Calls 3

loadConformanceTestFunction · 0.85
runServerTestFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…