MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / newInProcessClient

Function newInProcessClient

pkg/mcp/protocol_test.go:26–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func newInProcessClient(t *testing.T) *client.Client {
27 t.Helper()
28 cfg := DefaultConfig()
29 srv := New(cfg)
30
31 c, err := client.NewInProcessClient(srv.mcpSrv)
32 if err != nil {
33 t.Fatalf("NewInProcessClient: %v", err)
34 }
35
36 ctx := context.Background()
37 if err := c.Start(ctx); err != nil {
38 t.Fatalf("client.Start: %v", err)
39 }
40
41 initReq := mcpmcp.InitializeRequest{}
42 initReq.Params.ProtocolVersion = mcpmcp.LATEST_PROTOCOL_VERSION
43 initReq.Params.ClientInfo = mcpmcp.Implementation{
44 Name: "gosqlx-test-client",
45 Version: "0.0.1",
46 }
47 _, err = c.Initialize(ctx, initReq)
48 if err != nil {
49 t.Fatalf("client.Initialize: %v", err)
50 }
51
52 t.Cleanup(func() { _ = c.Close() })
53 return c
54}
55
56func extractProtocolResult(t *testing.T, res *mcpmcp.CallToolResult) map[string]any {
57 t.Helper()

Calls 7

StartMethod · 0.80
InitializeMethod · 0.80
DefaultConfigFunction · 0.70
NewFunction · 0.70
HelperMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected