Skip to content

Conversation

@adam-skalicky
Copy link

@adam-skalicky adam-skalicky commented Jul 18, 2025

Currently one shot doc writing works, but modifying existing documents proves to be a challenge. With this PR I aim to add line level editing and styling to docs and sheets.

📄 Google Docs - New Functions (8 total)

Document Modification Functions:

  • insert_text_at_line() - Insert text at specific line numbers with intelligent index calculation
  • find_and_replace_text() - Pattern-based text replacement using Google Docs replaceAllText API
  • create_versioned_document() - Full document content replacement with automatic Drive backup creation

Native Styling Functions:

  • format_text_style() - Rich text formatting (bold, italic, underline, fonts, colors) using updateTextStyle
  • format_paragraph_style() - Paragraph formatting (alignment, spacing, indentation) using updateParagraphStyle
  • apply_heading_style() - Apply Google Docs named heading styles (H1-H6) using namedStyleType
  • create_list() - Create bullet/numbered lists with nesting using createParagraphBullets
  • _hex_to_rgb() - Helper function for hex color conversion to Google Docs RGB format

📊 Google Sheets - New Functions (6 total)

Cell Styling Functions:

  • format_cell_style() - Comprehensive cell formatting (text styles, colors, alignment) using repeatCell
  • format_cell_borders() - Professional border styling with various styles and colors using updateBorders
  • format_number_display() - Number formatting (currency, percentage, date, custom patterns) using numberFormat

Helper Functions:

  • _hex_to_rgb_sheets() - Color conversion for Google Sheets API
  • _parse_range_to_grid_range() - A1 notation to GridRange conversion for API calls
  • _get_format_fields() - Dynamic API field specification generator

adam-skalicky and others added 4 commits July 16, 2025 21:11
- Add insert_text_at_line function for line-based text insertion
- Add find_and_replace_text function with case sensitivity option
- Add create_versioned_document function with backup capability
- Include comprehensive input validation and error handling
- Update documentation to reflect new capabilities

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…eets

This commit implements native styling capabilities for both Google Docs and Google Sheets APIs, providing professional document formatting tools.

## Google Docs Styling Functions:
- `format_text_style()`: Apply text formatting including bold, italic, underline, font size/family, text/background colors
- `format_paragraph_style()`: Set paragraph formatting with alignment, line spacing, indentation, and spacing
- `apply_heading_style()`: Convert text to heading styles (H1-H6) using Google Docs named styles
- `create_list()`: Create bullet or numbered lists with configurable nesting levels
- `_hex_to_rgb()`: Helper function for hex color conversion to Google Docs RGB format

## Google Sheets Styling Functions:
- `format_cell_style()`: Apply cell formatting including bold, italic, colors, alignment, and font properties
- `format_cell_borders()`: Add comprehensive border styling with various styles, colors, and widths
- `format_number_display()`: Set number formatting (currency, percent, date, scientific, custom patterns)
- `_hex_to_rgb_sheets()`: Helper function for hex color conversion to Google Sheets RGB format
- `_parse_range_to_grid_range()`: Convert A1 notation to API GridRange format
- `_get_format_fields()`: Helper for generating API field specifications

## Key Features:
- Range-based operations for precise formatting control
- Comprehensive color support with hex codes (#FF0000)
- Professional styling options (borders, number formatting, headings)
- Input validation and error handling
- Efficient batchUpdate API operations
- Consistent with existing codebase patterns and standards

## Technical Implementation:
- Uses Google APIs batchUpdate operations for performance
- Follows existing authentication and error handling patterns
- Maintains consistent logging and parameter validation
- Implements proper RGB color conversion for both APIs
- Supports both named ranges and A1 notation for sheets

This enhancement significantly expands the MCP server's document formatting capabilities, enabling professional document creation and styling through the Google Workspace APIs.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Remove unintended changes to uv.lock file to keep dependency management clean.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@adam-skalicky adam-skalicky changed the title Feature/native styling support Sheets and Docs Fine Grain Editing and Styling Jul 18, 2025
@taylorwilsdon
Copy link
Owner

taylorwilsdon commented Jul 18, 2025

omg love this, didn't realize you were using it haha I'm sick today but will get this merged asap

@taylorwilsdon taylorwilsdon self-requested a review July 18, 2025 14:56
@taylorwilsdon taylorwilsdon self-assigned this Jul 18, 2025
@taylorwilsdon taylorwilsdon added the enhancement New feature or request label Jul 18, 2025
@adam-skalicky
Copy link
Author

I would hold off, seeing some bugs with styling apply. Going to bake in some additional selectors.

@adam-skalicky adam-skalicky marked this pull request as draft July 18, 2025 16:32
@taylorwilsdon
Copy link
Owner

Docs in great depth is now in place in main @adam-skalicky - love to get similar in place for sheets soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants