fix(agentic): reject empty MCP session ids
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
ccedf536d6
commit
4cea9555d4
2 changed files with 15 additions and 0 deletions
|
|
@ -59,6 +59,18 @@ func TestRemoteclient_McpInitialize_Bad_ServerError(t *testing.T) {
|
|||
assert.Contains(t, err.Error(), "HTTP 500")
|
||||
}
|
||||
|
||||
func TestRemoteclient_McpInitialize_Bad_MissingSessionID(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
fmt.Fprintf(w, "data: {\"result\":{}}\n\n")
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
|
||||
_, err := mcpInitialize(context.Background(), srv.URL, "")
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "missing session id")
|
||||
}
|
||||
|
||||
func TestRemoteclient_McpInitialize_Bad_Unreachable(t *testing.T) {
|
||||
_, err := mcpInitialize(context.Background(), "http://127.0.0.1:1", "")
|
||||
assert.Error(t, err)
|
||||
|
|
|
|||
|
|
@ -223,6 +223,9 @@ func mcpInitializeResult(ctx context.Context, url, token string) core.Result {
|
|||
}
|
||||
|
||||
sessionID := response.Header.Get("Mcp-Session-Id")
|
||||
if sessionID == "" {
|
||||
return core.Result{Value: core.E("mcpInitialize", "missing session id", nil), OK: false}
|
||||
}
|
||||
|
||||
drainSSE(response)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue