Skip to content

feat(api): support elicitation from tool calls#804

Merged
manusa merged 3 commits intocontainers:mainfrom
Cali0707:add-elicitation-support
Mar 2, 2026
Merged

feat(api): support elicitation from tool calls#804
manusa merged 3 commits intocontainers:mainfrom
Cali0707:add-elicitation-support

Conversation

@Cali0707
Copy link
Collaborator

@Cali0707 Cali0707 commented Feb 23, 2026

This PR adds a first pass at adding elicitation support, so that toolset authors can use elicitation flows within their tools.

Note that I have not used this in any tools yet, just working to land support first here.

Fixes #801

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707 Cali0707 requested a review from manusa February 23, 2026 20:26
Elicit(ctx context.Context, message string, requestedSchema *jsonschema.Schema) (*ElicitResult, error)
}

type ElicitResult struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we document this a bit? Like others, e.g. Tool ?

Copy link
Collaborator

@matzew matzew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall it does LGTM

@manusa manusa added this to the 0.1.0 milestone Feb 24, 2026
}

result, err := session.Elicit(ctx, &mcp.ElicitParams{Message: message, RequestedSchema: requestedSchema})
// TODO: check if the error is because the client does not support elicitation, possibly return default value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO should be more actionable for tool authors. When session.Elicit() fails because the client doesn't support elicitation, the go-sdk returns a JSON-RPC error with code -32602 and message "client does not support elicitation". Tool authors need to know how to distinguish this from other errors so they can implement fallback behavior.

Consider either:

  • Documenting the expected error type/code here so callers know what to check
  • Wrapping it in a sentinel error (e.g., ErrElicitationNotSupported) that callers can use with errors.Is()

This becomes important as soon as actual tools start using elicitation.

Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Review: #804

Summary

Adds foundational MCP elicitation support: an Elicitor interface in pkg/api/, a sessionElicitor implementation in pkg/mcp/elicit.go that delegates to the go-sdk ServerSession.Elicit(), and wiring into both ToolHandlerParams and PromptHandlerParams. No tools use elicitation yet — this is plumbing only.

The design is clean and follows the existing patterns in the codebase (embedding interfaces in params structs, concrete implementations in pkg/mcp/).

Review Verdict

REQUEST_CHANGES

Findings

Critical Issues (Must Fix)

  1. Rebase on main required — The latest main (66106e7c) switched the test infrastructure from mark3labs/mcp-go to the official modelcontextprotocol/go-sdk client. The go-sdk client supports ElicitationHandler in ClientOptions, which enables real end-to-end elicitation integration tests. Please rebase on main.

  2. Missing tests — After rebasing, the go-sdk test client can be extended with a WithElicitationHandler(...) option (following the existing WithHTTPHeaders, WithClientInfo patterns in internal/test/mcp.go). This enables behavior-based integration tests that exercise the actual elicitation protocol flow:

    • TestElicitationAccepted — Client accepts with content, tool receives action=accept and provided data
    • TestElicitationDeclined — Client declines, tool receives action=decline
    • TestElicitationWithUnsupportedClient — Client has no handler, tool gets an error from Elicitor.Elicit() and handles it gracefully (no crash, returns fallback)

    These test the observable end-to-end behavior (server → client → response → server) with no mocks of the elicitor itself.

Suggestions (Should Consider)

See inline comments for:

  • ElicitResult.Action should document valid values or define constants
  • The TODO in elicit.go should be more actionable for tool authors

Security Concerns

None. The elicitation mechanism delegates to the MCP SDK's session handling, and the jsonschema.Schema parameter constrains client responses.

Overall Assessment

The interface design and wiring are solid. The main gap is the rebase needed to align with the current test infrastructure and enable proper integration tests.

@Cali0707 Cali0707 requested review from manusa and matzew February 27, 2026 17:44
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx!

@manusa manusa changed the title feat(mcp): support elicitation from tool calls feat(api): support elicitation from tool calls Mar 2, 2026
@manusa manusa merged commit 7b75311 into containers:main Mar 2, 2026
7 checks passed
manusa added a commit to marcnuri-forks/kubernetes-mcp-server that referenced this pull request Mar 2, 2026
Extend the Elicitor interface to support URL-mode elicitation added in
go-sdk v1.4.0. Refactor Elicit() to accept an ElicitParams struct
(instead of separate message/schema arguments) with fields for both
form mode (Message, RequestedSchema) and URL mode (URL, ElicitationID).

Fix error detection for mode-specific unsupported elicitation errors
by matching all three go-sdk error variants.

Follow-up to containers#804.

Signed-off-by: Marc Nuri <marc@marcnuri.com>
manusa added a commit to marcnuri-forks/kubernetes-mcp-server that referenced this pull request Mar 2, 2026
Extend the Elicitor interface to support URL-mode elicitation added in
go-sdk v1.4.0. Refactor Elicit() to accept an ElicitParams struct
(instead of separate message/schema arguments) with fields for both
form mode (Message, RequestedSchema) and URL mode (URL, ElicitationID).

Fix error detection for mode-specific unsupported elicitation errors
by matching all three go-sdk error variants.

Follow-up to containers#804.

Signed-off-by: Marc Nuri <marc@marcnuri.com>
manusa added a commit that referenced this pull request Mar 2, 2026
Extend the Elicitor interface to support URL-mode elicitation added in
go-sdk v1.4.0. Refactor Elicit() to accept an ElicitParams struct
(instead of separate message/schema arguments) with fields for both
form mode (Message, RequestedSchema) and URL mode (URL, ElicitationID).

Fix error detection for mode-specific unsupported elicitation errors
by matching all three go-sdk error variants.

Follow-up to #804.

Signed-off-by: Marc Nuri <marc@marcnuri.com>
aljesusg pushed a commit to aljesusg/kubernetes-mcp-server that referenced this pull request Mar 3, 2026
* feat(mcp): support elicitation from tool calls

Signed-off-by: Calum Murray <cmurray@redhat.com>

* cleanup: address review comments

Signed-off-by: Calum Murray <cmurray@redhat.com>

---------

Signed-off-by: Calum Murray <cmurray@redhat.com>
aljesusg pushed a commit to aljesusg/kubernetes-mcp-server that referenced this pull request Mar 3, 2026
Extend the Elicitor interface to support URL-mode elicitation added in
go-sdk v1.4.0. Refactor Elicit() to accept an ElicitParams struct
(instead of separate message/schema arguments) with fields for both
form mode (Message, RequestedSchema) and URL mode (URL, ElicitationID).

Fix error detection for mode-specific unsupported elicitation errors
by matching all three go-sdk error variants.

Follow-up to containers#804.

Signed-off-by: Marc Nuri <marc@marcnuri.com>
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.

Initial support for elicitation in the toolset API

3 participants