Skip to content

[fel] Refactor DefaultMcpClient: centralize request logic and improve robustness#143

Merged
CodeCasterX merged 1 commit intoModelEngine-Group:3.5.xfrom
CodeCasterX:fel-enhancement-tool
May 27, 2025
Merged

[fel] Refactor DefaultMcpClient: centralize request logic and improve robustness#143
CodeCasterX merged 1 commit intoModelEngine-Group:3.5.xfrom
CodeCasterX:fel-enhancement-tool

Conversation

@CodeCasterX
Copy link
Member

  • Extracted common HTTP + JSON-RPC request logic into a reusable post2McpServer method to reduce duplication across ping, initialize, getTools, and callTool.
  • Introduced BiConsumer<HttpClassicClientRequest, Long> for custom per-method setup (e.g., session ID extraction, response handler registration).
  • Replaced polling loop in initialize() with explicit failure handling via IllegalStateException when initialization fails.
  • Used Event.ENDPOINT.code() instead of hardcoded "endpoint" for better type safety and maintainability.
  • Centralized and improved logging and exception handling; wrapped IO exceptions with contextual messages.
  • Added timeout support in waitInitialized() using wait(60_000L) to prevent indefinite waiting during initialization.
  • Simplified and unified RPC method calling pattern across the class.

These changes increase code maintainability, improve error visibility, and make future enhancements easier.

…error handling, and enhance initialization robustness

- Extracted common HTTP + JSON-RPC request logic into a reusable post2McpServer method to reduce duplication across ping, initialize, getTools, and callTool.
- Introduced BiConsumer<HttpClassicClientRequest, Long> for custom per-method setup (e.g., session ID extraction, response handler registration).
- Replaced polling loop in initialize() with explicit failure handling via IllegalStateException when initialization fails.
- Used Event.ENDPOINT.code() instead of hardcoded "endpoint" for better type safety and maintainability.
- Centralized and improved logging and exception handling; wrapped IO exceptions with contextual messages.
- Added timeout support in waitInitialized() using wait(60_000L) to prevent indefinite waiting during initialization.
- Simplified and unified RPC method calling pattern across the class.

These changes increase code maintainability, improve error visibility, and make future enhancements easier.
@CodeCasterX CodeCasterX added this to the 3.5.0 milestone May 27, 2025
@CodeCasterX CodeCasterX requested a review from loveTsong May 27, 2025 14:39
@CodeCasterX CodeCasterX self-assigned this May 27, 2025
@CodeCasterX CodeCasterX added this to Nova May 27, 2025
@CodeCasterX CodeCasterX added type: enhancement A general enhancement in: fel Issues in FEL(FIT Expression for LLM) modules labels May 27, 2025
@CodeCasterX CodeCasterX merged commit dff4acc into ModelEngine-Group:3.5.x May 27, 2025
1 check passed
@github-project-automation github-project-automation bot moved this to Done in Nova May 27, 2025
Yager-42 pushed a commit to Yager-42/fit-framework that referenced this pull request Aug 16, 2025
…error handling, and enhance initialization robustness (ModelEngine-Group#143)

- Extracted common HTTP + JSON-RPC request logic into a reusable post2McpServer method to reduce duplication across ping, initialize, getTools, and callTool.
- Introduced BiConsumer<HttpClassicClientRequest, Long> for custom per-method setup (e.g., session ID extraction, response handler registration).
- Replaced polling loop in initialize() with explicit failure handling via IllegalStateException when initialization fails.
- Used Event.ENDPOINT.code() instead of hardcoded "endpoint" for better type safety and maintainability.
- Centralized and improved logging and exception handling; wrapped IO exceptions with contextual messages.
- Added timeout support in waitInitialized() using wait(60_000L) to prevent indefinite waiting during initialization.
- Simplified and unified RPC method calling pattern across the class.

These changes increase code maintainability, improve error visibility, and make future enhancements easier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: fel Issues in FEL(FIT Expression for LLM) modules type: enhancement A general enhancement

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant