Skip to main content
Glama

Ollama MCP Bridge for Google Antigravity CLI (agy)

Tiered Edge-Cloud Architecture: High-performance local inference daemon as a zero-cost semantic pre-filter, code drafter, and map-reduce compressor for Google Antigravity CLI.

CI / Automated V&V Pipeline License: AGPL v3 Protocol: MCP Runtime: Ollama Python: 3.10+ Coverage: 100% Assurance: DO--178C Level A


1. System Context & The Token Bottleneck

Google Antigravity CLI (agy) is a terminal-first autonomous coding agent harness designed for deep engineering workflows: repository-wide code exploration, multi-file edits, test execution, and multi-step reasoning.

Because agy-cli routes its primary reasoning loop through cloud-hosted frontier models (such as Gemini 2.0 Flash / Pro), feeding uncurated logs, raw data files, or entire repository ASTs rapidly inflates input/output context. This leads to quota exhaustion, throttling, and latency spikes.

                      [ Large Context: Dumps / Logs / Drafts ]
                                         │
                                         ▼
                              ┌──────────────────────┐
                              │   Local Pre-Filter   │  <-- Fast, Zero Token Cost (Ollama)
                              │  (Ollama / C++ Eng)  │      Summarization, Extraction, AST Pruning
                              └──────────┬───────────┘
                                         │  (Only high-density signal forwarded)
                                         ▼
                              ┌──────────────────────┐
                              │     agy-cli Core     │  <-- Protected Quota, High-Speed Reasoning
                              │ (Gemini 2.0 / Cloud) │      Strategic Decisions, Code Synthesis
                              └──────────────────────┘

By placing Ollama as a local semantic pre-filter via the open Model Context Protocol (MCP), you offload token-heavy preliminary workloads, saving 70% to 95% of cloud context tokens while accelerating turnaround latency.


Related MCP server: antigravity-mcp

2. Architecture & Data Flow

flowchart TD
    subgraph Antigravity ["Google Antigravity CLI (Cloud Frontier Harness)"]
        AGY["agy Core Agent Loop\n(Gemini 2.0 Flash / Pro)"]
        CLO_QUOTA["Cloud Quota / Token Budget\n(Protected)"]
    end

    subgraph MCP_Boundary ["Local Protocol Boundary (STDIO Transport)"]
        STDIO["JSON-RPC 2.0 over Stdio"]
        SERVER["src/ollama_bridge/server.py\n(FastMCP Server)"]
        ISOLATION["Stderr Logging Isolation\nsrc/ollama_bridge/config.py"]
    end

    subgraph Bridge_Engine ["Deterministic Edge Engine (Python 3.10+)"]
        RES["src/ollama_bridge/resolution.py\n4-Tier Precedence Resolver"]
        ENG["src/ollama_bridge/engine.py\nChunking, Drafting, Map-Reduce"]
        CLI["src/ollama_bridge/client.py\nInventory & Prewarming"]
    end

    subgraph Hardware_Tier ["Local Accelerated Compute Tier"]
        OLLAMA["Ollama Daemon (http://localhost:11434)"]
        VRAM["GPU VRAM (keep_alive: -1 pinned)"]
        QWEN["qwen2.5-coder:14b"]
        DEEPSEEK["deepseek-r1:14b"]
    end

    AGY -->|"Tools: draft, summarize,\nmap-reduce, extract_json"| STDIO
    STDIO --> SERVER
    SERVER --> RES
    SERVER --> ENG
    SERVER --> CLI
    SERVER -.->|"Diagnostic Logs (Stderr)"| ISOLATION
    RES -->|"Resolved Model"| ENG
    ENG -->|"POST /api/generate"| OLLAMA
    CLI -->|"GET /api/tags\nPOST /api/generate"| OLLAMA
    OLLAMA --> VRAM
    VRAM --> QWEN
    VRAM --> DEEPSEEK
    OLLAMA -->|"Fast Local Output (0 tokens billed)"| ENG
    ENG -->|"Clean JSON / Brief Result"| SERVER
    SERVER -->|"JSON-RPC Response"| STDIO
    STDIO --> AGY
    AGY -.->|"Only Curated Insights Fed"| CLO_QUOTA

3. Registered MCP Tools

The bridge daemon registers 7 specialized Model Context Protocol tools:

Tool Name

Parameters

Purpose & Rationale

local_draft_code

task_description, context, language, model

Drafts code implementations, boilerplate, and scaffolding locally without burning cloud tokens.

local_summarize_and_extract

content, extraction_goal, model

Strips noise, boilerplate, and repetitive lines from logs or text into a high-density technical summary.

local_chunked_summary

content, extraction_goal, chunk_chars, model

In-memory line-aware chunk partitioning and tree-synthesis map-reduce for texts exceeding single-pass limits.

local_map_reduce_file

file_path, extraction_goal, chunk_size, overlap, concurrency, model

File-direct sliding-window map-reduce. Streams multi-megabyte files directly from disk, runs concurrent worker map distillation with NO_SIGNAL pruning, and synthesizes an executive diagnostic brief (< 2KB) to protect STDIO and cloud context.

local_extract_json

content, schema_description, model

Extracts strict structured JSON conforming to a specified schema at low temperature (0.1).

local_list_models

(none)

Queries /api/tags, calculates sizes in gigabytes, parses parameter counts and quantization, and marks active default.

local_prewarm_model

model

Sends keep_alive: -1 to /api/generate to pin model weights into GPU VRAM and eliminate cold-start latency.


4. Antigravity CLI Integration & Slash Commands

4.1. FastMCP Daemon Registration

Add the bridge to your Antigravity configuration at ~/.gemini/config/mcp_config.json:

{
  "mcpServers": {
    "local-ollama": {
      "command": "python3",
      "args": [
        "/home/leifdavisson/.local/bin/ollama_mcp_bridge.py"
      ],
      "env": {
        "LOCAL_LLM_MODEL": "qwen2.5-coder:14b",
        "OLLAMA_HOST": "http://localhost:11434"
      }
    }
  }
}

4.2. Installed Antigravity Skills

The project installs two complementary slash commands for agy-cli:

  1. /local-draft (Open SKILL.md (file:///home/leifdavisson/.gemini/config/skills/local-draft/SKILL.md)): Forces AST parsing, code scaffolding, or boilerplate generation onto local Ollama models.

    /local-draft Create a Pydantic V2 schema for our customer ingestion webhook
  2. /reduce (Open SKILL.md (file:///home/leifdavisson/.gemini/config/skills/reduce/SKILL.md)): Performs file-direct chunked map-reduce on massive files (>300 lines) before ingesting into context.

    /reduce /var/log/syslog.log "Identify database connection timeouts and trace IDs"

4.3. Standalone CLI Utility (chunk_reduce.py)

Run the map-reduce pipeline directly from your shell or pipe from stdin:

# File direct execution:
chunk_reduce.py -f /var/log/syslog.log -g "Find failed SSH logins" -j 4

# Piped execution:
cat massive_output.txt | chunk_reduce.py -g "Extract unhandled exceptions"

5. Automated Verification & Validation (DO-178C Level A)

The codebase is governed by formal INCOSE requirements and verified according to DO-178C Level A High-Assurance verification criteria:

Metric

Required Standard

Achieved Result

Requirements Verified

100% (9 / 9)

100% (9 / 9)

Uncovered Requirements

0

0

Orphaned Tests

0

0

Total Test Suite

>= 80

139 Passed (135 AST Mapped)

Statement Coverage

100.0%

100.0% (366 / 366 statements)

Branch Coverage

100.0%

100.0% (92 / 92 branches)

DO-178C Level A MC/DC

100.0%

100.0% Verified Pairs

Mutation Kill Score

>= 90.0%

91.0% (mutmut)

Strict Static Typing

0 errors

0 errors (mypy --strict src/)

Protocol Isolation

Pure JSON-RPC

Zero stdout pollution (stderr isolated)

Detailed audit documentation and artifacts:


6. Quick Start & Installation

Requirements

  • Python 3.10+

  • Ollama running locally (http://localhost:11434)

  • Recommended local models: qwen2.5-coder:14b or deepseek-r1:14b

Installation

# 1. Clone repository
git clone https://github.com/leifdavisson/agy-ollama-mcp.git
cd agy-ollama-mcp

# 2. Install package in editable mode
pip install -e .
pip install -r requirements-dev.txt

# 3. Pull recommended local models in Ollama
ollama pull qwen2.5-coder:14b
ollama pull deepseek-r1:14b

# 4. Verify local installation
pytest --cov=src --cov-branch --cov-fail-under=100 tests/
python3 scripts/verify_mcdc.py
python3 scripts/generate_rtm.py

7. Configuration Environment Variables

Variable

Default

Description

OLLAMA_HOST

http://localhost:11434

Endpoint of the local Ollama daemon.

LOCAL_LLM_MODEL

Auto-detected

Preferred model override (e.g. qwen2.5-coder:14b, deepseek-r1:14b).

OLLAMA_TIMEOUT

180

Request timeout in seconds for generation tasks.

OLLAMA_NUM_CTX

16384

Context window size allocated in local model memory.

OLLAMA_TEMPERATURE

0.2

Sampling temperature for code generation.

OLLAMA_MCP_DEBUG

0

Set to 1 to enable verbose diagnostic output to stderr.


8. Companion Ecosystem & Project Attribution

This project is built atop the open-source AI and developer tooling ecosystem. Direct backlinks to official project documentation, homepages, and repositories:


9. License

This project is licensed under the GNU Affero General Public License v3.0 (GNU AGPLv3). See LICENSE (Open LICENSE (file:///data/agy_ollama_mcp/LICENSE)) for full legal terms.

Available Tools

7 tools
local_chunked_summaryC

Map-reduce chunked summarization for massive files or logs that exceed single context limits.

Inputs: content (required), model, chunk_chars, extraction_goal. Returns: result

local_draft_codeA

Generate initial code drafts, boilerplate, unit tests, or scaffolding locally via Ollama without consuming cloud tokens.

Inputs: task_description (required), model, context, language. Returns: result

local_extract_jsonB

Extract structured JSON from unstructured text, logs, or documentation according to a target schema description.

Inputs: content (required), schema_description (required), model. Returns: result

local_list_modelsA

List all models currently installed and available in the local Ollama instance.

Inputs: no named parameters. Returns: result

local_map_reduce_fileB

Compress large files, traces, or logs using local Ollama Map-Reduce before ingesting into context.

Inputs: file_path (required), extraction_goal (required), model, overlap, +2 more. Returns: result

local_prewarm_modelA

Pre-warm a local model into memory/VRAM with keep_alive=-1 so subsequent calls have zero cold-start delay.

Inputs: model. Returns: result

local_summarize_and_extractC

Compress massive files, logs, terminal traces, or documentation into high-density summaries before cloud reasoning.

Inputs: content (required), extraction_goal (required), model. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 7 tools

    Disambiguation2/5

    The tools have significant overlap: local_summarize_and_extract, local_chunked_summary, and local_map_reduce_file all perform summarization/compression with only subtle differences. This can confuse an agent about which to use. Other tools are clearer, but the redundant trio lowers the score.

    Naming Consistency3/5

    All tools use a 'local_' prefix and snake_case, which is consistent, but the names are not fully uniform: 'summarize_and_extract' combines two actions while others use a single verb, and 'chunked_summary' vs 'map_reduce_file' are stylistic variations. The patterns are mostly consistent but not perfectly aligned.

    Tool Count5/5

    Seven tools is a reasonable, well-scoped number for a local Ollama helper. It covers core operations without being overwhelming, fitting comfortably within the typical 3-15 range.

    Completeness4/5

    The tools cover the main capabilities (code generation, summarization, extraction, model management, prewarming) well. However, the presence of three overlapping summarization tools suggests redundancy rather than a missing feature; the domain appears largely covered, with minor gaps like model downloading or inference not being addressed.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables local AI agents to generate code and interact with Google Antigravity (Gemini Pro) via MCP, consuming zero API tokens.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Exposes Google's Antigravity CLI agent as MCP tools, letting any MCP host run persistent, resumable conversations with streamed progress and per-call workspace, model, effort, and mode overrides. Enables agents to delegate coding and shell-capable tasks to the Antigravity agent from OpenCode, Claude Desktop, Cursor, or custom agents.
      7
      MIT