java.lang.Object
com.github.thought2code.mcp.annotated.server.component.McpServerComponentBase<io.modelcontextprotocol.server.McpServerFeatures.SyncPromptSpecification>
com.github.thought2code.mcp.annotated.server.component.McpServerPrompt
All Implemented Interfaces:
McpServerComponent<io.modelcontextprotocol.server.McpServerFeatures.SyncPromptSpecification>

public class McpServerPrompt extends McpServerComponentBase<io.modelcontextprotocol.server.McpServerFeatures.SyncPromptSpecification>
MCP server component for handling prompt-related operations.

This class extends McpServerComponentBase and implements the functionality for creating and registering prompt components with an MCP server. It processes methods annotated with McpPrompt and creates appropriate prompt specifications that can be used to generate interactive prompts for LLM interactions.

The class handles:

  • Creation of prompt specifications from annotated methods
  • Registration of all prompt components with the server
  • Invocation of prompt methods with proper argument conversion
  • Localization of prompt attributes using resource bundles
Author:
codeboyzhou
See Also:
  • Constructor Details

    • McpServerPrompt

      public McpServerPrompt(io.modelcontextprotocol.server.McpSyncServer mcpSyncServer)
      Constructs a new McpServerPrompt with the specified MCP server.
      Parameters:
      mcpSyncServer - the MCP synchronous server to use for prompt registration
  • Method Details

    • from

      public io.modelcontextprotocol.server.McpServerFeatures.SyncPromptSpecification from(Method method)
      Creates a synchronous prompt specification from the specified method.

      This method processes a method annotated with McpPrompt and creates a McpServerFeatures.SyncPromptSpecification that can be registered with the MCP server. The method extracts prompt information from annotations and method signature, and creates appropriate prompt arguments.

      Parameters:
      method - the method annotated with McpPrompt to create a specification from
      Returns:
      a synchronous prompt specification for the MCP server
      See Also:
      • McpPrompt
      • McpSchema.Prompt
      • McpSchema.PromptArgument
    • register

      public void register()
      Registers all prompt components with the MCP server.

      This method scans for all methods annotated with McpPrompt and registers them as prompt components with the MCP server. It uses reflection to discover annotated methods and creates prompt specifications for each method.