Skip to content

fix(mcp): fix RawResponseEnabled hot reload not working - #2653

Merged
wklken merged 1 commit into
TencentBlueKing:release/1.21from
Han-Ya-Jun:fix/mcp-raw-response-hot-reload
Apr 21, 2026
Merged

fix(mcp): fix RawResponseEnabled hot reload not working#2653
wklken merged 1 commit into
TencentBlueKing:release/1.21from
Han-Ya-Jun:fix/mcp-raw-response-hot-reload

Conversation

@Han-Ya-Jun

Copy link
Copy Markdown
Member

Why this change was needed:
When changing RawResponseEnabled configuration for an MCP server, the setting was not taking effect without restarting the service. This was because genToolHandler captured the rawResponse bool value at handler registration time, so subsequent changes via SetRawResponseEnabled had no effect on already-registered tool handlers.

What changed:

  • Changed genToolHandler signature from rawResponse bool to rawResponseGetter func() bool to accept a getter function
  • Updated tool handler to call rawResponseGetter() dynamically instead of using captured boolean value
  • Changed call sites to pass mcpServer.RawResponseEnabled method value instead of config.RawResponseEnabled boolean
  • Added unit tests for RawResponseEnabled getter behavior and concurrent access safety

Problem solved:
RawResponseEnabled configuration changes now take effect immediately without requiring service restart. Tool handlers dynamically read the latest value from MCPServer on each execution.

Description

Fixes # (issue)

Checklist

  • 填写 PR 描述及相关 issue (write PR description and related issue)
  • 代码风格检查通过 (code style check passed)
  • PR 中包含单元测试 (include unit test)
  • 单元测试通过 (unit test passed)
  • 本地开发联调环境验证通过 (local development environment verification passed)

Why this change was needed:
When changing RawResponseEnabled configuration for an MCP server, the
setting was not taking effect without restarting the service. This was
because genToolHandler captured the rawResponse bool value at handler
registration time, so subsequent changes via SetRawResponseEnabled had
no effect on already-registered tool handlers.

What changed:
- Changed genToolHandler signature from rawResponse bool to
  rawResponseGetter func() bool to accept a getter function
- Updated tool handler to call rawResponseGetter() dynamically instead
  of using captured boolean value
- Changed call sites to pass mcpServer.RawResponseEnabled method value
  instead of config.RawResponseEnabled boolean
- Added unit tests for RawResponseEnabled getter behavior and
  concurrent access safety

Problem solved:
RawResponseEnabled configuration changes now take effect immediately
without requiring service restart. Tool handlers dynamically read the
latest value from MCPServer on each execution.

Co-authored-by: claude <noreply@anthropic.com>
@Han-Ya-Jun
Han-Ya-Jun requested review from wklken April 20, 2026 13:14
@wklken
wklken merged commit 662b5f0 into TencentBlueKing:release/1.21 Apr 21, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants