Skip to content

Add OUTPUT_FORMAT support (defaults to text, supports json)#6

Open
sam-at-luther wants to merge 2 commits intoadd-transport-flagfrom
add-output-format
Open

Add OUTPUT_FORMAT support (defaults to text, supports json)#6
sam-at-luther wants to merge 2 commits intoadd-transport-flagfrom
add-output-format

Conversation

@sam-at-luther
Copy link
Member

This PR adds OUTPUT_FORMAT environment variable support to the Google Drive MCP server, following the same pattern as the HANA server implementation.

Changes

  • Add OUTPUT_FORMAT environment variable support (defaults to 'text')
  • When OUTPUT_FORMAT=json, gdrive_search returns structured JSON with files array containing id, name, mimeType, modifiedTime, and size
  • 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

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_search returns:

{
  "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

- 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.
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.

1 participant