Repository navigation
Commit 012d130
authored
fix(billing-cost-management-mcp-server): flag MONTHLY forecasts and RI/SP utilization entries wider than the request (#4919)
* fix(billing-cost-management-mcp-server): flag MONTHLY forecasts widened to whole months
With MONTHLY granularity, GetCostForecast and GetUsageForecast widen a
partial-month request to whole calendar months: a start that is not a
1st moves back to the 1st, and an end that is not a 1st moves forward to
the next 1st. A forecast that starts mid-month, including the tool's
default start (tomorrow), therefore returns the whole current month, and
that month's period and Total include its actual costs to date. Nothing
in the response or the description said so, so a "rest of the month"
forecast read as several times too large.
- Add period_note to getCostForecast and getUsageForecast results when
a MONTHLY request comes back wider than requested. It gives both
ranges, says when actual costs or usage are included (the first period
starts before today's UTC date), and points to DAILY granularity for
part of a month. The API's periods and Total are returned unchanged.
The note is also passed to the SQL offload so a stored result keeps it.
- Document the whole-month periods in the getCostForecast and
getUsageForecast notes of the cost-explorer description.
* fix(billing-cost-management-mcp-server): flag MONTHLY RI and SP utilization entries wider than the request
With MONTHLY granularity, GetReservationUtilization and
GetSavingsPlansUtilization label each entry with its whole calendar
month, but the figures cover only the requested days, at both ends. A
2026-01-24 to 2026-03-10 request returns a first entry labelled
2026-01-01 to 2026-02-01 holding 8 days and a last entry labelled
2026-03-01 to 2026-04-01 holding 9 days. ri-performance passed these
labels through with no request echo and no note, so a caller reported
partial-month hours and savings as whole months. sp-performance
documented only the start side.
- ri-performance: return requested_time_period from both operations,
add a RESPONSE PERIODS section to the description, and return
period_note from get_reservation_utilization when the first label
starts before the request or the last ends after it.
- sp-performance: describe the end-side snap too, say total covers only
the requested days, and return the same period_note from
get_savings_plans_utilization.
- cost-explorer getSavingsPlansUtilization (same API, when MONTHLY is
requested): return the same period_note and say so in its notes.
- utilities/time_utils: monthly_period_note, shared by all three.
Coverage (RI and SP) is not snapped, and grouped RI utilization is
labelled with the requested period; neither gets a note.
* fix(billing-cost-management-mcp-server): satisfy pyright in monthly_period_note and its tests
Take the periods as a Sequence of optional Mappings, narrow the label
strings inside one boolean expression, and pass a granularity string in
the grouped utilization test. No behavior change.
* docs(billing-cost-management-mcp-server): say which sp-performance entry ends early in the data lag
The data freshness note said the last entry can end before end_date, while
the response periods note says a MONTHLY last entry is labelled with its whole
month and so ends after it. Both hold: the first is about DAILY entries. Say so.
* fix(billing-cost-management-mcp-server): end period_note at the first day without data
For the current month, GetReservationUtilization and GetSavingsPlansUtilization
end the MONTHLY entry's label, and its data, at the first day without data,
which in the 2-3 day processing lag is before the requested end. period_note
still said the figures, and total, cover the request up to end_date, and said
nothing when only the lag shortened the window.
monthly_period_note now takes the granularity sent. For MONTHLY, a last label
that ends inside its own month before the requested end marks the lag: the
note says the lag days are not included and ends the covered range at that
label's end. A past month's label (ending on the 1st) and DAILY entries are
never treated as the lag. The ri-performance, sp-performance and cost-explorer
getSavingsPlansUtilization descriptions now name the current-month exception.1 parent cdf6896 commit 012d130
10 files changed
Lines changed: 860 additions & 14 deletions
File tree
- src/billing-cost-management-mcp-server
- awslabs/billing_cost_management_mcp_server
- tools
- utilities
- tests
- tools
- utilities
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
404 | 452 | | |
405 | 453 | | |
406 | 454 | | |
| |||
467 | 515 | | |
468 | 516 | | |
469 | 517 | | |
| 518 | + | |
| 519 | + | |
470 | 520 | | |
471 | 521 | | |
472 | 522 | | |
| |||
478 | 528 | | |
479 | 529 | | |
480 | 530 | | |
| 531 | + | |
481 | 532 | | |
482 | 533 | | |
483 | 534 | | |
| |||
552 | 603 | | |
553 | 604 | | |
554 | 605 | | |
| 606 | + | |
| 607 | + | |
555 | 608 | | |
556 | 609 | | |
557 | 610 | | |
| |||
561 | 614 | | |
562 | 615 | | |
563 | 616 | | |
| 617 | + | |
564 | 618 | | |
565 | 619 | | |
566 | 620 | | |
| |||
762 | 816 | | |
763 | 817 | | |
764 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
765 | 830 | | |
766 | | - | |
| 831 | + | |
767 | 832 | | |
768 | 833 | | |
769 | 834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
102 | 118 | | |
103 | 119 | | |
104 | 120 | | |
| |||
381 | 397 | | |
382 | 398 | | |
383 | 399 | | |
| 400 | + | |
384 | 401 | | |
385 | 402 | | |
386 | 403 | | |
| |||
539 | 556 | | |
540 | 557 | | |
541 | 558 | | |
| 559 | + | |
| 560 | + | |
542 | 561 | | |
543 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
544 | 570 | | |
545 | 571 | | |
546 | 572 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
| |||
377 | 383 | | |
378 | 384 | | |
379 | 385 | | |
380 | | - | |
| 386 | + | |
381 | 387 | | |
382 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
383 | 395 | | |
384 | 396 | | |
385 | 397 | | |
| |||
0 commit comments