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

Method checkInitialized

mcp/server.go:1145–1158  ·  view source on GitHub ↗

checkInitialized returns a formatted error if the server has not yet received the initialized notification.

(method string)

Source from the content-addressed store, hash-verified

1143// checkInitialized returns a formatted error if the server has not yet
1144// received the initialized notification.
1145func (ss *ServerSession) checkInitialized(method string) error {
1146 if !ss.hasInitialized() {
1147 // TODO(rfindley): enable this check.
1148 // Right now is is flaky, because server tests don't await the initialized notification.
1149 // Perhaps requests should simply block until they have received the initialized notification
1150
1151 // if strings.HasPrefix(method, "notifications/") {
1152 // return fmt.Errorf("must not send %q before %q is received", method, notificationInitialized)
1153 // } else {
1154 // return fmt.Errorf("cannot call %q before %q is received", method, notificationInitialized)
1155 // }
1156 }
1157 return nil
1158}
1159
1160func (ss *ServerSession) ID() string {
1161 if c, ok := ss.mcpConn.(hasSessionID); ok {

Callers 4

ListRootsMethod · 0.95
CreateMessageMethod · 0.95
ElicitMethod · 0.95

Calls 1

hasInitializedMethod · 0.95

Tested by

no test coverage detected