Skip to content

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

Open
StevenRChen wants to merge 3 commits intomainfrom
receiving
Open

variants: simplify dispatch and session by reducing method boilerplate#8
StevenRChen wants to merge 3 commits intomainfrom
receiving

Conversation

@StevenRChen
Copy link
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)

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.

1 participant