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 Details

    • completeResultBuilder

      CompletionResult.Builder completeResultBuilder()
      Create a new builder for a CompletionResult.
      Returns:
      the new CompletionResult builder
    • newCompleteResult

      default CompletionResult newCompleteResult(List<String> values)
      Creates a new CompletionResult with a list of suggestions that is the complete set of available suggestions.
      Parameters:
      values - the list of suggestions
      Returns:
      the new completion result
    • newIncompleteResult

      default CompletionResult newIncompleteResult(List<String> values)
      Creates a new CompletionResult with 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

      default CompletionResult newResult(List<String> values, int total)
      Creates a new CompletionResult which includes a list of suggestions and the total number of available suggestions.
      Parameters:
      values - the list of suggestions
      total - the total number of available suggestions
      Returns:
      the new completion result
      Throws:
      IllegalArgumentException - if total is less than values.size()
    • textContentBuilder

      TextContent.Builder textContentBuilder(String text)
      Creates a new builder for a TextContent
      Parameters:
      text - the text
      Returns:
      the text content builder
    • newTextContent

      default TextContent newTextContent(String text)
      Creates a new TextContent
      Parameters:
      text - the text
      Returns:
      the new text content object
    • audioContentBuilder

      AudioContent.Builder audioContentBuilder(byte[] data, String mimeType)
      Creates a new builder for an AudioContent
      Parameters:
      data - the audio data
      mimeType - the MIME type of the audio data
      Returns:
      the audio content builder
    • newAudioContent

      default AudioContent newAudioContent(byte[] data, String mimeType)
      Creates a new AudioContent
      Parameters:
      data - the audio data
      mimeType - the MIME type of the audio data
      Returns:
      the new audio content
    • imageContentBuilder

      ImageContent.Builder imageContentBuilder(byte[] data, String mimeType)
      Creates a new builder for an ImageContent
      Parameters:
      data - the image data
      mimeType - the MIME type of the image data
      Returns:
      the image content builder
    • newImageContent

      default ImageContent newImageContent(byte[] data, String mimeType)
      Creates a new ImageContent
      Parameters:
      data - the image data
      mimeType - the MIME type of the image data
      Returns:
      the new image content
    • textEmbeddedResourceBuilder

      EmbeddedResource.Builder textEmbeddedResourceBuilder(String text, String uri)
      Creates a new builder for an EmbeddedResource with TextResourceContents
      Parameters:
      text - the text content for the embedded resource
      uri - the URI of the resource
      Returns:
      the embedded resource builder
    • blobEmbeddedResourceBuilder

      EmbeddedResource.Builder blobEmbeddedResourceBuilder(byte[] data, String uri)
      Creates a new builder for an EmbeddedResource with BlobResourceContents
      Parameters:
      data - the data for the embedded resource
      uri - the URI of the resource
      Returns:
      the embedded resource builder
    • resourceLinkBuilder

      ResourceLink.Builder resourceLinkBuilder(String name, String uri)
      Creates a new builder for a ResourceLink
      Parameters:
      name - the name of the link
      uri - the URI of the target resource
      Returns:
      the resource link builder
    • annotationsBuilder

      Annotations.Builder annotationsBuilder()
      Creates a new builder for an Annotations
      Returns:
      the annotations builder
    • promptResponseBuilder

      PromptResponse.Builder promptResponseBuilder()
      Create a builder for a new PromptResponse
      Returns:
      the new PromptResponse builder
    • newPromptResponse

      default PromptResponse newPromptResponse(Role role, ContentBlock content)
      Create a new PromptResponse with a single message
      Parameters:
      role - the role for the message
      content - the content of the message
      Returns:
      the new prompt response
    • resourceResponseBuilder

      ResourceResponse.Builder resourceResponseBuilder()
      Create a builder for a ResourceResponse
      Returns:
      the new ResourceResponse builder
    • resourceTextResponse

      default ResourceResponse resourceTextResponse(String uri, String text)
      Creates a new ResourceResponse with text content and no MIME type
      Parameters:
      uri - the resource URI
      text - the text content
      Returns:
      the new resource response
    • resourceTextResponse

      default ResourceResponse resourceTextResponse(String uri, String text, String mimeType)
      Creates a new ResourceResponse with text content and the given MIME type
      Parameters:
      uri - the resource URI
      text - the text content
      mimeType - the MIME type
      Returns:
      the new resource response
    • resourceBlobResponse

      default ResourceResponse resourceBlobResponse(String uri, byte[] data)
      Creates a new ResourceResponse with binary content and no MIME type
      Parameters:
      uri - the resource URI
      data - the binary content
      Returns:
      the new resource response
    • resourceBlobResponse

      default ResourceResponse resourceBlobResponse(String uri, byte[] data, String mimeType)
      Creates a new ResourceResponse with binary content and the given MIME type
      Parameters:
      uri - the resource URI
      data - the binary content
      mimeType - the MIME type
      Returns:
      the new resource response
    • newTextResourceContents

      default TextResourceContents newTextResourceContents(String uri, String text)
      Creates a new TextResourceContents with a URI and text.
      Parameters:
      uri - the resource URI
      text - the text content
      Returns:
      the new text resource
    • textResourceContentsBuilder

      TextResourceContents.Builder textResourceContentsBuilder(String uri, String text)
      Creates a builder for a TextResourceContents
      Parameters:
      uri - the resource URI
      text - the text content
      Returns:
      the new text resource builder
    • newBlobResourceContent

      default BlobResourceContents newBlobResourceContent(String uri, byte[] data)
      Creates a new BlobResourceContents with a URI and data.
      Parameters:
      uri - the resource URI
      data - the binary content
      Returns:
      the new blob resource
    • blobResourceContentsBuilder

      BlobResourceContents.Builder blobResourceContentsBuilder(String uri, byte[] data)
      Creates a builder for a BlobResourceContents
      Parameters:
      uri - the resource URI
      data - the binary content
      Returns:
      the new blob resource builder
    • toolResponseBuilder

      ToolResponse.Builder toolResponseBuilder()
      Create a builder for a new ToolResponse
      Returns:
      the new ToolResponse builder
    • newTextToolResponse

      default ToolResponse newTextToolResponse(String text)
      Creates a new successful ToolResponse with a single text content block.
      Parameters:
      text - the text content
      Returns:
      the new tool response
    • newErrorToolResponse

      default ToolResponse newErrorToolResponse(String error)
      Creates a new error ToolResponse with a single text content block containing the error message.
      Parameters:
      error - the error message
      Returns:
      the new tool response
    • newStructuredToolResponse

      default ToolResponse newStructuredToolResponse(Object structuredContent)
      Creates a new successful ToolResponse with structured content.
      Parameters:
      structuredContent - the structured content
      Returns:
      the new tool response
    • iconBuilder

      Icon.Builder iconBuilder(String uri)
      Creates a builder for a new Icon
      Parameters:
      uri - the icon URI
      Returns:
      the Icon builder
    • newIcon

      default Icon newIcon(String uri, String mimeType)
      Creates a new Icon
      Parameters:
      uri - the icon URI
      mimeType - the icon MIME type
      Returns:
      the new Icon