Class McpServerToolListingHandlerConfiguration.McpStreamableServerSessionFactory

java.lang.Object
io.meeds.mcp.server.configuration.McpServerToolListingHandlerConfiguration.McpStreamableServerSessionFactory
All Implemented Interfaces:
io.modelcontextprotocol.spec.McpStreamableServerSession.Factory
Enclosing class:
McpServerToolListingHandlerConfiguration

public static class McpServerToolListingHandlerConfiguration.McpStreamableServerSessionFactory extends Object implements io.modelcontextprotocol.spec.McpStreamableServerSession.Factory
  • Constructor Summary

    Constructors
    Constructor
    Description
    McpStreamableServerSessionFactory(io.modelcontextprotocol.spec.DefaultMcpStreamableServerSessionFactory sessionFactory, org.springframework.context.ApplicationContext appContext)
    Copies the SDK factory's handlers, replacing the tools/list one with toolsListRequestHandler().
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Drops every cached tools/list answer.
    io.modelcontextprotocol.spec.McpStreamableServerSession.McpStreamableServerSessionInit
    startSession(io.modelcontextprotocol.spec.McpSchema.InitializeRequest initializeRequest)
     

    Methods inherited from class java.lang.Object

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

    • McpStreamableServerSessionFactory

      public McpStreamableServerSessionFactory(io.modelcontextprotocol.spec.DefaultMcpStreamableServerSessionFactory sessionFactory, org.springframework.context.ApplicationContext appContext)
      Copies the SDK factory's handlers, replacing the tools/list one with toolsListRequestHandler().
      Parameters:
      sessionFactory - the SDK factory whose handlers are read
      appContext - the application context the MCP server and tool service beans are resolved from, lazily
  • Method Details

    • startSession

      public io.modelcontextprotocol.spec.McpStreamableServerSession.McpStreamableServerSessionInit startSession(io.modelcontextprotocol.spec.McpSchema.InitializeRequest initializeRequest)
      Specified by:
      startSession in interface io.modelcontextprotocol.spec.McpStreamableServerSession.Factory
      Parameters:
      initializeRequest - the client's initialize request
      Returns:
      a new session wired to the copied handlers, with the SDK's own answer to the initialize request
    • clearToolsCache

      public void clearToolsCache()
      Drops every cached tools/list answer. Called through the tool update listener registered in getMcpServerToolService(), so a tool definition change — a tool disabled, its approval requirement flipped — is visible on the very next listing rather than at restart. Not called when the MCP audience changes: the cache is keyed on scopes only, on the invariant documented in toolsListRequestHandler(), so an audience change alters who reaches the handler, never what it answers.