Skip to content

feat: google_drive write tools and read comment tool#1650

Merged
kalvinnchau merged 22 commits intoblock:mainfrom
sheagcraig:gdrive-write
Mar 14, 2025
Merged

feat: google_drive write tools and read comment tool#1650
kalvinnchau merged 22 commits intoblock:mainfrom
sheagcraig:gdrive-write

Conversation

@sheagcraig
Copy link
Copy Markdown
Contributor

Hi friends!
This PR adds the ability to the Gdrive MCP server to upload files (just whatever you want) and to create and update Google Docs, Sheets, and Slides.

I have some other tools coming, but I'm waiting on perms from our Google admins for the app, so I figured I'd start the process of getting this reviewed.

* upstream/main: (48 commits)
  feat: enable smart approve for user by default (#1599)
  ui: fix modal state (#1598)
  ui: setting configuration (#1597)
  fix: merge error logging in goose bench  (#1545)
  feat: add additional goosebench evals (#1571)
  chore: update types and imports (#1594)
  Retain session through view changes (#1580)
  docs: Add steps for desktop tutorial (#1590)
  remove env vars from bottom menu model setting (#1584)
  Fix Goosehints modal UI (#1581)
  docs: typo fix (#1593)
  feat: update config endpoints for use with providers (#1563)
  fix: update anthropic provider headers (#1592)
  feat: Build Goose in a Docker Container (#1551)
  docs: voyp blog post (#1588)
  fix: included files was panicing because dir didnt exist (#1583)
  feat: work with docs/xls and simple html (#1526)
  feat: parallel processing in approve mode (#1575)
  Feat: support auto-including dirs in binary/bench-work-dir (#1576)
  refactor models component (#1535)
  ...
@sheagcraig sheagcraig marked this pull request as ready for review March 12, 2025 20:00
* upstream/main:
  feat(google_drive): move credentials into keychain, add optional fallback (#1603)
  feat: add session list command in cli (#1586)
  feat: google sheets support (in google drive builtin MCP server) (#1601)
  fix: deep link opening when window is closed (#1633)
  docs: edits to docker guide (#1639)
  feat: ollama tool shim (#1448)
  feat: add write approve mode (#1628)
  ui: auto update card upon config (#1610)
  fix: fix tool output expansion checks (#1634)
  fix: remove conditional that breaks output display for tool calls (#1631)
  docs: Persistent Command History (#1627)
  change to make build work on windows, macos, linux (#1618)
  chore(release): release version 1.0.13 (#1623)
  fix: handle mac screenshots with the image tool (#1622)
  feat: write eval results to eval dir (#1620)
  [fix] fix model config logging to remove api key (#1619)
  fix: ensure repeating benches return to initial run-dir (#1617)
@sheagcraig sheagcraig changed the title Gdrive write feat: Gdrive write Mar 12, 2025
Copy link
Copy Markdown
Contributor

@kalvinnchau kalvinnchau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

Instead of defaulting to true for:

            .supports_team_drives(true)
            .supports_all_drives(true)

Should all the write operations also take in a parameter about the drive its writing to (like the corpora in search) so that by default we only write to a user's personal drive and only write to shared drives when explicitly asked to?

I noticed a bunch of duplication for upload/create files, could we extract that to some helper function and pass in params?

something like this?

enum FileOperation {
    Create { name: String },
    Update { file_id: String },
}

async fn upload_file(
    &self,
    operation: FileOperation,
    content: Box<dyn ReadSeek>,
    source_mime_type: &str,
    target_mime_type: &str,
) -> Result<Vec<Content>, ToolError> {
// body
}

// then upload/upload_doc/create_doc:
async fn upload(&self, params: Value) -> Result<Vec<Content>, ToolError> {
    //get params/content

    self.upload_file(
        FileOperation::Create { name: name.to_string() },
        content,
        mime_type,
        mime_type
    ).await

async fn create_doc(&self, params: Value) -> Result<Vec<Content>, ToolError> {
   // get params

    let source_mime_type = "text/markdown";
    let target_mime_type = "application/vnd.google-apps.document";
    let content = Box::new(Cursor::new(body.as_bytes()));

    self.upload_file(
        FileOperation::Create { name: name.to_string() },
        content,
        source_mime_type,
        target_mime_type
    ).await
}

@sheagcraig
Copy link
Copy Markdown
Contributor Author

@kalvinnchau thanks for catching all of those dumb mistakes. I've been running Zed instead of vim and I think it's doing some completions for me that are making me whiff on things like that.

I'll incorporate all of these tomorrow morning.

@sheagcraig
Copy link
Copy Markdown
Contributor Author

Okay-I updated to add a bool whether you want to allow the tool to access just your drive, or all of your available drives.

I also added a parent arg which lets you specify a folder ID to save a newly created folder in (didn't do this for updates because that works differently, and I'm going to write a move func.

So that's great! It defaults to not using "all drives", and it defaults to saving at the root of your drive.

The only problem is, even just doing this in the MCP inspector, I can't get it to actually upload files into another "parent" folder. I tried folders that are in "My Drive" as well as shared ones to no avail. So probably something we'll have to experiment with down the road.

Copy link
Copy Markdown
Contributor

@kalvinnchau kalvinnchau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@kalvinnchau kalvinnchau changed the title feat: Gdrive write feat: google_drive write tools and read comment tool Mar 14, 2025
@kalvinnchau kalvinnchau merged commit 8bda119 into block:main Mar 14, 2025
6 checks passed
kalvinnchau added a commit that referenced this pull request Mar 14, 2025
* origin/main: (29 commits)
  ui: reorganize extensions settings (#1702)
  feat: google_drive write tools and read comment tool (#1650)
  fix: developer builtin name (#1699)
  chore: update extensions section to work with new endpoints (#1696)
  chore: move things around (#1662)
  ui: extensions state updates (#1674)
  docs: goose ollama blog, updated (#1691)
  ui: load builtins (#1679)
  chore(release): release version 1.0.14 (#1676)
  Revert "feat: handling larger more complex PDF docs (and fix) (#1663)" (#1675)
  fix: uvshim default to existing uv configuration (#1670)
  fix: handle interruptions during tool responses (#1651)
  feat: Copy error message button in toast (#1658)
  feat: handling larger more complex PDF docs (and fix) (#1663)
  Add Filesystem Tutorial (#1666)
  docs: figma blog post (#1647)
  docs: updating goose modes doc (#1665)
  docs: Add running tasks guide (#1626)
  docs: Add experimental features (#1644)
  feat(cli): add better error message, support stdin via -i - or just no args (#1660)
  ...
laanak08 added a commit that referenced this pull request Mar 16, 2025
* main: (31 commits)
  feat: add default metrics for core evals (#1602)
  feat(google_drive): use oauth2 crate for PKCE support, make token storage generic over Serializable (#1645)
  ui: reorganize extensions settings (#1702)
  feat: google_drive write tools and read comment tool (#1650)
  fix: developer builtin name (#1699)
  chore: update extensions section to work with new endpoints (#1696)
  chore: move things around (#1662)
  ui: extensions state updates (#1674)
  docs: goose ollama blog, updated (#1691)
  ui: load builtins (#1679)
  chore(release): release version 1.0.14 (#1676)
  Revert "feat: handling larger more complex PDF docs (and fix) (#1663)" (#1675)
  fix: uvshim default to existing uv configuration (#1670)
  fix: handle interruptions during tool responses (#1651)
  feat: Copy error message button in toast (#1658)
  feat: handling larger more complex PDF docs (and fix) (#1663)
  Add Filesystem Tutorial (#1666)
  docs: figma blog post (#1647)
  docs: updating goose modes doc (#1665)
  docs: Add running tasks guide (#1626)
  ...
cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants