Add batch send sandbox email tool - #135
Conversation
📝 WalkthroughWalkthroughAdds the ChangesBatch sandbox email
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MCPClient
participant batchSendSandboxEmail
participant SandboxClient
MCPClient->>batchSendSandboxEmail: Submit batch request
batchSendSandboxEmail->>SandboxClient: Send transformed payload to resolved sandbox
SandboxClient-->>batchSendSandboxEmail: Return API response
batchSendSandboxEmail-->>MCPClient: Return success or error response
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tools/sandbox/utils/resolveSandboxId.ts`:
- Around line 10-18: Update resolveSandboxId to resolve process.env[envName]
before the compatibility fallback to MAILTRAP_TEST_INBOX_ID, while preserving
the explicit sandboxId precedence. Add coverage with both environment variables
set to verify batch-send-sandbox-email uses MAILTRAP_TEST_INBOX_ID when it
passes that envName.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9d72b351-8e63-4a4c-87d1-2f3f5a51b8f1
📒 Files selected for processing (9)
CLAUDE.mdREADME.mdsrc/server.tssrc/tools/sandbox/__tests__/batchSendSandboxEmail.test.tssrc/tools/sandbox/batchSendSandboxEmail.tssrc/tools/sandbox/index.tssrc/tools/sandbox/schemas/batchSendSandboxEmail.tssrc/tools/sandbox/utils/resolveSandboxId.tssrc/types/mailtrap.ts
MAILTRAP_TEST_INBOX_ID is a legacy alias for MAILTRAP_SANDBOX_ID, so a new tool should not advertise it — the schema description is what the model reads when deciding how to call the tool, and the error message is what a user sees when nothing is configured. Both now name the canonical variable. Renaming the parameter also removes the need for the paramName/envName arguments added to resolveSandboxId: the helper is back to its pre-PR form, identical to main, so this branch no longer touches a file shared by 14 tools. Legacy configs keep working via the helper's existing MAILTRAP_TEST_INBOX_ID fallback, now covered by a test. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/types/mailtrap.ts`:
- Around line 85-87: Rename the batch sandbox identifier from sandbox_id to
test_inbox_id across BatchSendSandboxEmailToolRequest and its related schema,
downstream handler, and documentation, matching SendSandboxEmailRequest and the
public contract. Ensure the handler reads test_inbox_id so caller-provided inbox
selection is preserved, and remove remaining batch-flow references to
sandbox_id.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f5364cd6-6dd3-4de1-b1e4-31f978e717e2
📒 Files selected for processing (7)
CLAUDE.mdREADME.mdsrc/server.tssrc/tools/sandbox/__tests__/batchSendSandboxEmail.test.tssrc/tools/sandbox/batchSendSandboxEmail.tssrc/tools/sandbox/schemas/batchSendSandboxEmail.tssrc/types/mailtrap.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- CLAUDE.md
- src/server.ts
- README.md
- src/tools/sandbox/batchSendSandboxEmail.ts
- src/tools/sandbox/tests/batchSendSandboxEmail.test.ts
- src/tools/sandbox/schemas/batchSendSandboxEmail.ts
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Summary
The
mailtrapSDK exposesbatchSendagainst all three sending streams, but the MCP server only wired up two of them. The send surface is a 3×2 grid (transactional / bulk / sandbox × singlesend/batchSend), and the sandbox×batch cell was empty:send()batchSend()send-emailbatch-send-transactional-emailbatch-send-bulk-emailsend-sandbox-emailbatch-send-sandbox-email(this PR)Registers one new tool,
batch-send-sandbox-email, so sandbox users can batch in a single API call instead of loopingsend-sandbox-email.Changes
src/tools/sandbox/batchSendSandboxEmail.ts): resolves the sandbox, builds the payload, posts via a sandbox client.buildBatchPayload,getSandboxClient, andresolveSandboxIdwere already stream-agnostic, so no new client, payload, or resolver logic was needed — the SDK routes toTESTING_ENDPOINT/api/batch/{inboxId}on its own.src/tools/sandbox/schemas/batchSendSandboxEmail.ts): the shared batch schema plussandbox_id. Built by spreading into a freshpropertiesobject — all three batch tools re-export one shared schema object, so an in-place edit would leaksandbox_idinto the transactional and bulk tools.src/types/mailtrap.ts):BatchSendSandboxEmailToolRequestextends the existing batch request withsandbox_id.server.ts, plusREADME.mdandCLAUDE.md. Also corrected theMAILTRAP_ACCOUNT_ID/DEFAULT_FROM_EMAILnotes, which listed only the single-send tools but apply to the batch tools too, and flaggedMAILTRAP_TEST_INBOX_IDas the legacy alias it is.sandbox_idnot leaking into the SDK payload,MAILTRAP_SANDBOX_IDfallback, legacyMAILTRAP_TEST_INBOX_IDfallback and its precedence, missing-sandbox error, validation passthrough, API error prefix.Notes
batch-send-sandbox-email, not "bulk sandbox": the SDK throwsBULK_SANDBOX_INCOMPATIBLEwhenbulkandsandboxare both set, so that combination cannot exist. The axis these tools vary on is the stream.sandbox_id, nottest_inbox_id.MAILTRAP_TEST_INBOX_IDis a legacy alias forMAILTRAP_SANDBOX_ID, and a new tool shouldn't advertise it — the schema description is what the model reads when deciding how to call the tool, and the error message is what a user sees when nothing is configured. Existing configs still resolve viaresolveSandboxId'sMAILTRAP_SANDBOX_ID ?? MAILTRAP_TEST_INBOX_IDfallback, which is covered by a test. This also means the tool needs no changes toresolveSandboxIditself, so the PR doesn't touch a helper shared by 14 other tools.send-sandbox-email's human-readable summary, which would discardbatchSend's per-requesterrors[].to/cc/bccrather than requiringto, matchingbuildBatchPayload's actual behaviour over the SDK's stricter type.attachmentsremains unsupported here, consistent with the four existing send tools. The SDK accepts it on batchbase, eachrequests[]entry, and singleMail, but every MCP send schema omits it underadditionalProperties: false— worth its own ticket rather than a one-off divergence.Follow-up (not in this PR)
send-sandbox-email,get-sandbox-messages,show-sandbox-email-message, andget-sandbox-inboxpredateresolveSandboxIdand inline their own env lookup, reading only the legacyMAILTRAP_TEST_INBOX_IDwith noMAILTRAP_SANDBOX_IDfallback. So a config with onlyMAILTRAP_SANDBOX_IDset works for this new tool but errors on those four. Routing them throughresolveSandboxIdis a clean separate change — their existing error strings already match the helper's output.Summary by CodeRabbit
New Features
batch-send-sandbox-emailtool.Documentation