Skip to content

amir-arad/riglm

Repository files navigation

   {Ξ}
  RigLM

The Intelligent Context Router for AI

License: ISC MCP Ready Status: Active

The central multiplexer for your Model Context Protocol ecosystem. Define your tools once, then dynamically route fine-grained context subsets to any client or session.


Get Started Documentation


Features

  • Intelligent Context Routing - Route multiple MCP servers (local or remote) through unified endpoints
  • Tool Namespacing - Tools are automatically prefixed with server names (github-list_repos) to avoid conflicts
  • Flexible Configuration - JSON5 config with support for local (stdio) and remote (SSE/HTTP) servers
  • Tool Filtering - Filter out unwanted tools at global, endpoint, or server level
  • Multiple Endpoints - Create different endpoints for different use cases (development, production, etc.)
  • Web UI - Dark-themed dashboard for monitoring and management

Installation

Standalone Binary (Recommended)

Build a single executable with embedded web client (no Bun or Node.js runtime required):

bun install
bun run build:standalone

This creates dist/riglm (~102MB) with all dependencies and assets embedded.

Install system-wide:

sudo cp dist/riglm /usr/local/bin/
sudo chmod +x /usr/local/bin/riglm

Or add to your PATH:

mkdir -p ~/.local/bin
cp dist/riglm ~/.local/bin/
chmod +x ~/.local/bin/riglm
# Add to ~/.bashrc or ~/.zshrc: export PATH="$HOME/.local/bin:$PATH"

Initial Setup

Create a configuration file:

# Global config in ~/.config/riglm/
riglm init

# Or local config in ./.riglm/ (project-specific)
riglm init --local

Template options:

  • minimal (default) - Basic starter config
  • standard - Common server setup
  • full - All options with comments
riglm init --template standard

Edit the generated config.json5 to add your MCP servers.

Running

# Start the server (uses config from ~/.config/riglm/ or ./.riglm/)
riglm serve

# Or simply (serve is the default command)
riglm

# Custom port and verbose logging
riglm serve -p 8080 -v

# Show all available options
riglm help

Validate Configuration

riglm validate
riglm validate -c /path/to/config.json5

Architecture

The Switchboard Philosophy

RigLM is not just an aggregator; it is an active routing layer.

%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#0A0E17', 'edgeLabelBackground':'#161B22', 'tertiaryColor': '#161B22'}}}%%
graph LR
    subgraph INPUTS ["How you define them"]
        A["🛢️ Prod DB"]:::mcp
        B["📁 Filesystem"]:::mcp
        C["💬 Slack History"]:::mcp
    end

    subgraph RIGLM ["{Ξ} RigLM Router"]
        Router[Context Multiplexer]:::router
    end

    subgraph OUTPUTS ["How you use them"]
        Session1("Session A: Junior Dev (Cursor)"):::session
        Session2("Session B: Architect (Claude)"):::session
    end

    A -->|Full Context| Router
    B -->|Full Context| Router
    C -->|Full Context| Router

    Router -->|Filtered Subset| Session1
    Router -->|Full Access| Session2

    classDef mcp fill:#161B22,stroke:#00F0FF,color:#fff,stroke-width:1px
    classDef router fill:#0A0E17,stroke:#7B61FF,color:#00F0FF,stroke-width:2px
    classDef session fill:#161B22,stroke:#8B949E,color:#fff
    linkStyle 0,1,2 stroke:#8B949E,stroke-width:1px
    linkStyle 3,4 stroke:#00F0FF,stroke-width:2px
Loading

Prerequisites

  • Bun 1.x or higher (recommended)
  • Or Node.js 18.x or higher with npm

Local Setup Guide

1. Clone the Repository

git clone <repository-url>
cd riglm

2. Install Dependencies

bun install

3. Create Configuration File

Use the CLI to create a configuration file:

bun run dev init  # Creates ~/.config/riglm/config.json5

Or manually copy the example configuration:

mkdir -p data
cp config.simplified.example.json5 data/config.local.json5

Edit your configuration file to define your MCP servers:

{
  // Define MCP servers (local or remote)
  "servers": {
    // Local server using stdio transport
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/mcp-server-filesystem", "/path/to/allowed/dir"],
      "description": "Filesystem access"
    },
    // Remote server using SSE transport
    "github": {
      "url": "http://localhost:3001/sse",
      "description": "GitHub operations",
      "headers": {
        "Authorization": "Bearer your-token"
      }
    },
    // Remote server using HTTP transport
    "calculator": {
      "url": "http://localhost:3002",
      "description": "Calculator service"
    }
  },

  // Define endpoints that expose server groups
  "endpoints": {
    "main": {
      "servers": ["filesystem", "github", "calculator"],
      "description": "Main development endpoint"
    },
    "minimal": {
      "servers": ["filesystem"],
      "description": "Minimal endpoint with filesystem only"
    }
  }
}

4. Start the Server

# Development mode (with hot reload)
bun run dev

# Or production mode
bun run build
bun run start

The server will start on port 3000 by default. Web UI is served at http://localhost:3000.

Configuration Reference

Server Types

Local Server (stdio)

{
  "command": "npx",
  "args": ["-y", "@anthropic-ai/mcp-server-github"],
  "env": {
    "GITHUB_TOKEN": "ghp_xxx"
  },
  "description": "GitHub MCP server"
}

Remote Server (SSE) - URL ends with /sse

{
  "url": "http://localhost:3001/sse",
  "headers": {
    "Authorization": "Bearer xxx"
  },
  "description": "Remote SSE server"
}

Remote Server (HTTP)

{
  "url": "http://localhost:3002",
  "description": "Remote HTTP server"
}

Tool Filtering

Filter out unwanted tools using glob patterns:

{
  "servers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/mcp-server-github"],
      "filters": ["*_dangerous", "*_admin"]  // Server-specific filters
    }
  },
  "endpoints": {
    "production": {
      "servers": ["github"],
      "filters": ["*_debug"]  // Endpoint-specific filters
    }
  },
  "filters": ["*_internal"]  // Global filters (lowest priority)
}

Filter priority: Server filters > Endpoint filters > Global filters

Connecting MCP Clients

Claude Code

Add to your Claude Code MCP configuration (~/.config/claude-code/config.json or project-level):

{
  "mcpServers": {
    "extension-manager": {
      "url": "http://localhost:3000/main/sse"
    }
  }
}

Cursor

Add to your Cursor settings:

{
  "mcp.servers": {
    "extension-manager": {
      "url": "http://localhost:3000/main/sse"
    }
  }
}

Other MCP Clients

Use the SSE endpoint URL: http://localhost:3000/<endpoint-id>/sse

Replace <endpoint-id> with the endpoint name from your configuration (e.g., main, minimal).

API Endpoints

Endpoint Method Description
/:endpointId/sse GET SSE endpoint for MCP client connections
/:endpointId/messages/:sessionId POST MCP message handling
/:endpointId/status GET Health check for specific endpoint

Environment Variables

Variable Default Description
CONFIG_PATH Auto-detected Override config path (default: ~/.config/riglm/ or ./.riglm/)
PORT 3000 Server port
LOG_LEVEL info Logging level (error, warn, info, debug)
NODE_ENV development Environment mode

Development Commands

bun run dev          # Development with hot reload
bun run build        # Production build
bun run start        # Run production build
bun test             # Run tests (Bun test runner)
bun run lint         # Run ESLint
bun run typecheck    # Type checking

Development Workflow

This project uses GitHub Actions for CI/CD with automated testing, building, and releasing.

Continuous Integration

On every push and PR to main, GitHub Actions runs:

Check Command Description
Type Check bun run typecheck TypeScript compilation
Lint bun run lint ESLint code quality
Test bun test Unit and integration tests
Build bun run build:standalone Verify standalone builds

Version Management

Version management uses npm's built-in versioning which automatically:

  • Runs pre-version checks (lint, typecheck, tests)
  • Updates package.json version
  • Creates a git commit with the version
  • Creates a git tag (e.g., v1.2.3)
  • Pushes the commit and tag to origin

Release commands:

# Patch release (1.0.0 → 1.0.1) - bug fixes
bun run release:patch

# Minor release (1.0.0 → 1.1.0) - new features, backward compatible
bun run release:minor

# Major release (1.0.0 → 2.0.0) - breaking changes
bun run release:major

Manual version control:

# Set specific version
npm version 2.0.0-beta.1

# Prerelease versions
npm version prerelease --preid=beta  # 1.0.0 → 1.0.1-beta.0
npm version prerelease --preid=rc    # 1.0.0 → 1.0.1-rc.0

Release Process

When a version tag is pushed (e.g., v1.2.3), GitHub Actions automatically:

  1. Builds standalone executables for all platforms:

    • riglm-linux-x64.tar.gz - Linux (Intel/AMD)
    • riglm-linux-arm64.tar.gz - Linux (ARM)
    • riglm-darwin-x64.tar.gz - macOS (Intel)
    • riglm-darwin-arm64.tar.gz - macOS (Apple Silicon)
    • riglm-windows-x64.zip - Windows
  2. Creates a GitHub Release with:

    • All platform binaries attached
    • Auto-generated release notes from commits

Complete Release Example

# 1. Ensure you're on main with latest changes
git checkout main
git pull origin main

# 2. Run release
bun run release:minor  # or release:patch, release:major

# This automatically:
# - Runs lint, typecheck, and tests
# - Bumps version in package.json (e.g., 1.0.0 → 1.1.0)
# - Commits: "1.1.0"
# - Tags: "v1.1.0"
# - Pushes commit and tag to origin
# - Triggers GitHub Actions release workflow

# 3. Monitor the release
# Go to GitHub Actions to watch the build
# Once complete, binaries are available at:
# https://github.com/<owner>/riglm/releases/latest

Downloading Releases

Users can download pre-built binaries from the Releases page:

# Linux (x64)
curl -L https://github.com/<owner>/riglm/releases/latest/download/riglm-linux-x64.tar.gz | tar xz
chmod +x riglm-linux-x64
sudo mv riglm-linux-x64 /usr/local/bin/riglm

# macOS (Apple Silicon)
curl -L https://github.com/<owner>/riglm/releases/latest/download/riglm-darwin-arm64.tar.gz | tar xz
chmod +x riglm-darwin-arm64
sudo mv riglm-darwin-arm64 /usr/local/bin/riglm

# Windows (PowerShell)
Invoke-WebRequest -Uri "https://github.com/<owner>/riglm/releases/latest/download/riglm-windows-x64.zip" -OutFile riglm.zip
Expand-Archive riglm.zip -DestinationPath .
# Add to PATH or move to desired location

Project Structure

riglm/
├── src/                    # Express backend (hexagonal architecture)
│   ├── index.ts            # Entry point
│   ├── ports/              # Abstract interfaces (contracts)
│   ├── domain/             # Pure business logic (filter, types, config)
│   ├── adapters/           # Concrete implementations
│   │   ├── http/           # Express routes & middleware
│   │   ├── logging/        # Winston adapter
│   │   ├── storage/        # File config adapter
│   │   └── mcp/            # MCP client/server adapters
│   ├── application/        # Services (riglm-server, hosts, backend, transport-session-manager)
│   ├── cli/                # CLI commands and argument parsing
│   └── etc/                # Utilities (closeable, env)
├── test/                   # Unit and E2E tests
├── e2e-ui/                 # Playwright UI tests
├── public/                 # Static web UI (vanilla HTML/CSS/JS)
├── data/                   # Runtime data (config, extensions, logs)
├── docs/                   # Documentation and plans
└── README.md

License

ISC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors