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

Function TestComplete

mcp/mcp_test.go:2173–2206  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2171}
2172
2173func TestComplete(t *testing.T) {
2174 completionValues := []string{"python", "pytorch", "pyside"}
2175
2176 serverOpts := &ServerOptions{
2177 CompletionHandler: func(_ context.Context, request *CompleteRequest) (*CompleteResult, error) {
2178 return &CompleteResult{
2179 Completion: CompletionResultDetails{
2180 Values: completionValues,
2181 },
2182 }, nil
2183 },
2184 }
2185 server := NewServer(testImpl, serverOpts)
2186 cs, _, cleanup := basicClientServerConnection(t, nil, server, func(s *Server) {})
2187 defer cleanup()
2188
2189 result, err := cs.Complete(context.Background(), &CompleteParams{
2190 Argument: CompleteParamsArgument{
2191 Name: "language",
2192 Value: "py",
2193 },
2194 Ref: &CompleteReference{
2195 Type: "ref/prompt",
2196 Name: "code_review",
2197 },
2198 })
2199 if err != nil {
2200 t.Fatal(err)
2201 }
2202
2203 if diff := cmp.Diff(completionValues, result.Completion.Values); diff != "" {
2204 t.Errorf("Complete() mismatch (-want +got):\n%s", diff)
2205 }
2206}
2207
2208// TestEmbeddedStructResponse performs a tool call to verify that a struct with
2209// an embedded pointer generates a correct, flattened JSON schema and that its

Callers

nothing calls this directly

Calls 3

NewServerFunction · 0.85
CompleteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…