Skip to content

Commit 8046e28

Browse files
make handleNotify public
1 parent f37e549 commit 8046e28

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

mcp/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (c *Client) Connect(ctx context.Context, t Transport, _ *ClientSessionOptio
154154
hc.sessionUpdated(cs.state)
155155
}
156156
req2 := &initializedClientRequest{Session: cs, Params: &InitializedParams{}}
157-
if err := handleNotify(ctx, notificationInitialized, req2); err != nil {
157+
if err := HandleNotify(ctx, notificationInitialized, req2); err != nil {
158158
_ = cs.Close()
159159
return nil, err
160160
}
@@ -662,7 +662,7 @@ func (cs *ClientSession) callProgressNotificationHandler(ctx context.Context, pa
662662
// This can be used if the client is performing a long-running task that was
663663
// initiated by the server
664664
func (cs *ClientSession) NotifyProgress(ctx context.Context, params *ProgressNotificationParams) error {
665-
return handleNotify(ctx, notificationProgress, newClientRequest(cs, orZero[Params](params)))
665+
return HandleNotify(ctx, notificationProgress, newClientRequest(cs, orZero[Params](params)))
666666
}
667667

668668
// Tools provides an iterator for all tools available on the server,

mcp/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ func (ss *ServerSession) callProgressNotificationHandler(ctx context.Context, p
809809
// This is typically used to report on the status of a long-running request
810810
// that was initiated by the client.
811811
func (ss *ServerSession) NotifyProgress(ctx context.Context, params *ProgressNotificationParams) error {
812-
return handleNotify(ctx, notificationProgress, newServerRequest(ss, orZero[Params](params)))
812+
return HandleNotify(ctx, notificationProgress, newServerRequest(ss, orZero[Params](params)))
813813
}
814814

815815
func newServerRequest[P Params](ss *ServerSession, params P) *ServerRequest[P] {
@@ -896,7 +896,7 @@ func (ss *ServerSession) Log(ctx context.Context, params *LoggingMessageParams)
896896
if compareLevels(params.Level, logLevel) < 0 {
897897
return nil
898898
}
899-
return handleNotify(ctx, notificationLoggingMessage, newServerRequest(ss, orZero[Params](params)))
899+
return HandleNotify(ctx, notificationLoggingMessage, newServerRequest(ss, orZero[Params](params)))
900900
}
901901

902902
// AddSendingMiddleware wraps the current sending method handler using the provided

mcp/shared.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func orZero[T any, P *U, U any](p P) T {
114114
return any(p).(T)
115115
}
116116

117-
func handleNotify(ctx context.Context, method string, req Request) error {
117+
func HandleNotify(ctx context.Context, method string, req Request) error {
118118
mh := req.GetSession().sendingMethodHandler()
119119
_, err := mh(ctx, method, req)
120120
return err
@@ -351,7 +351,7 @@ func notifySessions[S Session, P Params](sessions []S, method string, params P)
351351
defer cancel()
352352
for _, s := range sessions {
353353
req := newRequest(s, params)
354-
if err := handleNotify(ctx, method, req); err != nil {
354+
if err := HandleNotify(ctx, method, req); err != nil {
355355
// TODO(jba): surface this error better
356356
log.Printf("calling %s: %v", method, err)
357357
}

0 commit comments

Comments
 (0)