Skip to content
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

fix: component MCP Tools (SSE): 'Timeout' #5638

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

azdolinski
Copy link

Propose for resolve: #5637

  • Uses Python's built-in asyncio.timeout() context manager
  • Properly handles timeout exceptions
  • Maintains the same functionality but with correct async context management

Tested:
image

Uses Python's built-in asyncio.timeout() context manager
Properly handles timeout exceptions
Maintains the same functionality but with correct async context management
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. python Pull requests that update Python code labels Jan 13, 2025
@azdolinski azdolinski changed the title Update mcp_sse.py fix: component MCP Tools (SSE): 'Timeout' Jan 13, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 13, 2025
+clean up comment
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 13, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 13, 2025
Missing args_schema inside cause that tools are generated without input schema and are not able to be properly executed as agent know tool, but dost know what input field tool have.

Same problem looks to be in MCP STDIO.
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 14, 2025
Line 56:

Error: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
TRY003 Avoid specifying long messages outside the exception class
EM102 Exception must not use an f-string literal, assign to variable first
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 14, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 14, 2025
@ogabrielluiz ogabrielluiz requested a review from phact January 21, 2025 01:49
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @azdolinski !

Comment on lines 42 to 48
try:
async with asyncio.timeout(timeout_seconds):
sse_transport = await self.exit_stack.enter_async_context(
sse_client(url, headers, timeout_seconds, sse_read_timeout_seconds)
)
self.sse, self.write = sse_transport
self.session = await self.exit_stack.enter_async_context(ClientSession(self.sse, self.write))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Python 3.10 has that function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure which function you are talking about? Can you be more precise?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 3.10 doesn't have asyncio.timeout(). I think asyncio.wait_for() along with minor modifications to your code would serve the purpose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why @phact created the custom context manager.

Remove asyncio.timeout() (not valid for Py3.10) and replace it by asyncio.wait_for()
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 24, 2025
@github-actions github-actions bot removed the bug Something isn't working label Jan 24, 2025
@github-actions github-actions bot added the bug Something isn't working label Jan 24, 2025
Move return response.tools inside an else block. This makes it clearer that tools are returned only if the connection is successful, and not if a TimeoutError occurs.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jan 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests that update Python code size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error building Component MCP Tools (SSE): 'Timeout' object does not support the context manager protocol
4 participants