newTestMCPServer creates a streamable HTTP MCP server with the given tools. The caller must close the returned *httptest.Server.
(t *testing.T, tools ...mcpserver.ServerTool)
| 26 | // newTestMCPServer creates a streamable HTTP MCP server with the |
| 27 | // given tools. The caller must close the returned *httptest.Server. |
| 28 | func newTestMCPServer(t *testing.T, tools ...mcpserver.ServerTool) *httptest.Server { |
| 29 | t.Helper() |
| 30 | srv := mcpserver.NewMCPServer("test-server", "1.0.0") |
| 31 | srv.AddTools(tools...) |
| 32 | httpSrv := mcpserver.NewStreamableHTTPServer(srv) |
| 33 | ts := httptest.NewServer(httpSrv) |
| 34 | t.Cleanup(ts.Close) |
| 35 | return ts |
| 36 | } |
| 37 | |
| 38 | // echoTool returns a ServerTool that echoes its "input" argument |
| 39 | // prefixed with "echo: ". |
no test coverage detected