Package org.mcpjava.server.spi
Interface McpServerSPI
public interface McpServerSPI
Factory interface for data objects and builders in the API.
Implementers must implement this interface and register their implementation to be loadable with
ServiceLoader.load(Class, ClassLoader) using the classloader of McpServerSPI.
Users should use static constructor methods, for example TextContent.of(String), rather
than this interface and must not implement this interface.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new builder for anAnnotationsaudioContentBuilder(byte[] data, String mimeType) Creates a new builder for anAudioContentblobEmbeddedResourceBuilder(byte[] data, String uri) Creates a new builder for anEmbeddedResourcewithBlobResourceContentsblobResourceContentsBuilder(String uri, byte[] data) Creates a builder for aBlobResourceContentsCreate a new builder for aCompletionResult.iconBuilder(String uri) Creates a builder for a newIconimageContentBuilder(byte[] data, String mimeType) Creates a new builder for anImageContentdefault AudioContentnewAudioContent(byte[] data, String mimeType) Creates a newAudioContentdefault BlobResourceContentsnewBlobResourceContent(String uri, byte[] data) Creates a newBlobResourceContentswith a URI and data.default CompletionResultnewCompleteResult(List<String> values) Creates a newCompletionResultwith a list of suggestions that is the complete set of available suggestions.default ToolResponsenewErrorToolResponse(String error) Creates a new errorToolResponsewith a single text content block containing the error message.default IconCreates a newIcondefault ImageContentnewImageContent(byte[] data, String mimeType) Creates a newImageContentdefault CompletionResultnewIncompleteResult(List<String> values) Creates a newCompletionResultwith a list of suggestions that is not the complete set of available suggestions.default PromptResponsenewPromptResponse(Role role, ContentBlock content) Create a newPromptResponsewith a single messagedefault CompletionResultCreates a newCompletionResultwhich includes a list of suggestions and the total number of available suggestions.default ToolResponsenewStructuredToolResponse(Object structuredContent) Creates a new successfulToolResponsewith structured content.default TextContentnewTextContent(String text) Creates a newTextContentdefault TextResourceContentsnewTextResourceContents(String uri, String text) Creates a newTextResourceContentswith a URI and text.default ToolResponsenewTextToolResponse(String text) Creates a new successfulToolResponsewith a single text content block.Create a builder for a newPromptResponsedefault ResourceResponseresourceBlobResponse(String uri, byte[] data) Creates a newResourceResponsewith binary content and no MIME typedefault ResourceResponseresourceBlobResponse(String uri, byte[] data, String mimeType) Creates a newResourceResponsewith binary content and the given MIME typeresourceLinkBuilder(String name, String uri) Creates a new builder for aResourceLinkCreate a builder for aResourceResponsedefault ResourceResponseresourceTextResponse(String uri, String text) Creates a newResourceResponsewith text content and no MIME typedefault ResourceResponseresourceTextResponse(String uri, String text, String mimeType) Creates a newResourceResponsewith text content and the given MIME typetextContentBuilder(String text) Creates a new builder for aTextContenttextEmbeddedResourceBuilder(String text, String uri) Creates a new builder for anEmbeddedResourcewithTextResourceContentstextResourceContentsBuilder(String uri, String text) Creates a builder for aTextResourceContentsCreate a builder for a newToolResponse
-
Method Details
-
completeResultBuilder
CompletionResult.Builder completeResultBuilder()Create a new builder for aCompletionResult.- Returns:
- the new
CompletionResultbuilder
-
newCompleteResult
Creates a newCompletionResultwith a list of suggestions that is the complete set of available suggestions.- Parameters:
values- the list of suggestions- Returns:
- the new completion result
-
newIncompleteResult
Creates a newCompletionResultwith a list of suggestions that is not the complete set of available suggestions.- Parameters:
values- the list of suggestions- Returns:
- the new completion result
-
newResult
Creates a newCompletionResultwhich includes a list of suggestions and the total number of available suggestions.- Parameters:
values- the list of suggestionstotal- the total number of available suggestions- Returns:
- the new completion result
- Throws:
IllegalArgumentException- iftotalis less thanvalues.size()
-
textContentBuilder
Creates a new builder for aTextContent- Parameters:
text- the text- Returns:
- the text content builder
-
newTextContent
Creates a newTextContent- Parameters:
text- the text- Returns:
- the new text content object
-
audioContentBuilder
Creates a new builder for anAudioContent- Parameters:
data- the audio datamimeType- the MIME type of the audio data- Returns:
- the audio content builder
-
newAudioContent
Creates a newAudioContent- Parameters:
data- the audio datamimeType- the MIME type of the audio data- Returns:
- the new audio content
-
imageContentBuilder
Creates a new builder for anImageContent- Parameters:
data- the image datamimeType- the MIME type of the image data- Returns:
- the image content builder
-
newImageContent
Creates a newImageContent- Parameters:
data- the image datamimeType- the MIME type of the image data- Returns:
- the new image content
-
textEmbeddedResourceBuilder
Creates a new builder for anEmbeddedResourcewithTextResourceContents- Parameters:
text- the text content for the embedded resourceuri- the URI of the resource- Returns:
- the embedded resource builder
-
blobEmbeddedResourceBuilder
Creates a new builder for anEmbeddedResourcewithBlobResourceContents- Parameters:
data- the data for the embedded resourceuri- the URI of the resource- Returns:
- the embedded resource builder
-
resourceLinkBuilder
Creates a new builder for aResourceLink- Parameters:
name- the name of the linkuri- the URI of the target resource- Returns:
- the resource link builder
-
annotationsBuilder
Annotations.Builder annotationsBuilder()Creates a new builder for anAnnotations- Returns:
- the annotations builder
-
promptResponseBuilder
PromptResponse.Builder promptResponseBuilder()Create a builder for a newPromptResponse- Returns:
- the new
PromptResponsebuilder
-
newPromptResponse
Create a newPromptResponsewith a single message- Parameters:
role- the role for the messagecontent- the content of the message- Returns:
- the new prompt response
-
resourceResponseBuilder
ResourceResponse.Builder resourceResponseBuilder()Create a builder for aResourceResponse- Returns:
- the new
ResourceResponsebuilder
-
resourceTextResponse
Creates a newResourceResponsewith text content and no MIME type- Parameters:
uri- the resource URItext- the text content- Returns:
- the new resource response
-
resourceTextResponse
Creates a newResourceResponsewith text content and the given MIME type- Parameters:
uri- the resource URItext- the text contentmimeType- the MIME type- Returns:
- the new resource response
-
resourceBlobResponse
Creates a newResourceResponsewith binary content and no MIME type- Parameters:
uri- the resource URIdata- the binary content- Returns:
- the new resource response
-
resourceBlobResponse
Creates a newResourceResponsewith binary content and the given MIME type- Parameters:
uri- the resource URIdata- the binary contentmimeType- the MIME type- Returns:
- the new resource response
-
newTextResourceContents
Creates a newTextResourceContentswith a URI and text.- Parameters:
uri- the resource URItext- the text content- Returns:
- the new text resource
-
textResourceContentsBuilder
Creates a builder for aTextResourceContents- Parameters:
uri- the resource URItext- the text content- Returns:
- the new text resource builder
-
newBlobResourceContent
Creates a newBlobResourceContentswith a URI and data.- Parameters:
uri- the resource URIdata- the binary content- Returns:
- the new blob resource
-
blobResourceContentsBuilder
Creates a builder for aBlobResourceContents- Parameters:
uri- the resource URIdata- the binary content- Returns:
- the new blob resource builder
-
toolResponseBuilder
ToolResponse.Builder toolResponseBuilder()Create a builder for a newToolResponse- Returns:
- the new
ToolResponsebuilder
-
newTextToolResponse
Creates a new successfulToolResponsewith a single text content block.- Parameters:
text- the text content- Returns:
- the new tool response
-
newErrorToolResponse
Creates a new errorToolResponsewith a single text content block containing the error message.- Parameters:
error- the error message- Returns:
- the new tool response
-
newStructuredToolResponse
Creates a new successfulToolResponsewith structured content.- Parameters:
structuredContent- the structured content- Returns:
- the new tool response
-
iconBuilder
Creates a builder for a newIcon- Parameters:
uri- the icon URI- Returns:
- the
Iconbuilder
-
newIcon
Creates a newIcon- Parameters:
uri- the icon URImimeType- the icon MIME type- Returns:
- the new
Icon
-