Interface McpHandlerResolver
Contract for discovering MCP endpoints and composing programmatic handlers onto them.
Standard threadsafe implementations can be acquired via:
fromClasspathIntrospection()for production discovery viaSokletProcessor-generated metadatafromClasses(Set)for runtime reflection against a known set of endpoint classes
Programmatic handlers may be layered onto either base resolver via the withX(...) methods.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionendpointRegistrationForClass(@NonNull Class<? extends McpEndpoint> endpointClass) Resolves MCP endpoint metadata for the given endpoint class.static @NonNull McpHandlerResolverfromClasses(@NonNull Set<@NonNull Class<?>> endpointClasses) Acquires a threadsafeMcpHandlerResolverimplementation which discovers MCP endpoints by reflecting over the given endpoint classes.static @NonNull McpHandlerResolverAcquires a threadsafeMcpHandlerResolverimplementation which discovers MCP endpoints by examining a processor-generated lookup table.Vends the set of all registered MCP endpoint metadata in the system.withPrompt(@NonNull McpPromptHandler promptHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given prompt handler layered onto the specified endpoint class.withResource(@NonNull McpResourceHandler resourceHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given resource handler layered onto the specified endpoint class.withResourceList(@NonNull McpResourceListHandler resourceListHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given resource-list handler layered onto the specified endpoint class.withTool(@NonNull McpToolHandler toolHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given tool handler layered onto the specified endpoint class.
-
Method Details
-
endpointRegistrationForClass
@NonNull Optional<McpEndpointRegistration> endpointRegistrationForClass(@NonNull Class<? extends McpEndpoint> endpointClass) Resolves MCP endpoint metadata for the given endpoint class.- Parameters:
endpointClass- the endpoint class- Returns:
- resolved endpoint registration metadata, if available
-
getEndpointRegistrations
Vends the set of all registered MCP endpoint metadata in the system.- Returns:
- all resolved endpoint registrations
-
withTool
@NonNull McpHandlerResolver withTool(@NonNull McpToolHandler toolHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given tool handler layered onto the specified endpoint class.- Parameters:
toolHandler- the tool handler to addendpointClass- the endpoint class to which the handler belongs- Returns:
- a new resolver instance containing the overlay
-
withPrompt
@NonNull McpHandlerResolver withPrompt(@NonNull McpPromptHandler promptHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given prompt handler layered onto the specified endpoint class.- Parameters:
promptHandler- the prompt handler to addendpointClass- the endpoint class to which the handler belongs- Returns:
- a new resolver instance containing the overlay
-
withResource
@NonNull McpHandlerResolver withResource(@NonNull McpResourceHandler resourceHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given resource handler layered onto the specified endpoint class.- Parameters:
resourceHandler- the resource handler to addendpointClass- the endpoint class to which the handler belongs- Returns:
- a new resolver instance containing the overlay
-
withResourceList
@NonNull McpHandlerResolver withResourceList(@NonNull McpResourceListHandler resourceListHandler, @NonNull Class<? extends McpEndpoint> endpointClass) Returns a new resolver with the given resource-list handler layered onto the specified endpoint class.- Parameters:
resourceListHandler- the resource-list handler to addendpointClass- the endpoint class to which the handler belongs- Returns:
- a new resolver instance containing the overlay
-
fromClasspathIntrospection
Acquires a threadsafeMcpHandlerResolverimplementation which discovers MCP endpoints by examining a processor-generated lookup table.This implementation requires that your application be compiled with the
SokletProcessorannotation processor. The returned instance is guaranteed to be a JVM-wide singleton.- Returns:
- a resolver backed by classpath introspection
-
fromClasses
Acquires a threadsafeMcpHandlerResolverimplementation which discovers MCP endpoints by reflecting over the given endpoint classes.This method is guaranteed to return a new instance.
- Parameters:
endpointClasses- the endpoint classes to inspect- Returns:
- a resolver backed by the provided endpoint classes
-