Skip to content

variants: simplify dispatch and session by reducing method boilerplate#8

Merged
StevenRChen merged 7 commits into
mainfrom
receiving
May 1, 2026
Merged

variants: simplify dispatch and session by reducing method boilerplate#8
StevenRChen merged 7 commits into
mainfrom
receiving

Conversation

@StevenRChen
Copy link
Copy Markdown
Collaborator

Simplify variant dispatch and session by replacing per-method boilerplate with generic handlers backed by reflect.

Motivation and Context

The dispatcher and backend session had separate handler functions for every MCP method (ListTools, ListResources, CallTool, Subscribe, etc.), each following an identical pattern: extract params, inject metadata, call inner handler, cast result. This meant ~250 lines of near-identical code across dispatch.go and session.go, and every new MCP method required adding another copy.

How Has This Been Tested?

All existing unit and integration tests pass (go test -v ./...)

Breaking Changes

None. All changes are internal to the variants package. Public API is unchanged.

Types of changes

Refactor (non-breaking change which fixes an issue)

Comment thread go/sdk/variants/dispatch.go
Comment thread go/sdk/variants/dispatch.go
@StevenRChen StevenRChen merged commit b95923d into main May 1, 2026
11 checks passed
@StevenRChen StevenRChen deleted the receiving branch May 1, 2026 11:29
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