Skip to content

rdmilly/mcp-tool-flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MCP Tool Flow Architecture

Complete self-hosted MCP (Model Context Protocol) infrastructure for Claude.ai integration with 95% token reduction.

License: MIT

Overview

This repository documents the complete MCP tool flow architecture that enables Claude.ai to access 350+ tools while consuming only ~800 tokens (instead of ~40,000).

Claude.ai β†’ mcp-front (OAuth) β†’ mcp-tool-filter (semantic) β†’ mcp-name-bridge β†’ Context Forge β†’ [22 MCP servers]

Why This Architecture?

Problem: Token Explosion

Connecting Claude.ai directly to 350+ tools would consume ~40,000 tokens before any conversation starts, severely limiting conversation length.

Solution: 4-Layer Architecture

  1. OAuth Gateway - Secure authentication via Google OAuth
  2. Semantic Tool Filter - Exposes only 3 meta-tools, finds relevant tools on-demand
  3. Name Bridge - Translates naming conventions between systems
  4. Context Forge - Aggregates all MCP servers into unified endpoint

Result

Metric Before After Savings
Token Usage ~40,000 ~800 98%
Tools Visible 350+ 3 Semantic search
Security None OAuth 2.0 Enterprise-ready

Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         CLAUDE.AI                                β”‚
β”‚              Sees only 3 tools (~800 tokens):                    β”‚
β”‚         search_tools, execute_tool, list_all_tools               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ HTTPS
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    mcp.millyweb.com                              β”‚
β”‚              Traefik (SSL Termination)                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 mcp-front (Port 8088)                            β”‚
β”‚                                                                  β”‚
β”‚  β€’ Google OAuth 2.0 authentication                               β”‚
β”‚  β€’ JWT token validation                                          β”‚
β”‚  β€’ Routes to tool-filter                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              mcp-tool-filter-cf (Port 8098)                      β”‚
β”‚                 TOKEN OPTIMIZATION LAYER                         β”‚
β”‚                                                                  β”‚
β”‚  β€’ Exposes only 3 meta-tools to Claude                           β”‚
β”‚  β€’ search_tools(query) - Semantic search with embeddings         β”‚
β”‚  β€’ execute_tool(name, args) - Execute any tool by name           β”‚
β”‚  β€’ list_all_tools() - Browse all available tools                 β”‚
β”‚  β€’ Uses local MiniLM embeddings (no API key needed)              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               mcp-name-bridge (Port 8080)                        β”‚
β”‚                 CONVENTION CONVERTER                             β”‚
β”‚                                                                  β”‚
β”‚  β€’ Translates tool names between systems                         β”‚
β”‚  β€’ gateway__ssh_execute β†’ gateway-ssh-execute                    β”‚
β”‚  β€’ Handles Context Forge slug conventions                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             Context Forge (Port 4444/8099)                       β”‚
β”‚                 MCP GATEWAY AGGREGATOR                           β”‚
β”‚                                                                  β”‚
β”‚  β€’ IBM's open-source MCP gateway                                 β”‚
β”‚  β€’ Aggregates 22 MCP servers                                     β”‚
β”‚  β€’ 350+ tools available                                          β”‚
β”‚  β€’ Admin UI at :4444                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό                     β–Ό                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Filesystem  β”‚   β”‚    GitHub     β”‚   β”‚  mcp-gateway  β”‚
β”‚     Git       β”‚   β”‚    Slack      β”‚   β”‚   (SSH/VPS)   β”‚
β”‚   PostgreSQL  β”‚   β”‚   LinkedIn    β”‚   β”‚               β”‚
β”‚     Fetch     β”‚   β”‚   Puppeteer   β”‚   β”‚ β€’ ssh_execute β”‚
β”‚  BraveSearch  β”‚   β”‚  Browserless  β”‚   β”‚ β€’ ssh_read    β”‚
β”‚     ...       β”‚   β”‚     ...       β”‚   β”‚ β€’ ssh_write   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Start

Prerequisites

  • Docker & Docker Compose
  • Domain with DNS pointing to your server
  • Google OAuth credentials (for authentication)
  • Traefik reverse proxy (or similar)

1. Clone Repository

git clone https://github.com/rdmilly/mcp-tool-flow.git
cd mcp-tool-flow

2. Deploy Context Forge (MCP Aggregator)

cd contextforge
cp .env.example .env
# Edit .env with your credentials
docker-compose up -d

3. Deploy Name Bridge

cd ../mcp-name-bridge
docker-compose up -d

4. Deploy Tool Filter

cd ../mcp-tool-filter
cp .env.example .env
# Edit .env
docker-compose up -d

5. Deploy OAuth Gateway

cd ../mcp-front
cp .env.example .env
# Edit .env with Google OAuth credentials
docker-compose up -d

6. Register in Claude.ai

  1. Go to Claude.ai Settings β†’ Connectors
  2. Add custom connector: https://your-domain.com/mcp/sse
  3. Complete OAuth flow
  4. Start using 350+ tools!

Components

Component Port Purpose Documentation
mcp-front 8088 OAuth gateway mcp-front/README.md
mcp-tool-filter 8098 Semantic filtering mcp-tool-filter/README.md
mcp-name-bridge 8080 Name translation mcp-name-bridge/README.md
contextforge 4444, 8099 MCP aggregation contextforge/README.md
mcp-gateway 8086 SSH/VPS tools mcp-gateway/README.md

Registered MCP Servers (22 total)

Server Tools Description
Filesystem 15+ File operations
Git 10+ Git operations
PostgreSQL 10+ Database queries
GitHub 30+ Repository management
Slack 15+ Messaging
Docker 20+ Container management
Puppeteer 10+ Browser automation
Browserless 5+ Headless browsing
LinkedIn 5+ Social posting
Gateway (SSH) 9 SSH/VPS management
...and 12 more

API Reference

Tool Filter Endpoints

# Health check
curl http://localhost:8098/health

# List all tools (paginated)
curl -X POST http://localhost:8098/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Context Forge Admin API

# List gateways
curl -u admin:PASSWORD http://localhost:4444/gateways

# Register new gateway
curl -X POST http://localhost:4444/gateways \
  -u admin:PASSWORD \
  -H "Content-Type: application/json" \
  -d '{"name":"MyServer","url":"http://server:8080/mcp","transport":"STREAMABLEHTTP"}'

# List all tools
curl -u admin:PASSWORD "http://localhost:4444/tools?limit=500"

Network Configuration

All components communicate over a shared Docker network:

networks:
  mcp-network:
    external: true

Create it once:

docker network create mcp-network

Troubleshooting

Tools not showing up

  1. Check Context Forge has gateways registered: curl -u admin:PASS http://localhost:4444/gateways
  2. Check tool-filter can reach name-bridge: docker logs mcp-tool-filter-cf
  3. Verify name-bridge health: curl http://localhost:8080/health

OAuth not working

  1. Verify Google OAuth credentials in mcp-front .env
  2. Check redirect URI matches your domain
  3. Review mcp-front logs: docker logs mcp-front

SSH tools failing

  1. Verify mcp-gateway is registered with Context Forge
  2. Check SSH keys are mounted: docker exec mcp-gateway ls /ssh
  3. Test SSH connection: docker exec mcp-gateway cat /app/src/index.js

Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

License

MIT License - see LICENSE for details.

Credits


Built by Ryan Milly as part of the Millyweb AI infrastructure project.

About

Complete MCP Tool Flow Architecture - OAuth Gateway, Semantic Tool Filter, Name Bridge, Context Forge aggregation. 95% token reduction for Claude.ai integration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors