Skip to content

Commit d7b2519

Browse files
committed
fix: detect OAuth requirement from unexpected content-type responses
Some MCP servers (e.g., Atlassian) return text/plain error responses instead of HTTP 401 when unauthenticated. Add "unexpected content type" to OAuth detection heuristics so these are correctly routed to the OAuth flow rather than surfaced as generic connection errors. Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent bec7699 commit d7b2519

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • crates/mcpmux-gateway/src/pool/transport

crates/mcpmux-gateway/src/pool/transport/http.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl HttpTransport {
9494
"access token",
9595
"missing or invalid",
9696
"bearer",
97+
"unexpected content type",
9798
];
9899
oauth_indicators.iter().any(|s| error_lower.contains(s))
99100
}
@@ -845,6 +846,13 @@ mod tests {
845846
assert!(HttpTransport::requires_oauth("transport channel closed"));
846847
}
847848

849+
#[test]
850+
fn test_requires_oauth_unexpected_content_type() {
851+
assert!(HttpTransport::requires_oauth(
852+
"Unexpected content type: Some(\"text/plain;charset=UTF-8\")"
853+
));
854+
}
855+
848856
#[test]
849857
fn test_requires_oauth_false_for_unrelated() {
850858
assert!(!HttpTransport::requires_oauth("connection refused"));

0 commit comments

Comments
 (0)