Skip to content

Commit 5378d0f

Browse files
authored
feat: add message to ProgressNotification (#119)
1 parent 79a0ac0 commit 5378d0f

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
@@ -130,6 +130,7 @@ func NewProgressNotification(
130130
token ProgressToken,
131131
progress float64,
132132
total *float64,
133+
message *string,
133134
) ProgressNotification {
134135
notification := ProgressNotification{
135136
Notification: Notification{
@@ -139,6 +140,7 @@ func NewProgressNotification(
139140
ProgressToken ProgressToken `json:"progressToken"`
140141
Progress float64 `json:"progress"`
141142
Total float64 `json:"total,omitempty"`
143+
Message string `json:"message,omitempty"`
142144
}{
143145
ProgressToken: token,
144146
Progress: progress,
@@ -147,6 +149,9 @@ func NewProgressNotification(
147149
if total != nil {
148150
notification.Params.Total = *total
149151
}
152+
if message != nil {
153+
notification.Params.Message = *message
154+
}
150155
return notification
151156
}
152157

0 commit comments

Comments
 (0)