fetch_email_thread
Retrieve email conversation threads by searching subject keywords across recent messages to restore complete discussions.
Instructions
제목 키워드로 이메일 스레드(대화)를 복원합니다. 최근 100건에서 검색합니다.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"subject_keyword": "<subject_keyword>"
},
"name": "fetch_email_thread"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subject_keyword | Yes | 제목에 포함된 키워드 |
Implementation Reference
- src/email-tools.ts:161-200 (handler)The implementation of the `fetch_email_thread` tool logic, which retrieves and sorts emails matching a subject keyword.
case "fetch_email_thread": { if (!args.subject_keyword || typeof args.subject_keyword !== "string") { return { content: [{ type: "text" as const, text: "오류: subject_keyword는 필수 문자열 파라미터입니다." }], isError: true }; } const keyword = args.subject_keyword.toLowerCase(); const emails = await withConnection(config, async (client) => { const headers = await client.list(100); const matched = headers.filter((h) => h.subject.toLowerCase().includes(keyword) ); const results = []; for (const h of matched) { try { results.push(await client.getEmail(h.id)); } catch { /* skip */ } } return results.sort( (a, b) => new Date(a.date).getTime() - new Date(b.date).getTime() ); }); if (emails.length === 0) { return { content: [{ type: "text" as const, text: `"${args.subject_keyword}" 관련 스레드를 찾을 수 없습니다.` }], }; } const text = emails .map( (e) => `### ${e.subject}\n` + `From: ${e.from} | ${e.date ? new Date(e.date).toLocaleString("ko-KR") : ""}\n\n` + `${e.body}` ) .join("\n\n---\n\n"); return { content: [{ type: "text" as const, text: `스레드 (${emails.length}건):\n\n${text}` }], }; } - src/email-tools.ts:52-62 (schema)The definition and schema for `fetch_email_thread` tool.
{ name: "fetch_email_thread", description: "제목 키워드로 이메일 스레드(대화)를 복원합니다. 최근 100건에서 검색합니다.", inputSchema: { type: "object" as const, properties: { subject_keyword: { type: "string", description: "제목에 포함된 키워드" }, }, required: ["subject_keyword"], }, },