Skip to content

Completions follow-ups #1318

Open
Open

Description

@tzolov

Follow-ups from the review of #1316. Each item can go in its own small PR.

  1. A ref without type returns an internal error instead of invalid params. CompletionsFeature.handle looks up byRefType.get(ref.get("type")). byRefType comes from Map.copyOf, and get(null) on an immutable map throws an NPE, so a request like {"ref": {"name": "x"}, ...} gets -32603 instead of -32602.

  2. McpFeature.completionRefTypes() can't serve a new reference type. CompletionsFeature decodes every request into CompleteRequest before calling feature.complete(...). CompleteReference only lists ref/prompt and ref/resource in @JsonSubTypes, so a feature that declares ref/custom is advertised and routed to, but decoding fails with -32602 "Malformed CompleteRequest" before complete() runs. Today a custom feature can only take over one of the two built-in types. Either remove the extension point until there's a use case, or let complete() take the raw params, as handle() does.

  3. ref/resource with a concrete resource URI is rejected. ResourcesFeature.complete only resolves ref/resource through an exact findTemplate match, so a reference to an existing resource such as test://static-text gets -32602 "Unknown resource template". The legacy McpAsyncServer returns an empty completion here, so the two server stacks now differ. Confirm if this is intentional

Activity

  1. media-ctrl commented on Nov 9, 2026

    @media-ctrl
  2. neerajbhatt commented on Nov 14, 2026

    @neerajbhatt
    Contributor

    Hi @tzolov, I’d like to take item 1 of this issue. I’ll add a regression test for a completion request missing ref.type, then guard the lookup so it returns -32602 instead of -32603. I’ll keep the PR limited to item 1.

  3. weiwastron commented on Nov 16, 2026

    @weiwastron

    Hi, @tzolov, I'd like to work on item 2.

    I propose changing complete() to accept Object params, allowing custom features to handle their own parameter deserialization, while keeping common request validation in CompletionsFeature.

    To maintain backward compatibility, we could retain the existing complete(McpRequestContext, CompleteRequest) method and introduce the new complete(McpRequestContext, Object) method with a default implementation that delegates to the existing one. This would allow existing feature implementations to continue working while enabling custom reference types.

    Would this approach be acceptable? Also, do we need to consider any additional migration guidance for existing implementations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions