-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(extensions): add Unix socket transport for StreamableHttp extensions #7631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
c4289ce
f4af365
99564e9
9eeac23
5716182
52ee2b5
944f675
53517de
057a044
6c9dad3
02320d0
b5487d8
c1d7153
322d0b5
93c2b69
94b8d10
b884cd1
9854fef
403b39b
b3c49b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -232,6 +232,11 @@ pub enum ExtensionConfig { | |
| env_keys: Vec<String>, | ||
| #[serde(default)] | ||
| headers: HashMap<String, String>, | ||
| /// Unix domain socket path to route HTTP through (e.g. "@egress.sock" for Envoy sidecar). | ||
| /// When set, the physical connection goes through this socket while `uri` is used for the | ||
| /// HTTP Host header and path. Useful in K8s environments where DNS only resolves via Envoy. | ||
| #[serde(default)] | ||
| socket: Option<String>, | ||
| // NOTE: set timeout to be optional for compatibility. | ||
| // However, new configurations should include this field. | ||
| timeout: Option<u64>, | ||
|
|
@@ -305,6 +310,7 @@ impl ExtensionConfig { | |
| envs: Envs::default(), | ||
| env_keys: Vec::new(), | ||
| headers: HashMap::new(), | ||
| socket: None, | ||
| description: description.into(), | ||
| timeout: Some(timeout.into()), | ||
| bundled: None, | ||
|
|
@@ -459,6 +465,7 @@ impl ExtensionConfig { | |
| envs, | ||
| env_keys, | ||
| headers, | ||
| socket, | ||
| timeout, | ||
| bundled, | ||
| available_tools, | ||
|
|
@@ -478,6 +485,7 @@ impl ExtensionConfig { | |
| envs: Envs::new(merged), | ||
| env_keys: vec![], | ||
| headers, | ||
| socket, | ||
|
Comment on lines
485
to
+488
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| timeout, | ||
| bundled, | ||
| available_tools, | ||
|
|
@@ -494,9 +502,12 @@ impl std::fmt::Display for ExtensionConfig { | |
| ExtensionConfig::Sse { name, .. } => { | ||
| write!(f, "SSE({}: unsupported)", name) | ||
| } | ||
| ExtensionConfig::StreamableHttp { name, uri, .. } => { | ||
| write!(f, "StreamableHttp({}: {})", name, uri) | ||
| } | ||
| ExtensionConfig::StreamableHttp { | ||
| name, uri, socket, .. | ||
| } => match socket { | ||
| Some(s) => write!(f, "StreamableHttp({}: {} via {})", name, uri, s), | ||
| None => write!(f, "StreamableHttp({}: {})", name, uri), | ||
| }, | ||
| ExtensionConfig::Stdio { | ||
| name, cmd, args, .. | ||
| } => { | ||
|
|
@@ -678,6 +689,7 @@ available_tools: [] | |
| )] | ||
| .into_iter() | ||
| .collect(), | ||
| socket: None, | ||
| timeout: None, | ||
| bundled: None, | ||
| available_tools: vec![], | ||
|
|
@@ -698,6 +710,7 @@ available_tools: [] | |
| )] | ||
| .into_iter() | ||
| .collect(), | ||
| socket: None, | ||
| timeout: None, | ||
| bundled: None, | ||
| available_tools: vec![], | ||
|
|
@@ -771,6 +784,7 @@ available_tools: [] | |
| )] | ||
| .into_iter() | ||
| .collect(), | ||
| socket: None, | ||
| timeout: None, | ||
| bundled: None, | ||
| available_tools: vec![], | ||
|
|
@@ -788,6 +802,7 @@ available_tools: [] | |
| headers: [("Authorization".to_string(), "Bearer secret_value".to_string())] | ||
| .into_iter() | ||
| .collect(), | ||
| socket: None, | ||
| timeout: None, | ||
| bundled: None, | ||
| available_tools: vec![], | ||
|
|
@@ -802,6 +817,7 @@ available_tools: [] | |
| envs: extension::Envs::default(), | ||
| env_keys: vec!["MY_SECRET".into()], | ||
| headers: std::collections::HashMap::new(), | ||
| socket: None, | ||
| timeout: None, | ||
| bundled: None, | ||
| available_tools: vec![], | ||
|
|
@@ -817,6 +833,7 @@ available_tools: [] | |
| }), | ||
| env_keys: vec![], | ||
| headers: std::collections::HashMap::new(), | ||
| socket: None, | ||
| timeout: None, | ||
| bundled: None, | ||
| available_tools: vec![], | ||
|
|
@@ -867,4 +884,64 @@ available_tools: [] | |
| cfg.set("MY_SECRET", &"secret_value", true).unwrap(); | ||
| assert_eq!(config.resolve(&cfg).await.unwrap(), expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_deserialize_streamable_http_with_socket() { | ||
| let config: ExtensionConfig = serde_yaml::from_str( | ||
| "type: streamable_http\nname: ai-app-info\ndescription: test\nuri: http://example.com/mcp\nsocket: \"@egress.sock\"\n", | ||
| ) | ||
| .unwrap(); | ||
| if let ExtensionConfig::StreamableHttp { socket, .. } = config { | ||
| assert_eq!(socket, Some("@egress.sock".to_string())); | ||
| } else { | ||
| panic!("unexpected variant"); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_deserialize_streamable_http_without_socket() { | ||
| let config: ExtensionConfig = serde_yaml::from_str( | ||
| "type: streamable_http\nname: ai-app-info\ndescription: test\nuri: http://example.com/mcp\n", | ||
| ) | ||
| .unwrap(); | ||
| if let ExtensionConfig::StreamableHttp { socket, .. } = config { | ||
| assert_eq!(socket, None); | ||
| } else { | ||
| panic!("unexpected variant"); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_display_streamable_http_without_socket() { | ||
| let config = ExtensionConfig::streamable_http( | ||
| "ai-app-info", | ||
| "http://example.com/mcp", | ||
| "test", | ||
| 300u64, | ||
| ); | ||
| assert_eq!( | ||
| format!("{config}"), | ||
| "StreamableHttp(ai-app-info: http://example.com/mcp)" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_display_streamable_http_with_socket() { | ||
| let config = ExtensionConfig::StreamableHttp { | ||
| name: "ai-app-info".to_string(), | ||
| uri: "http://example.com/mcp".to_string(), | ||
| description: "test".to_string(), | ||
| timeout: Some(300), | ||
| headers: Default::default(), | ||
| envs: Default::default(), | ||
| env_keys: vec![], | ||
| socket: Some("@egress.sock".to_string()), | ||
| bundled: None, | ||
| available_tools: vec![], | ||
| }; | ||
| assert_eq!( | ||
| format!("{config}"), | ||
| "StreamableHttp(ai-app-info: http://example.com/mcp via @egress.sock)" | ||
| ); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.