Skip to content

Refactor routes and harden AddTool#5375

Merged
kevwan merged 1 commit intozeromicro:masterfrom
mk0walsk:refactor
Jan 24, 2026
Merged

Refactor routes and harden AddTool#5375
kevwan merged 1 commit intozeromicro:masterfrom
mk0walsk:refactor

Conversation

@mk0walsk
Copy link
Contributor

This PR refactors server.go to eliminate code duplication in route registration and hardens AddTool in types.go against silent failures.

Key Changes:

  1. DRY & Consistency: Extracted identical route registration logic from setupSSETransport and setupStreamableTransport into a registerRoutes helper. This reduces duplication and ensures consistent timeout handling across transport modes.
  2. Error Visibility: Added explicit error logging to AddTool when the server type assertion fails. Previously, passing a custom McpServer implementation would cause the tool registration to silently fail, leading to difficult debugging.

@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kevwan kevwan added this pull request to the merge queue Jan 24, 2026
Merged via the queue into zeromicro:master with commit 94e2f5b Jan 24, 2026
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