Class McpServerPrompt
- All Implemented Interfaces:
McpServerComponent<io.modelcontextprotocol.server.McpServerFeatures.SyncPromptSpecification>
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:
-
McpPromptMcpPromptParamMcpSchema.PromptMcpSchema.PromptArgument
-
Field Summary
Fields inherited from class com.github.thought2code.mcp.annotated.server.component.McpServerComponentBase
mcpSyncServer -
Constructor Summary
ConstructorsConstructorDescriptionMcpServerPrompt(io.modelcontextprotocol.server.McpSyncServer mcpSyncServer) Constructs a newMcpServerPromptwith the specified MCP server. -
Method Summary
Methods inherited from class com.github.thought2code.mcp.annotated.server.component.McpServerComponentBase
localizeAttribute
-
Constructor Details
-
McpServerPrompt
public McpServerPrompt(io.modelcontextprotocol.server.McpSyncServer mcpSyncServer) Constructs a newMcpServerPromptwith the specified MCP server.- Parameters:
mcpSyncServer- the MCP synchronous server to use for prompt registration
-
-
Method Details
-
from
Creates a synchronous prompt specification from the specified method.This method processes a method annotated with
McpPromptand creates aMcpServerFeatures.SyncPromptSpecificationthat can be registered with the MCP server. The method extracts prompt information from annotations and method signature, and creates appropriate prompt arguments. -
register
public void register()Registers all prompt components with the MCP server.This method scans for all methods annotated with
McpPromptand registers them as prompt components with the MCP server. It uses reflection to discover annotated methods and creates prompt specifications for each method.
-