# dukeabaddon/gate-mcp architecture

> Architecture diagram of the GitHub repository dukeabaddon/gate-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dukeabaddon/gate-mcp
- Repository: https://github.com/dukeabaddon/gate-mcp

## Overview

Gate-MCP is a local MCP gateway that reduces tool-schema and payload context for coding assistants while reporting bounded, measured savings. The principal workflow is catalog exposure, graph-based repository navigation, selective file compression, and session measurement; additional tools clean responses, optimize images, deduplicate work, persist memory, and optionally proxy downstream MCP servers. The graph follows documented capabilities and sampled dispatch/import evidence; some handler internals and storage wiring are not shown in the excerpts, so uncertain links are omitted.

Main entry points: [`src/main.ts`](https://github.com/dukeabaddon/gate-mcp/blob/main/src/main.ts) (MCP Server), [`src/tools/graphQuery.ts`](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/graphQuery.ts) (Graph Query), [`src/tools/dedupContext.ts`](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/dedupContext.ts) (Context Dedup), [`src/tools/sessionStats.ts`](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/sessionStats.ts) (Session Stats)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["MCP Gateway"]
  node_server["MCP Server<br/>[main.ts]"]
  node_catalog["Tool Mode<br/>[toolMode.ts]"]
  node_invoke["Tool Invoke<br/>[invoke.ts]"]
  node_help["Help<br/>[help.ts]"]
  node_init["Workspace Init<br/>[gateInit.ts]"]
end

subgraph group_navigation["Repository Navigation"]
  node_graphquery["Graph Query<br/>[graphQuery.ts]"]
  node_symbolgraph["Symbol Graph<br/>[symbolGraph.ts]"]
  node_graphify["Graphify Bridge<br/>[graphifyBridge.ts]"]
end

subgraph group_payload["Payload Optimization"]
  node_compress["File Compression<br/>[compressFile.ts]"]
  node_parser["AST Parser<br/>[astParser.ts]"]
  node_image["Image Optimization<br/>[optimizeImage.ts]"]
  node_clean["Response Cleaning<br/>[cleanResponse.ts]"]
end

subgraph group_state["Local State"]
  node_dedup["Context Dedup<br/>[dedupContext.ts]"]
  node_memory["Agent Memory<br/>[memory.ts]"]
  node_cache[("Dedup Cache<br/>[cacheDb.ts]")]
  node_memorydb[("Memory Store<br/>[memoryDb.ts]")]
  node_stats["Session Stats<br/>[sessionStats.ts]"]
  node_metrics["Session Metrics<br/>[sessionMetrics.ts]"]
end

subgraph group_integration["External Integrations"]
  node_proxytools["Proxy Tools<br/>[proxyTools.ts]"]
  node_proxy["Proxy Client<br/>[proxyClient.ts]"]
end

node_assistant(("AI Assistant"))
node_downstream(("MCP Servers"))

node_assistant -->|"MCP requests"| node_server
node_server -->|"selects tools"| node_catalog
node_server -->|"dispatches"| node_invoke
node_server -->|"dispatches"| node_help
node_server -->|"dispatches"| node_init
node_server -->|"dispatches"| node_graphquery
node_server -->|"dispatches"| node_compress
node_server -->|"dispatches"| node_image
node_server -->|"dispatches"| node_clean
node_server -->|"dispatches"| node_dedup
node_server -->|"dispatches"| node_memory
node_server -->|"dispatches"| node_stats
node_server -.->|"dispatches"| node_proxytools
node_graphquery -->|"queries graph"| node_symbolgraph
node_graphquery -.->|"queries map"| node_graphify
node_dedup -->|"reads and writes"| node_cache
node_stats -->|"reads counters"| node_metrics
node_proxytools -.->|"calls"| node_proxy
node_proxy -.->|"MCP calls"| node_downstream

click node_server "https://github.com/dukeabaddon/gate-mcp/blob/main/src/main.ts"
click node_catalog "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/toolMode.ts"
click node_invoke "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/invoke.ts"
click node_help "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/help.ts"
click node_init "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/gateInit.ts"
click node_graphquery "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/graphQuery.ts"
click node_symbolgraph "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/symbolGraph.ts"
click node_graphify "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/graphifyBridge.ts"
click node_compress "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/compressFile.ts"
click node_parser "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/astParser.ts"
click node_image "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/optimizeImage.ts"
click node_clean "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/cleanResponse.ts"
click node_dedup "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/dedupContext.ts"
click node_memory "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/memory.ts"
click node_cache "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/cacheDb.ts"
click node_memorydb "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/memoryDb.ts"
click node_stats "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/sessionStats.ts"
click node_metrics "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/sessionMetrics.ts"
click node_proxytools "https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/proxyTools.ts"
click node_proxy "https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/proxyClient.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_catalog,node_invoke,node_help,node_init toneBlue
class node_graphquery,node_symbolgraph,node_graphify toneAmber
class node_compress,node_parser,node_image,node_clean,node_downstream toneMint
class node_dedup,node_memory,node_cache,node_memorydb,node_stats,node_metrics toneRose
class node_proxytools,node_proxy,node_assistant toneIndigo
```

## Components

### MCP Gateway

- [MCP Server](https://github.com/dukeabaddon/gate-mcp/blob/main/src/main.ts): `src/main.ts`
- [Tool Mode](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/toolMode.ts): `src/lib/toolMode.ts`
- [Tool Invoke](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/invoke.ts): `src/tools/invoke.ts`
- [Help](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/help.ts): `src/tools/help.ts`
- [Workspace Init](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/gateInit.ts): `src/tools/gateInit.ts`

### Repository Navigation

- [Graph Query](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/graphQuery.ts): `src/tools/graphQuery.ts`
- [Symbol Graph](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/symbolGraph.ts): `src/lib/symbolGraph.ts`
- [Graphify Bridge](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/graphifyBridge.ts): `src/lib/graphifyBridge.ts`

### Payload Optimization

- [File Compression](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/compressFile.ts): `src/tools/compressFile.ts`
- [AST Parser](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/astParser.ts): `src/lib/astParser.ts`
- [Image Optimization](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/optimizeImage.ts): `src/tools/optimizeImage.ts`
- [Response Cleaning](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/cleanResponse.ts): `src/tools/cleanResponse.ts`

### Local State

- [Context Dedup](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/dedupContext.ts): `src/tools/dedupContext.ts`
- [Agent Memory](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/memory.ts): `src/tools/memory.ts`
- [Dedup Cache](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/cacheDb.ts): `src/lib/cacheDb.ts`
- [Memory Store](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/memoryDb.ts): `src/lib/memoryDb.ts`
- [Session Stats](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/sessionStats.ts): `src/tools/sessionStats.ts`
- [Session Metrics](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/sessionMetrics.ts): `src/lib/sessionMetrics.ts`

### External Integrations

- [Proxy Tools](https://github.com/dukeabaddon/gate-mcp/blob/main/src/tools/proxyTools.ts): `src/tools/proxyTools.ts`
- [Proxy Client](https://github.com/dukeabaddon/gate-mcp/blob/main/src/lib/proxyClient.ts): `src/lib/proxyClient.ts`

### Other components

- **AI Assistant**
- **MCP Servers**

## Connections

- AI Assistant → MCP Server: MCP requests
- MCP Server → Tool Mode: selects tools
- MCP Server → Tool Invoke: dispatches
- MCP Server → Help: dispatches
- MCP Server → Workspace Init: dispatches
- MCP Server → Graph Query: dispatches
- MCP Server → File Compression: dispatches
- MCP Server → Image Optimization: dispatches
- MCP Server → Response Cleaning: dispatches
- MCP Server → Context Dedup: dispatches
- MCP Server → Agent Memory: dispatches
- MCP Server → Session Stats: dispatches
- MCP Server → Proxy Tools: dispatches
- Graph Query → Symbol Graph: queries graph
- Graph Query → Graphify Bridge: queries map
- Context Dedup → Dedup Cache: reads and writes
- Session Stats → Session Metrics: reads counters
- Proxy Tools → Proxy Client: calls
- Proxy Client → MCP Servers: MCP calls
