Fix mcp ps uptime: parse StartedAt from podman ps JSON

List() was not extracting the StartedAt field from podman's JSON
output, so LiveCheck always returned zero timestamps and the CLI
showed "-" for every container's uptime.

podman ps --format json includes StartedAt as a Unix timestamp
(int64). Parse it into ContainerInfo.Started so the existing
LiveCheck → CLI uptime display chain works.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-27 22:56:39 -07:00
parent f06ab9aeb6
commit cedba9bf83

View File

@@ -219,6 +219,7 @@ type podmanPSEntry struct {
Image string `json:"Image"` Image string `json:"Image"`
State string `json:"State"` State string `json:"State"`
Command []string `json:"Command"` Command []string `json:"Command"`
StartedAt int64 `json:"StartedAt"`
} }
// List returns information about all containers. // List returns information about all containers.
@@ -240,12 +241,16 @@ func (p *Podman) List(ctx context.Context) ([]ContainerInfo, error) {
if len(e.Names) > 0 { if len(e.Names) > 0 {
name = e.Names[0] name = e.Names[0]
} }
infos = append(infos, ContainerInfo{ info := ContainerInfo{
Name: name, Name: name,
Image: e.Image, Image: e.Image,
State: e.State, State: e.State,
Version: ExtractVersion(e.Image), Version: ExtractVersion(e.Image),
}) }
if e.StartedAt > 0 {
info.Started = time.Unix(e.StartedAt, 0)
}
infos = append(infos, info)
} }
return infos, nil return infos, nil