DEV Community

ryoto miyake
ryoto miyake

Posted on

Claude-Gemini Integration Tool "CGMB" v1.1.0: Implementing Windows Support

I've released v1.1.0 of "CGMB," an MCP tool that integrates Claude Code and Gemini.

Previous article: Bridging Claude and Gemini: Creating the Multimodal Integration Tool "CGMB"

What You'll Learn

  • 4 new features added in v1.1.0
  • Implementation details of Windows path normalization
  • How URL auto-routing works

v1.1.0 New Features

Feature Description Status
πŸͺŸ Windows Support Path normalization & drive letter handling βœ… Full Support
πŸ“ OCR Feature Scanned PDF support βœ… New
πŸ”„ URL Auto-Routing Layer selection by URL type βœ… New
πŸš€ Latest Models gemini-3-flash, gemini-2.5-flash βœ… Supported

Windows Path Implementation

The Challenge

v1.0 only supported Unix paths, but Windows paths have these characteristics:

  • Start with a drive letter (C:, D:, etc.)
  • Use backslash (\) as separator
  • May have mixed forward slashes (C:/Users/...)

Node.js's path.isAbsolute() can correctly determine Windows paths, but cannot handle mixed slashes.

Implementation

Handled in the validateAndNormalize method of CGMBServer.ts:

// Detect Windows absolute path pattern (case-insensitive)
const isWindowsAbsolutePath = /^[A-Za-z]:[/\\]/.test(filePath);

if (isWindows && isWindowsAbsolutePath) {
  // Normalize forward slashes to backslashes
  preprocessedPath = filePath.replace(/\//g, '\\');
}

const normalizedPath = path.normalize(preprocessedPath);

// Absolute path detection (considering Windows pattern)
const isAbsolute = path.isAbsolute(normalizedPath) || isWindowsAbsolutePath;
const resolvedPath = isAbsolute
  ? normalizedPath
  : path.resolve(baseDir, normalizedPath);
Enter fullscreen mode Exit fullscreen mode

Key Points:

  1. Regex /^[A-Za-z]:[/\\]/ detects drive letters
  2. Unify slashes before path.normalize() normalization
  3. Combine path.isAbsolute() result with Windows pattern detection

File Path Extraction from Prompts

v1.1.0 automatically detects file paths written in prompts.

// Regex to detect both Windows + Unix paths
const filePathRegex = /(?:[A-Za-z]:\\[^\s"'<>|]+\.[a-zA-Z0-9]+|\/(?!https?:)[^\s"'<>|]+\.[a-zA-Z0-9]+|\.\.?\/[^\s"'<>|]+\.[a-zA-Z0-9]+)/gi;

const localPathsInPrompt = prompt.match(filePathRegex) || [];
Enter fullscreen mode Exit fullscreen mode

This enables usage like:

CGMB analyze C:\Users\name\Documents\report.pdf
CGMB analyze /home/user/documents/report.pdf
Enter fullscreen mode Exit fullscreen mode

URL Auto-Routing

Determines URL type and automatically routes to the optimal AI layer.

private detectUrlType(url: string): 'pdf' | 'image' | 'audio' | 'web' {
  const lower = url.toLowerCase();
  const urlPath = lower.split('?')[0] ?? lower;

  if (urlPath.endsWith('.pdf') || lower.includes('/pdf')) {
    return 'pdf';
  }

  if (/\.(png|jpg|jpeg|gif|webp|bmp|svg)$/.test(urlPath)) {
    return 'image';
  }

  if (/\.(mp3|wav|m4a|ogg|flac|aac)$/.test(urlPath)) {
    return 'audio';
  }

  return 'web';
}
Enter fullscreen mode Exit fullscreen mode

Routing Destinations

URL Type Destination Reason
PDF AI Studio OCR processing via Gemini File API
Images/Audio AI Studio Multimodal processing
Web Pages Gemini CLI Real-time information retrieval

Installation & Upgrade

# New installation
npm install -g claude-gemini-multimodal-bridge

# Upgrade
npm update -g claude-gemini-multimodal-bridge
Enter fullscreen mode Exit fullscreen mode

Improvements from v1.0.0

Item v1.0.0 v1.1.0
Windows Support ❌ Unix only βœ… Full support
OCR Feature ❌ None βœ… Scanned PDF support
URL Routing Basic βœ… Type-based auto-selection
Gemini Models gemini-2.0-flash βœ… gemini-3-flash support

Future Plans

  • More advanced routing algorithms
  • Quick support for new Gemini models
  • Performance optimization

Links

Feedback and Issues are welcome!

Top comments (0)