Repository navigation
Description
Problem
When importing security vulnerability reports from a PonyMail-backed mailing list via the issue-import skill, email attachments (test files, patches, PoC archives) cannot be downloaded. The PonyMail MCP server's get_source tool truncates output to 12,000 characters, and get_mbox similarly truncates — base64-encoded attachments are always cut off.
The get_email tool lists attachments with their hashes and filenames but provides no way to download the actual content.
Impact
Security reports frequently include reproducer test files and patches as attachments. Without attachment extraction, a PMC member must manually download them from a browser, breaking the import workflow.
Workaround
A Python script that bypasses the MCP truncation by fetching the raw MIME source directly from the PonyMail API (/api/source.json) and decoding the MIME parts with Python's email module:
#!/usr/bin/env python3
"""Extract MIME attachments from a PonyMail email by message ID.
Usage:
python3 -I extract-email-attachments.py <message-id> [output-dir]
Requires a valid PonyMail session in ~/.ponymail-mcp/session.json.
"""
import email
import email.policy
import json
import os
import sys
import urllib.request
def main():
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <message-id> [output-dir]", file=sys.stderr)
sys.exit(2)
msg_id = sys.argv[1]
outdir = sys.argv[2] if len(sys.argv) > 2 else "."
outdir = os.path.abspath(outdir)
base_url = os.environ.get("PONYMAIL_BASE_URL", "https://lists.apache.org")
api_url = f"{base_url}/api/source.json"
session_file = os.path.expanduser("~/.ponymail-mcp/session.json")
with open(session_file) as f:
cookie = json.load(f)["cookie"]
req = urllib.request.Request(
api_url,
data=json.dumps({"id": msg_id}).encode(),
headers={
"Content-Type": "application/json",
"Accept": "text/plain",
"Cookie": cookie,
},
method="POST",
)
with urllib.request.urlopen(req) as resp:
raw = resp.read()
msg = email.message_from_bytes(raw, policy=email.policy.default)
count = 0
for part in msg.walk():
fn = part.get_filename()
if fn:
data = part.get_content()
if isinstance(data, str):
data = data.encode()
outpath = os.path.join(outdir, fn)
with open(outpath, "wb") as f:
f.write(data)
print(f"Saved: {fn} ({len(data)} bytes)")
count += 1
if count == 0:
print("No attachments found in MIME message", file=sys.stderr)
sys.exit(1)
print(f"\nExtracted {count} attachment(s) to {outdir}")
if __name__ == "__main__":
main()Suggested approach
-
Preferred: Add a
get_attachmenttool to the PonyMail MCP server that downloads individual attachments by email ID + attachment hash (already available fromget_emailresponse). This would fix the problem at the source for all MCP consumers. -
Alternative: Ship the workaround script above as a utility in the
magpie-securityfamily, and haveissue-importcall it when attachments are detected. The script reuses the PonyMail session cookie from~/.ponymail-mcp/session.json.
Context
Discovered while importing security reports for the Apache Tomcat PMC. Emails with .java test files and .patch attachments (4-7 KB each) were truncated by the MCP tool. The workaround script successfully extracted all attachments.
Activity
potiuk commentedon Oct 23, 2026
Nice !
feat(security): fetch and decrypt report attachments through PonyMail
feat(security): fetch and decrypt report attachments through PonyMail (…