Format read_inbox output like 9p-read-inbox

- Parse JSON and format as: [Message from X] / Type / Subject / Body
- Makes it clear who the sender is for replying
- Matches original 9p-read-inbox behavior
This commit is contained in:
Levi Neely 2026-02-18 22:14:01 +01:00
parent 7089aa96fb
commit 840453f2cc
2 changed files with 15 additions and 1 deletions

Binary file not shown.

View File

@ -266,7 +266,21 @@ func readInbox(agentID string) (string, error) {
fmt.Fprintf(os.Stderr, "[anvilmcp] Warning: Failed to mark message as complete: %v\n", err)
}
return string(data), nil
// Parse and format the message like 9p-read-inbox does
var msg map[string]interface{}
if err := json.Unmarshal(data, &msg); err != nil {
// If parsing fails, return raw JSON
return string(data), nil
}
// Format: [Message from {from}]\nType: {type}\nSubject: {subject}\n\n{body}
from, _ := msg["from"].(string)
msgType, _ := msg["type"].(string)
subject, _ := msg["subject"].(string)
body, _ := msg["body"].(string)
formatted := fmt.Sprintf("[Message from %s]\nType: %s\nSubject: %s\n\n%s", from, msgType, subject, body)
return formatted, nil
}
func sendMessage(from, to, msgType, subject, body string) error {