MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / disconnect

Method disconnect

mcp/server.go:992–1003  ·  view source on GitHub ↗

disconnect implements the binder[*ServerSession] interface, so that Servers can be connected using [connect].

(cc *ServerSession)

Source from the content-addressed store, hash-verified

990// disconnect implements the binder[*ServerSession] interface, so that
991// Servers can be connected using [connect].
992func (s *Server) disconnect(cc *ServerSession) {
993 s.mu.Lock()
994 defer s.mu.Unlock()
995 s.sessions = slices.DeleteFunc(s.sessions, func(cc2 *ServerSession) bool {
996 return cc2 == cc
997 })
998
999 for _, subscribedSessions := range s.resourceSubscriptions {
1000 delete(subscribedSessions, cc)
1001 }
1002 s.opts.Logger.Info("server session disconnected", "session_id", cc.ID())
1003}
1004
1005// ServerSessionOptions configures the server session.
1006type ServerSessionOptions struct {

Callers

nothing calls this directly

Calls 1

IDMethod · 0.65

Tested by

no test coverage detected