Skip to main content

MCP server that bridges Claude Code to Gemini CLI for workflow tasks like codebase analysis, specification creation, and code review

Project description

Gemini Workflow Bridge MCP v2.0

Gemini as Context Compression Engine + Claude as Reasoning Engine = A-Grade Results

What's New in v2.0 ๐Ÿš€

Version 2.0 is a complete redesign that transforms this MCP from a "spec generation tool" to a "context compression engine" that optimally leverages both Claude Code and Gemini's strengths.

Key Improvements

  • โœ… Quality: B-grade โ†’ A-grade specifications (Gemini provides facts, Claude does reasoning)
  • โœ… Cost: 47-61% reduction in Claude tokens (expensive operations move to free Gemini tier)
  • โœ… Compression: 174:1 token compression ratio (50K tokens โ†’ 300 token summaries)
  • โœ… DX: Auto-generated workflows and slash commands for common tasks

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Claude Code (Reasoning Engine)        โ”‚
โ”‚   - Superior planning & specifications  โ”‚
โ”‚   - Precise code editing                โ”‚
โ”‚   - A-grade output quality              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚ MCP Protocol
               โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   MCP Server (Compression Layer)        โ”‚
โ”‚   - 50K tokens โ†’ 300 token summaries    โ”‚
โ”‚   - Fact extraction only                โ”‚
โ”‚   - Validation & consistency checks     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚ Gemini CLI
               โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Gemini (Context Engine)               โ”‚
โ”‚   - 2M token window (free tier)         โ”‚
โ”‚   - Factual extraction only             โ”‚
โ”‚   - No opinions or planning             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Installation

Prerequisites

  1. Gemini CLI - Install and authenticate:

    npm install -g @google/gemini-cli
    gemini  # Follow authentication prompts
    
  2. Python 3.11+ with pip

Install the MCP Server

# Clone the repository
git clone https://github.com/hitoshura25/gemini-workflow-bridge-mcp
cd gemini-workflow-bridge-mcp

# Install dependencies
pip install -e .

Configure Claude Code

Add to your Claude Code MCP settings (typically claude_desktop_config.json):

{
  "mcpServers": {
    "gemini-workflow-bridge": {
      "command": "python",
      "args": ["-m", "hitoshura25_gemini_workflow_bridge"],
      "env": {
        "CONTEXT_CACHE_TTL_MINUTES": "30",
        "MAX_TOKENS_PER_ANSWER": "300",
        "TARGET_COMPRESSION_RATIO": "100"
      }
    }
  }
}

Quick Start

# 1. Extract facts about your codebase
query_codebase_tool(
    questions=["How is authentication implemented?"],
    scope="src/"
)
# Returns: Compressed facts with file:line references

# 2. Create specification using those facts (Claude does this)
# [Your reasoning creates A-grade spec here]

# 3. Validate specification
validate_against_codebase_tool(
    spec_content="...",
    validation_checks=["missing_files", "undefined_dependencies"]
)
# Returns: Completeness score, issues, suggestions

Documentation

Tools Overview

๐Ÿ” Tier 1: Fact Extraction

Tool Purpose Key Feature
query_codebase_tool() Multi-question analysis 174:1 compression ratio
find_code_by_intent_tool() Semantic search Returns summaries, not full code
trace_feature_tool() Follow execution flow Step-by-step with data flow
list_error_patterns_tool() Extract patterns Filtering at the edge

โœ… Tier 2: Validation

Tool Purpose
validate_against_codebase_tool() Validate specs for completeness
check_consistency_tool() Verify pattern alignment

๐Ÿš€ Tier 3: Workflow Automation

Tool Purpose
generate_feature_workflow_tool() Generate executable workflows
generate_slash_command_tool() Create custom slash commands

Example: Complete Feature Implementation

User: "Add Redis caching to product API"

# Step 1: Extract facts
โ†’ query_codebase_tool(questions=[...])
โ† 52K tokens โ†’ 387 tokens (134:1 compression)

# Step 2: Claude creates A-grade spec using facts
โ†’ [Your superior reasoning]
โ† High-quality specification

# Step 3: Validate spec
โ†’ validate_against_codebase_tool(spec=...)
โ† Completeness: 92%, 1 minor issue

# Step 4: Implement
โ†’ [Your precise code editing]

Result: โœ… A-grade spec, 61% token savings, 3.5 minutes

Why v2.0 is Better

Aspect v1.x (Old) v2.0 (New)
Spec Creation Gemini generates (B-grade) Claude generates (A-grade)
Token Usage 8,000 Claude tokens 3,100 Claude tokens (-61%)
Gemini Role Tries to plan & reason Provides facts only
Claude Role Reviews & fixes Gemini's work Creates from scratch with facts
Quality B-grade A-grade
Workflows Manual Auto-generated

Configuration

Key environment variables (see .env.example for all):

CONTEXT_CACHE_TTL_MINUTES=30     # Cache duration
MAX_TOKENS_PER_ANSWER=300        # Compression target
TARGET_COMPRESSION_RATIO=100     # Aim for 100:1
GEMINI_MODEL=auto                # or specific model

Migration from v1.x

Quick Migration

Before (v1.x):

create_specification_with_gemini(feature="Add 2FA")
# โ†’ B-grade spec from Gemini

After (v2.0):

# 1. Get facts
facts = query_codebase_tool(questions=[...])

# 2. Create spec (you do this with superior reasoning)
spec = create_your_a_grade_spec(facts)

# 3. Validate
validate_against_codebase_tool(spec=spec)

See MIGRATION.md for complete guide.

Troubleshooting

"Gemini CLI not found"

npm install -g @google/gemini-cli

"Empty response from Gemini"

gemini --version  # Check installation
gemini            # Re-authenticate if needed

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run with debug logging
DEBUG_MODE=true python -m hitoshura25_gemini_workflow_bridge

Project Structure

hitoshura25_gemini_workflow_bridge/
โ”œโ”€โ”€ tools/           # 8 new tools (Tier 1, 2, 3)
โ”œโ”€โ”€ prompts/         # Strict fact extraction prompts
โ”œโ”€โ”€ workflows/       # Workflow templates
โ”œโ”€โ”€ utils/           # Token counting, prompt loading
โ”œโ”€โ”€ server.py        # MCP server (v2.0)
โ””โ”€โ”€ generator.py     # Legacy implementations

Success Metrics

  • โœ… 61% cost reduction in Claude tokens
  • โœ… 174:1 compression ratio (50K โ†’ 300 tokens)
  • โœ… A-grade quality specifications
  • โœ… Progressive disclosure with workflows

Contributing

Contributions welcome! Please read:

  1. Implementation Plan
  2. Architecture Overview
  3. Submit PR with tests

License

MIT License - see LICENSE

Credits


Version: 2.0.0 Status: โœ… Production Ready Last Updated: November 15, 2025

๐ŸŒŸ Star us on GitHub if you find this useful!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hitoshura25_gemini_workflow_bridge-0.3.0.tar.gz (121.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file hitoshura25_gemini_workflow_bridge-0.3.0.tar.gz.

File metadata

File hashes

Hashes for hitoshura25_gemini_workflow_bridge-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4ca349b6e5bcc8b68bdd4b63536c4b8b12a101c43fbf54673c9f4ec03bced50f
MD5 41431efa1a48f50063410ddb13dcd559
BLAKE2b-256 c42398feab9498ae185f473a90b6a6344b7f70086ade7a67bb9d6e1147b61df8

See more details on using hashes here.

Provenance

The following attestation bundles were made for hitoshura25_gemini_workflow_bridge-0.3.0.tar.gz:

Publisher: release.yml on hitoshura25/gemini-workflow-bridge-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hitoshura25_gemini_workflow_bridge-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hitoshura25_gemini_workflow_bridge-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 146156dd382b8a935cd3d5bbe8d44fb0b28a9e5980b097a4acad3e9e8d74f4eb
MD5 48e69713f92d73a43382871993896830
BLAKE2b-256 7c18a7f47d7ad9c375626f92b610655bfdae2f8029cdd7d3814c1017be6c9acf

See more details on using hashes here.

Provenance

The following attestation bundles were made for hitoshura25_gemini_workflow_bridge-0.3.0-py3-none-any.whl:

Publisher: release.yml on hitoshura25/gemini-workflow-bridge-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page