mcp: add Session.ID (#67)
Support retrieving the session ID from client and server sessions. Fixes #65.
This commit is contained in:
parent
e1b1cd0072
commit
9b6327b3b7
1 changed files with 67 additions and 11 deletions
|
|
@ -505,6 +505,7 @@ func (ss *ServerSession) NotifyProgress(ctx context.Context, params *ProgressNot
|
|||
type ServerSession struct {
|
||||
server *Server
|
||||
conn *jsonrpc2.Connection
|
||||
mcpConn Connection
|
||||
mu sync.Mutex
|
||||
logLevel LoggingLevel
|
||||
initializeParams *InitializeParams
|
||||
|
|
@ -512,6 +513,17 @@ type ServerSession struct {
|
|||
keepaliveCancel context.CancelFunc
|
||||
}
|
||||
|
||||
func (ss *ServerSession) setConn(c Connection) {
|
||||
ss.mcpConn = c
|
||||
}
|
||||
|
||||
func (ss *ServerSession) ID() string {
|
||||
if ss.mcpConn == nil {
|
||||
return ""
|
||||
}
|
||||
return ss.mcpConn.SessionID()
|
||||
}
|
||||
|
||||
// Ping pings the client.
|
||||
func (ss *ServerSession) Ping(ctx context.Context, params *PingParams) error {
|
||||
_, err := handleSend[*emptyResult](ctx, ss, methodPing, params)
|
||||
|
|
|
|||
Loading…
Reference in a new issue