You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix serialization issue in streamablehttp mcp tools (#6721)
<!-- Thank you for your contribution! Please review
https://microsoft.github.io/autogen/docs/Contribute before opening a
pull request. -->
The current `StreamableHttpServerParams` has timedelta values that are
not JSON serializable (config.dump_component.model_dump_json()).
This make is unusable in UIs like AGS that expect configs to be
serializable to json,
```python
class StreamableHttpServerParams(BaseModel):
"""Parameters for connecting to an MCP server over Streamable HTTP."""
type: Literal["StreamableHttpServerParams"] = "StreamableHttpServerParams"
url: str # The endpoint URL.
headers: dict[str, Any] | None = None # Optional headers to include in requests.
timeout: timedelta = timedelta(seconds=30) # HTTP timeout for regular operations.
sse_read_timeout: timedelta = timedelta(seconds=60 * 5) # Timeout for SSE read operations.
terminate_on_close: bool = True
```
This PR uses float for time outs and casts it to timedelta as needed.
```python
class StreamableHttpServerParams(BaseModel):
"""Parameters for connecting to an MCP server over Streamable HTTP."""
type: Literal["StreamableHttpServerParams"] = "StreamableHttpServerParams"
url: str # The endpoint URL.
headers: dict[str, Any] | None = None # Optional headers to include in requests.
timeout: float = 30.0 # HTTP timeout for regular operations in seconds.
sse_read_timeout: float = 300.0 # Timeout for SSE read operations in seconds.
terminate_on_close: bool = True
```
<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->
## Why are these changes needed?
<!-- Please give a short summary of the change and the problem this
solves. -->
## Related issue number
<!-- For example: "Closes#1234" -->
## Checks
- [ ] I've included any doc changes needed for
<https://microsoft.github.io/autogen/>. See
<https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to
build and test documentation locally.
- [ ] I've added tests (if relevant) corresponding to the changes
introduced in this PR.
- [ ] I've made sure all auto checks have passed.
0 commit comments