Skip to content

feat: improved MCP timeout - #23546

Merged
crazywoola merged 1 commit into
langgenius:mainfrom
IthacaDream:feat/imporoved-mcp-timeout
Aug 8, 2025
Merged

crazywoola merged 1 commit into
langgenius:mainfrom
IthacaDream:feat/imporoved-mcp-timeout

Conversation

@IthacaDream

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes: #23544

This is a minor improvement, and compatibility has been tested.

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 💪 enhancement New feature or request labels Aug 7, 2025
@crazywoola
crazywoola requested review from Nov1c444 and Copilot August 7, 2025 06:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves MCP (Model Context Protocol) timeout handling by adding configurable timeout parameters for better connection management. The changes allow users to specify custom timeout values when creating or updating MCP tool providers.

  • Adds timeout and sse_read_timeout parameters to MCP provider models and services
  • Updates API endpoints to accept timeout configuration
  • Propagates timeout settings through the entire MCP client stack

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
api/models/tools.py Adds timeout and sse_read_timeout columns to MCPToolProvider model
api/migrations/versions/2025_08_07_1115-fa8b0fa6f407_add_timeout_for_tool_mcp_providers.py Database migration to add timeout columns with default values
api/services/tools/mcp_tools_manage_service.py Updates service methods to handle timeout parameters
api/controllers/console/workspace/tool_providers.py Adds timeout parameters to API endpoints
api/core/tools/mcp_tool/tool.py Updates MCPTool to accept and use timeout parameters
api/core/tools/mcp_tool/provider.py Updates provider controller to pass timeout settings
api/core/mcp/mcp_client.py Updates MCP client to use configurable timeouts
api/core/mcp/client/streamable_client.py Converts timeout handling from timedelta to float
api/core/tools/tool_manager.py Removes redundant comment
api/core/tools/__base/tool_provider.py Removes redundant entity declaration
api/core/mcp/session/client_session.py Improves type hints for queue parameters
api/core/mcp/session/base_session.py Code cleanup removing unused imports and pass statements
api/core/mcp/client/sse_client.py Improves exception handling

Comment thread api/core/mcp/mcp_client.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement/Refactor] improved to allow flexible timeout configuration for MCP tools

3 participants