Skip to content

Commit 3f51f6e

Browse files
committed
feat: add message to ProgressNotification
1 parent a0e968a commit 3f51f6e

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

examples/everything/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ func handleLongRunningOperationTool(
369369
"progress": i,
370370
"total": int(steps),
371371
"progressToken": progressToken,
372+
"message": fmt.Sprintf("Server progress %v%%", int(float64(i)*100/steps)),
372373
},
373374
)
374375
}

mcp/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ type ProgressNotification struct {
371371
Progress float64 `json:"progress"`
372372
// Total number of items to process (or total progress required), if known.
373373
Total float64 `json:"total,omitempty"`
374+
// Message related to progress. This should provide relevant human-readable
375+
// progress information.
376+
Message string `json:"message,omitempty"`
374377
} `json:"params"`
375378
}
376379

mcp/utils.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func NewProgressNotification(
129129
token ProgressToken,
130130
progress float64,
131131
total *float64,
132+
message *string,
132133
) ProgressNotification {
133134
notification := ProgressNotification{
134135
Notification: Notification{
@@ -138,6 +139,7 @@ func NewProgressNotification(
138139
ProgressToken ProgressToken `json:"progressToken"`
139140
Progress float64 `json:"progress"`
140141
Total float64 `json:"total,omitempty"`
142+
Message string `json:"message,omitempty"`
141143
}{
142144
ProgressToken: token,
143145
Progress: progress,
@@ -146,6 +148,9 @@ func NewProgressNotification(
146148
if total != nil {
147149
notification.Params.Total = *total
148150
}
151+
if message != nil {
152+
notification.Params.Message = *message
153+
}
149154
return notification
150155
}
151156

0 commit comments

Comments
 (0)