Improve MCP serve polling and attachment extraction reliability - #32556
Improve MCP serve polling and attachment extraction reliability#32556aydnOktay wants to merge 3 commits into
Conversation
Add UTC Z-aware timestamp parsing for EventBridge polling, deduplicate extracted attachments, and normalize MEDIA tag paths by stripping trailing punctuation, with regression tests covering each behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
Run pull-request test jobs against changed and related test files while keeping full-suite runs on main pushes, and narrow supply-chain critical pattern scanning to reduce fixture-driven false positives. Co-authored-by: Cursor <cursoragent@cursor.com>
|
This PR bundles fixes from three existing open PRs by the same author into a single submission:
All three fixes target mcp_serve.py. Consider whether this superset PR supersedes the individual ones or should be split. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for combining the attachment regressions and adding focused coverage. The attachment work remains relevant, but this branch needs selective salvage against current main.
Problems
- Current
mcp_serve.py:442-472now uses the state.db routing index introduced by747386ecf; the PR's sessions.json mtime/cache polling context is obsolete and should not be restored. mcp_serve.py:182in the PR strips!,),], quotes, and other legal filename suffixes unconditionally. That can turn a validMEDIA:path into a different path.- The Z-timestamp change is redundant: supported Python is
>=3.11(pyproject.toml:20), and current main already callsdatetime.fromisoformatfor EventBridge timestamps (mcp_serve.py:500).
Suggested changes
- Port only the attachment behavior onto the current state.db-based polling implementation.
- Preserve literal filenames ending in punctuation, with regression coverage for that case, before adding punctuation normalization.
Automated hermes-sweeper review.
| media_pattern = re.compile(r'MEDIA:\s*(\S+)') | ||
| for match in media_pattern.finditer(text): | ||
| path = match.group(1) | ||
| path = match.group(1).rstrip(".,;:!?)]}\"'") |
There was a problem hiding this comment.
This unconditionally changes valid local filenames such as MEDIA:/tmp/report! or MEDIA:/tmp/a]. Please use a delimiter-aware MEDIA syntax, or otherwise preserve literal punctuation and add coverage for those valid path suffixes.
|
Closing to concentrate review on a single linked product bug: #89979. |
|
Closing to concentrate review on a single linked product bug: #89979. |
This PR strengthens mcp_serve.py by making EventBridge polling reliable for ISO-8601 UTC timestamps with a Z suffix, deduplicating extracted attachments while preserving order, and normalizing MEDIA: paths so trailing sentence punctuation is not captured as part of file paths; it adds focused regression coverage in tests/test_mcp_serve.py for each behavior and includes PR CI hardening so checks run targeted related tests instead of the full unrelated suite, while supply-chain scanning avoids recurring fixture-driven critical false positives.