package mcp_test import ( "bytes" "encoding/json" "io" "net/http" "net/http/httptest" "testing" "github.com/mathiasbq/hyperguild/ingestion/internal/mcp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestMCPMountedHandler(t *testing.T) { srv := mcp.NewServer(t.TempDir(), nil, nil) mux := http.NewServeMux() mux.Handle("POST /mcp", srv) ts := httptest.NewServer(mux) defer ts.Close() body, err := json.Marshal(map[string]any{ "jsonrpc": "2.0", "id": 1, "method": "tools/list", }) require.NoError(t, err) resp, err := http.Post(ts.URL+"/mcp", "application/json", bytes.NewReader(body)) require.NoError(t, err) defer func() { _ = resp.Body.Close() }() assert.Equal(t, http.StatusOK, resp.StatusCode) out, _ := io.ReadAll(resp.Body) assert.Contains(t, string(out), `"brain_query"`) }