create_doc
Create a new Google Doc with optional HTML or Markdown content, images, tables, and links, and optionally place it in a specific Drive folder.
Instructions
Create a new Google Doc, optionally with initial content.
Content is interpreted as HTML by default. Pass content_format='markdown' to supply Markdown instead (headings, bold, italic, lists, links, tables, fenced code blocks, task list items, and images are all supported). Each table is inserted where it appears in the content. A table nested inside a table cell needs HTML content; Markdown has no syntax for one. In HTML, a line break inside a tag's text is a space, as a browser shows it: use or (or Markdown) for line structure. Plain text with no tags at all keeps each line as its own paragraph.
Images: a markdown "" (or an HTML ) is embedded inline.
src may be a local filesystem path (uploaded to Drive automatically), a
"drive:<file_id>" reference to an already-uploaded file, or a public http(s) URL
(used directly). A local-path or drive: image is temporarily shared anyone-with-
link/reader — required, since the Docs backend fetches inline images as an
anonymous HTTP request — then, by default, that share is revoked again once the
image is actually embedded (revoke_sharing=False leaves it shared instead; see
insert_local_images for the same tradeoff). Images inside table cells, nested
tables included, are embedded the same way. A local-path image is uploaded to
folder_id, else the server's default folder, else the new doc's own folder.
Per-image outcomes (including any resolution or sharing failure) are returned
under "images" when the content had any.
An image that can't be embedded (Docs can't fetch it, e.g. an SVG badge or an unreachable URL, or its source couldn't be resolved) is written as its alt text instead, keeping its link, or as its file name when the alt is empty. Its "images" entry then has an "error" and a "fallback_text" with that text. In a heading it's left out instead, so the heading's text, and a "#slug" link to it, stay as written; its entry has only the "error". A data: URI image can't be embedded (Docs takes an image only by URL).
A local-path or drive: image over Google Docs' ~25-megapixel or ~50MB inline-image limit fails with a clear error naming the limit it exceeds and its actual dimensions or file size, before any upload/share happens — set auto_downscale=True to resize it instead (see that arg's own docs). A public http(s) image can't be pre-validated this way; an oversized one instead fails at the embed step with a rewritten error explaining the likely cause.
Args: title: The title of the new document content: Optional content for the document body folder_id: Optional Google Drive folder ID where the document should be created. If not provided, creates in the root of My Drive. content_format: 'html' (default) or 'markdown' autolink_urls: When content_format='markdown', whether a bare http(s):// URL, www. address or email address (not already wrapped in a Markdown link or angle brackets) becomes a real hyperlink, as in GitHub Markdown (default True). Set False to leave them as plain text; to suppress just one instead of the whole call, wrap it in backticks. revoke_sharing: Whether a local-path/drive: image's temporary anyone:reader share is revoked again after it's embedded (default True). An image file that was already link-shared before the call keeps its link and is reported with already_shared: true. auto_downscale: Resize an oversized local-path/drive: image instead of failing it (default False). A drive: source gets a new " (resized)" copy created alongside the original (left untouched); a local-path source uploads the resized bytes directly instead of the original file. No effect on a public http(s) image source (see above).
Returns: Information about the newly created document including its ID and web link. Includes "images" (per-image outcomes) when content contained any images. Includes "dropped_links" when a link was written as plain text instead: a list of {"url", "reason"}, where reason is "no_scheme" for a target Docs can't store as a link (a relative path such as ./guide.md or /guide.md), or "no_matching_heading" for a "#slug" anchor that no heading matches. A scheme-less target that names a host is linked over https instead: //host/x as https://host/x, www.host as https://www.host. If the content can't be converted, returns {"error"} and creates no doc. If writing the content fails after the doc was created, returns {"error", "docId", "images", "dropped_links"} instead, with any temporary image share already revoked.
Note: Requires OAuth or ADC auth. Service accounts cannot create files in personal Drive (no storage quota). Works on Shared Drives regardless of auth method. Workaround for service accounts: create the file manually in Drive, then use write_doc_content to populate it. Check server://auth-status for your current auth method.
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": {
"title": "<title>"
},
"name": "create_doc"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| content | No | ||
| folder_id | No | ||
| autolink_urls | No | ||
| auto_downscale | No | ||
| content_format | No | html | |
| revoke_sharing | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||