The _wrap_well_known_endpoint function assumed all route endpoints are regular
request handlers (async def handler(request) -> Response). However, the MCP
SDK's cors_middleware wraps handlers with CORSMiddleware, which is an ASGI app
expecting (scope, receive, send). When the wrapper called
`await endpoint(request)` on a CORSMiddleware instance, it passed only 1
argument instead of the required 3 ASGI args.
The fix detects whether the endpoint is a regular handler function or an ASGI
app (using the same inspect check as Starlette's Route constructor), and uses
the appropriate calling convention:
- Regular handlers: called as `await endpoint(request)` (existing behavior)
- ASGI apps: invoked via the ASGI interface `await endpoint(scope, receive, send)`
with response capture to apply cache-busting headers
https://claude.ai/code/session_011S5zFTWRfKBJBUEanrhvQg
Fixes#494 - Windows attachment corruption for PNG/PDF files.
On Windows, os.open() defaults to text mode, which translates LF (0x0a)
bytes to CRLF (0x0d 0x0a) during os.write(). This corrupts any binary
attachment containing 0x0a bytes (PNG headers, PDFs, etc.).
The fix adds os.O_BINARY to the os.open() flags using the standard
getattr(os, 'O_BINARY', 0) idiom, which returns the flag on Windows
and 0 (no-op) on platforms where it doesn't exist.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a new `get_doc_as_markdown` tool that converts Google Docs to clean
Markdown preserving formatting (headings, bold/italic/strikethrough, links,
code spans, ordered/unordered lists with nesting, and tables).
Optionally overlays comments with their anchor text (quotedFileContent) —
the specific text each comment is attached to — in two modes:
- inline: footnote-style references placed at the anchor text location
- appendix: all comments grouped at the bottom with blockquoted anchors
This gives AI agents full document context in a single tool call, unlike
get_doc_content which strips all formatting to plain text.
New files:
- gdocs/docs_markdown.py: Converter + comment formatting logic
- tests/gdocs/test_docs_markdown.py: 18 tests
Tool tier: extended (alongside search_docs, export_doc_to_pdf, etc.)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When reading comments via read_document_comments / read_spreadsheet_comments /
read_presentation_comments, the Drive API's quotedFileContent.value field is
now requested and displayed as "Quoted text:" in the output. This shows which
specific text in the document each comment is anchored to.
Comments without anchor text (document-level comments) omit the line.
Relates to #210
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously, get_messages and search_messages completely ignored the
attachment field on Chat API messages. This adds:
- Attachment metadata (filename, type) displayed inline in get_messages
and search_messages output
- New download_chat_attachment tool that downloads attachments via the
Chat API media endpoint and saves to local disk
The download uses httpx with a Bearer token against the
chat.googleapis.com/v1/media endpoint (with alt=media), which works
correctly in both OAuth 2.0 and OAuth 2.1 modes. The attachment's
downloadUri field is intentionally ignored as it points to
chat.google.com which requires browser session cookies.
Key details:
- Uses attachmentDataRef.resourceName for the media endpoint URL
- No new OAuth scopes required (existing chat_read is sufficient)
- Tool registered in the extended tier
- 10 unit tests covering metadata display, download, and edge cases