Sanitize AgentMail message read arguments - #13
Open
toanminhbui wants to merge 1 commit into
Open
toanminhbui wants to merge 1 commit into
toanminhbui wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
list_messagesandsearch_messagesfrom the AgentMail connection fail whenever Vee reads email:MCP error -32602: Invalid arguments for tool list_messages: expected: "date" received: "Invalid Date" path: ["before"] / ["after"]HTTP 400: Request validation failed.get_inboxworks, so auth/transport are healthy. Prompt-level fixes (PR #12) did not help because the empty strings originate from the model filling optional fields of the raw tool schema, and Eve/@ai-sdk/mcppass model-emitted arguments to the MCP server verbatim — AgentMail then parses""as a datetime.Fix
Follow the established
list_agentmail_inboxespattern (authored tools calling the authenticated MCP connection directly), with argument sanitization at the boundary we control:sanitizeAgentMailArguments(agent/lib/agentmail-sanitize.ts) — recursively strips empty strings, empty arrays, and null/undefined while preserving meaningful falsy values (false,0).list_agentmail_messagesandsearch_agentmail_messageswith clean typed input schemas (RFC 3339 datetimes, non-empty query) that sanitize arguments beforecallTool.list_messages/search_messages; raw tools remain exposed but unused.get_threadstays as-is for full threads.agentMailAuthOptions; update connection description and changelog.Argument names/types were verified against AgentMail's canonical
mcp-manifest.json.Verification
pnpm typecheck— passpnpm test— 10/10 pass (6 new sanitizer tests + 4 existing)pnpm build— pass