Class McpServerCompletion
java.lang.Object
com.github.thought2code.mcp.annotated.server.component.AbstractMcpServerComponent<io.modelcontextprotocol.server.McpServerFeatures.SyncCompletionSpecification>
com.github.thought2code.mcp.annotated.server.component.McpServerCompletion
- All Implemented Interfaces:
McpServerComponent<io.modelcontextprotocol.server.McpServerFeatures.SyncCompletionSpecification>
public class McpServerCompletion
extends AbstractMcpServerComponent<io.modelcontextprotocol.server.McpServerFeatures.SyncCompletionSpecification>
MCP server component for handling completion requests.
This class is responsible for creating and managing completion specifications for the Model
Context Protocol (MCP) server. It processes methods annotated with McpPromptCompletion or
McpResourceCompletion and creates the appropriate completion handlers that can provide
auto-completion suggestions.
The component validates method signatures, creates completion references, and handles the invocation of completion methods. It supports both prompt-based and resource-based completion functionality.
- Author:
- codeboyzhou
-
Field Summary
Fields inherited from class com.github.thought2code.mcp.annotated.server.component.AbstractMcpServerComponent
injector -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.github.thought2code.mcp.annotated.server.component.AbstractMcpServerComponent
localizeAttribute
-
Constructor Details
-
McpServerCompletion
public McpServerCompletion()
-
-
Method Details
-
create
public io.modelcontextprotocol.server.McpServerFeatures.SyncCompletionSpecification create(Method method) Creates a synchronous completion specification for the given method.This method validates the method signature to ensure it meets the requirements for completion handlers, then creates a
McpServerFeatures.SyncCompletionSpecificationthat can be registered with the MCP server.The method must:
- Return
McpCompleteCompletion - Have exactly one parameter of type
McpSchema.CompleteRequest.CompleteArgument - Be annotated with either
McpPromptCompletionorMcpResourceCompletion
- Parameters:
method- the method to create completion specification for- Returns:
- a synchronous completion specification for the MCP server
- Throws:
McpServerComponentRegistrationException- if the method signature is invalid
- Return
-