Class ResourceRegistry

java.lang.Object
io.micronaut.mcp.server.registry.ResourceRegistry

@Requires(beans=McpServerConfiguration.class) @Singleton @Internal public final class ResourceRegistry extends Object
The registry of Resource-annotated methods. Produces MCP Resource specifications with handlers that invoke the annotated methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
     
    protected static final String
     
    protected final List<io.micronaut.mcp.server.registry.AbstractMcpMethodRegistry.Method<Object>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceRegistry(List<McpErrorExceptionMapper<? extends Throwable>> exceptionMappers, io.micronaut.context.BeanContext beanContext, io.micronaut.core.bind.ArgumentBinderRegistry<io.modelcontextprotocol.spec.McpSchema.ReadResourceRequest> argumentBinderRegistry)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    addMethod(io.micronaut.inject.BeanDefinition<?> beanDefinition, io.micronaut.inject.ExecutableMethod<?,?> method)
    Adds a new method to the registry by associating it with a given bean definition.
    protected final Stream<io.micronaut.mcp.server.registry.AbstractMcpMethodRegistry.Method<Object>>
    Returns a stream of the methods currently stored in the registry.
    List<io.modelcontextprotocol.server.McpServerFeatures.AsyncResourceSpecification>
     
    List<io.modelcontextprotocol.server.McpStatelessServerFeatures.AsyncResourceSpecification>
     
    List<io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncResourceSpecification>
     
    List<io.modelcontextprotocol.server.McpServerFeatures.SyncResourceSpecification>
     
    boolean
     
    protected io.modelcontextprotocol.spec.McpError
     
    protected Map<io.micronaut.core.type.Argument<?>,Object>
    prepareBoundVariables(io.micronaut.inject.ExecutableMethod<?,?> executable, List<?> parameters)
     
    protected @Nullable io.modelcontextprotocol.common.McpTransportContext
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ResourceRegistry

      public ResourceRegistry(List<McpErrorExceptionMapper<? extends Throwable>> exceptionMappers, io.micronaut.context.BeanContext beanContext, io.micronaut.core.bind.ArgumentBinderRegistry<io.modelcontextprotocol.spec.McpSchema.ReadResourceRequest> argumentBinderRegistry)
  • Method Details

    • getSyncSpecs

      public List<io.modelcontextprotocol.server.McpServerFeatures.SyncResourceSpecification> getSyncSpecs()
    • getAsyncSpecs

      public List<io.modelcontextprotocol.server.McpServerFeatures.AsyncResourceSpecification> getAsyncSpecs()
    • getStatelessSyncSpecs

      public List<io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncResourceSpecification> getStatelessSyncSpecs()
    • getStatelessAsyncSpecs

      public List<io.modelcontextprotocol.server.McpStatelessServerFeatures.AsyncResourceSpecification> getStatelessAsyncSpecs()
    • isNotEmpty

      public boolean isNotEmpty()
    • addMethod

      public final void addMethod(io.micronaut.inject.BeanDefinition<?> beanDefinition, io.micronaut.inject.ExecutableMethod<?,?> method)
      Adds a new method to the registry by associating it with a given bean definition.
      Parameters:
      beanDefinition - the bean definition that declares or provides the method
      method - the executable method to be added to the registry
    • drainMethods

      protected final Stream<io.micronaut.mcp.server.registry.AbstractMcpMethodRegistry.Method<Object>> drainMethods()
      Returns a stream of the methods currently stored in the registry. After the stream is consumed or closed, the underlying list of methods will be cleared.
      Returns:
      a stream of methods from the registry
    • mcpError

      protected io.modelcontextprotocol.spec.McpError mcpError(Exception ex)
    • prepareBoundVariables

      protected Map<io.micronaut.core.type.Argument<?>,Object> prepareBoundVariables(io.micronaut.inject.ExecutableMethod<?,?> executable, List<?> parameters)
    • resolveMcpTransportContext

      @Nullable protected @Nullable io.modelcontextprotocol.common.McpTransportContext resolveMcpTransportContext(Object ctx)