mirror of
https://gitea.ingwaz.work/Ingwaz/openbrain-mcp.git
synced 2026-04-02 07:29:07 +00:00
Fix MCP transport compatibility and batch_store e2e coverage
This commit is contained in:
20
src/auth.rs
20
src/auth.rs
@@ -90,6 +90,15 @@ pub fn get_optional_agent_id(headers: &HeaderMap) -> Option<String> {
|
||||
.map(ToOwned::to_owned)
|
||||
}
|
||||
|
||||
pub fn get_optional_agent_type(headers: &HeaderMap) -> Option<String> {
|
||||
headers
|
||||
.get("X-Agent-Type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(ToOwned::to_owned)
|
||||
}
|
||||
|
||||
/// Extract agent ID from request headers or default
|
||||
pub fn get_agent_id(request: &Request) -> String {
|
||||
get_optional_agent_id(request.headers())
|
||||
@@ -122,4 +131,15 @@ mod tests {
|
||||
Some("agent-zero")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extracts_agent_type_from_header() {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert("X-Agent-Type", HeaderValue::from_static("codex"));
|
||||
|
||||
assert_eq!(
|
||||
get_optional_agent_type(&headers).as_deref(),
|
||||
Some("codex")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user