Documentation
¶
Overview ¶
Package session provides vMCP-specific session types that extend transport sessions with domain logic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VMCPSessionFactory ¶
func VMCPSessionFactory() transportsession.Factory
VMCPSessionFactory creates a factory function for the session manager.
Types ¶
type VMCPSession ¶
type VMCPSession struct {
*transportsession.StreamableSession
// contains filtered or unexported fields
}
VMCPSession extends StreamableSession with domain-specific routing data. This keeps routing table state in the application layer (pkg/vmcp/server) rather than polluting the transport layer (pkg/transport/session) with domain concerns.
Design Rationale:
- Embeds StreamableSession to inherit Session interface and streamable HTTP behavior
- Adds routing table for per-session capability routing
- Stores tool list with InputSchema for type coercion in composite tool workflows
- Maintains lifecycle synchronization with underlying transport session
- Provides type-safe access to routing table (vs. interface{} casting)
Lifecycle:
- Created by VMCPSessionFactory during sessionIDAdapter.Generate()
- Routing table and tools populated in AfterInitialize hook
- Retrieved by middleware on subsequent requests via type assertion
- Cleaned up automatically by session.Manager TTL worker
func GetVMCPSession ¶
func GetVMCPSession(sessionID string, mgr *transportsession.Manager) (*VMCPSession, error)
GetVMCPSession retrieves and validates a VMCPSession from the session manager.
This helper abstracts the common pattern of:
- Retrieving a session from the manager
- Type-asserting to *VMCPSession
- Handling errors with clear messages
func NewVMCPSession ¶
func NewVMCPSession(id string) *VMCPSession
NewVMCPSession creates a VMCPSession with initialized StreamableSession. The routing table is initially nil and will be populated during AfterInitialize hook.
This function panics if NewStreamableSession returns an unexpected type. This is intentional fail-fast behavior for programming errors that should be caught during development/testing. The type assertion should always succeed since NewStreamableSession is under our control and always returns *StreamableSession. A panic here indicates a bug in the transport layer that needs to be fixed, not a runtime condition to handle gracefully.
func (*VMCPSession) GetRoutingTable ¶
func (s *VMCPSession) GetRoutingTable() *vmcp.RoutingTable
GetRoutingTable retrieves the routing table for this session. Returns nil if capabilities have not been initialized yet.
func (*VMCPSession) GetTools ¶ added in v0.6.17
func (s *VMCPSession) GetTools() []vmcp.Tool
GetTools retrieves the tools list for this session. Returns nil if capabilities have not been initialized yet.
func (*VMCPSession) SetRoutingTable ¶
func (s *VMCPSession) SetRoutingTable(rt *vmcp.RoutingTable)
SetRoutingTable sets the routing table for this session. Called during AfterInitialize hook after capability discovery.
func (*VMCPSession) SetTools ¶ added in v0.6.17
func (s *VMCPSession) SetTools(tools []vmcp.Tool)
SetTools sets the tools list for this session. Called during AfterInitialize hook after capability discovery. The tools list includes InputSchema needed for type coercion in composite tool workflows.
func (*VMCPSession) Type ¶
func (*VMCPSession) Type() transportsession.SessionType
Type identifies this as a streamable vMCP session.