Add OUTPUT_FORMAT support (defaults to text, supports json)#6
Open
sam-at-luther wants to merge 2 commits intoadd-transport-flagfrom
Open
Add OUTPUT_FORMAT support (defaults to text, supports json)#6sam-at-luther wants to merge 2 commits intoadd-transport-flagfrom
sam-at-luther wants to merge 2 commits intoadd-transport-flagfrom
Conversation
- Add OUTPUT_FORMAT environment variable support (defaults to 'text') - When OUTPUT_FORMAT=json, gdrive_search returns structured JSON with files array - When OUTPUT_FORMAT=json, gdrive_read_file returns JSON with fileId, mimeType, and content - Update error handling to return JSON errors when OUTPUT_FORMAT=json - Add helper functions isJsonOutput() and createResponse() - Update README.md with OUTPUT_FORMAT documentation and examples This follows the same pattern as mcp-server-hana PR #1 and allows programmatic consumption of responses instead of parsing text strings.
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.
This PR adds OUTPUT_FORMAT environment variable support to the Google Drive MCP server, following the same pattern as the HANA server implementation.
Changes
OUTPUT_FORMATenvironment variable support (defaults to'text')OUTPUT_FORMAT=json,gdrive_searchreturns structured JSON with files array containing id, name, mimeType, modifiedTime, and sizeOUTPUT_FORMAT=json,gdrive_read_filereturns JSON with fileId, mimeType, and contentOUTPUT_FORMAT=jsonisJsonOutput()andcreateResponse()Motivation
The current text output format (e.g., "Found 3 files:\nRent Value Update Report (application/vnd.google-apps.spreadsheet) - ID: mock_spreadsheet_123") is difficult for programs to parse and ingest. This change allows structured JSON responses that are easier to consume programmatically.
Example JSON Output
When
OUTPUT_FORMAT=json,gdrive_searchreturns:{ "files": [ { "id": "mock_spreadsheet_123", "name": "Rent Value Update Report", "mimeType": "application/vnd.google-apps.spreadsheet", "modifiedTime": "2024-01-01T00:00:00.000Z", "size": "1024" } ], "total": 1 }Related