Skip to content

[Server] completion/complete crashes for plain ref/resource #387

Description

@kiryadev

Description

When a client sends a completion/complete request with ref.type = "ref/resource" pointing to a regular MCP resource, the server triggers a PHP warning/internal error:

Warning: Undefined property: Mcp\Capability\Registry\ResourceReference::$completionProviders

This happens because CompletionCompleteHandler fetches the resource reference and unconditionally reads $reference->completionProviders, but Mcp\Capability\Registry\ResourceReference does not define that property. The property exists on PromptReference and ResourceTemplateReference, but not on plain ResourceReference.

Example request

{
  "jsonrpc": "2.0",
  "id": 16,
  "method": "completion/complete",
  "params": {
    "argument": {
      "name": "tone"
    },
    "ref": {
      "type": "ref/resource",
      "uri": "page-editor://version-1/instruction"
    }
  }
}

Current behavior

The server logs/returns an internal error because PHP raises:

Undefined property: Mcp\Capability\Registry\ResourceReference::$completionProviders

This becomes an ErrorException and produces a JSON-RPC internal error.

Version

Observed on mcp/sdk v0.5.0.
I also checked v0.6.0 and main, and the same access pattern appears to still exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions