MCP Router logo

MCP Router

Organization
voicetreelab

MCP proxy server with lazy loading support - reduces context usage through on-demand tool activation

Publishervoicetreelab
Repositorylazy-mcp
LanguageGo
Forks
17
Stars
114
Available tools
0
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    MCP Router exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    114 stars and 17 forks from the linked repository.

Lazy MCP

Lazy MCP lets your agent fetch MCP tools only on demand, saving those tokens from polluting your context window.

In this example, it saved 17% (34,000 tokens) of an entire claude code context window by hiding 2 MCP tools that aren't always needed.

Welcoming open source contributions!

How it Works

Lazy MCP exposes two meta tools, which allows agents to explore a tree structure of available MCP tools and categories.

  • get_tools_in_category(path) - Navigate the tool hierarchy
  • execute_tool(tool_path, arguments) - Execute tools by path

Example Flow

1. get_tools_in_category("") → {
     "categories": {
       "coding_tools": "Development tools... use when...",
       "web_tools": "description ... instructions"
     }
   }
   
2. get_tools_in_category("coding_tools") → {
     "categories": {
       "serena": "description ... instructions",
     }
   } 

3. get_tools_in_category("coding_tools.serena") → {
     "tools": {"find_symbol": "...", "get_symbols_overview": "..."}
   }

4. execute_tool("coding_tools.serena.find_symbol", {...})
   → Lazy loads Serena server (if not already loaded)
   → Proxies request to Serena
   → Returns result

img_1.png img_2.png

Quick Start

bash
make build
bash
./build/structure_generator --config config.json --output testdata/mcp_hierarchy

This generates the hierarchical structure in the output folder config.json specifies, by fetching the available tools from the mcp servers specified.

Add to Claude Code:

bash
 claude mcp add --transport stdio mcp-proxy build/mcp-proxy -- --config config.json

Configuration

Basic Config Structure

see config.json for an example.

Tool Hierarchy Structure

Tool hierarchy is defined in testdata/mcp_hierarchy/ with JSON files:

Root node (testdata/mcp_hierarchy/root.json):

Category nodes (e.g., testdata/mcp_hierarchy/github/github.json):

Tool nodes (e.g., testdata/mcp_hierarchy/github/create_issue/create_issue.json):

Command Line Options

bash
./mcp-proxy --help

Permission Control with Claude Code Hooks

When using lazy-mcp with Claude Code, all tool calls go through execute_tool. This means traditional MCP permission rules (like mcp__github__create_issue) don't apply directly.

To control which tools require permission prompts, use Claude Code hooks.

Option 1: Claude Code Native Hook (Recommended for Claude Code)

Claude Code's PreToolUse hooks can inspect the tool_path argument and decide permission by outputting JSON:

  • Allow: Exit 0 (no output)
  • Ask: Exit 0 with {"hookSpecificOutput": {"permissionDecision": "ask", ...}}
  • Deny: Exit 0 with {"hookSpecificOutput": {"permissionDecision": "deny", ...}}

Setup

  1. Copy the example hook script:

    bash
    cp examples/hooks/check-sensitive-tools.sh ~/.claude/hooks/
    chmod +x ~/.claude/hooks/check-sensitive-tools.sh
  2. Configure Claude Code hooks (in ~/.claude/settings.json or project .claude/settings.local.json):

    json
    {
      "hooks": {
        "PreToolUse": [
          {
            "matcher": "mcp__lazy-mcp__execute_tool",
            "hooks": [
              {
                "type": "command",
                "command": "~/.claude/hooks/check-sensitive-tools.sh"
              }
            ]
          }
        ]
      }
    }
  3. Customize sensitive tools via environment variables:

    bash
    # Tools that require permission prompts
    export LAZY_MCP_SENSITIVE_TOOLS="gmail.send_email,github.create_*,gitlab.create_*"
    
    # Tools that are completely blocked
    export LAZY_MCP_DENIED_TOOLS="*.force_delete_*"

Option 2: Token-Based Hook (Recommended for OpenCode / General Use)

Since not all agents support the permissionDecision JSON protocol, lazy-mcp also supports a universal "Token Hook" mechanism. This forces the agent to retry the operation after user confirmation.

How It Works

  1. First Call: Hook checks for a token. If missing, it exits with error CONFIRMATION_NEEDED and the path to the required token.
  2. Agent Response: The agent catches this error, asks the user for confirmation, and creates the token file.
  3. Retry: The agent retries the tool call. The hook finds the token, deletes it (one-time use), and allows execution.

Setup

  1. Copy the token hook script:

    bash
    cp examples/hooks/confirm-tool-token.sh /path/to/hooks/
    chmod +x /path/to/hooks/confirm-tool-token.sh
  2. Configure your agent to call this script before execute_tool.

Option 3: OpenCode Plugin

For OpenCode users, a TypeScript plugin is available that logs warnings for sensitive actions.

bash
cp examples/plugins/opencode-sensitive-tools.ts .opencode/plugin/sensitive-tools-check.ts

Default Sensitive Tools

The example scripts include sensible defaults for public-facing actions:

ServerSensitive Tools
Gmailsend_email, create_draft, delete_email, trash_email
GitHubcreate_issue, create_pull_request, create_repository, push_files, create_or_update_file, create_branch, fork_repository
GitLabcreate_issue, create_merge_request, accept_merge_request, create_project, create_branch, create_or_update_file

Pattern Syntax

  • Exact match: gmail.send_email
  • Server prefix: gmail.* (all gmail tools)
  • Suffix match: *.delete_* (all delete operations)

Credits

Forked from TBXark/mcp-proxy - extended with hierarchical routing, lazy loading, and stdio support.

License

MIT License - see LICENSE

Installation

TypingMind
{
  "mcpServers": {
    "lazy-mcp": {
      "command": "go",
      "args": [
        "install",
        "github.com/TBXark/mcp-proxy@latest"
      ]
    }
  }
}

Use MCP Router MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCP Router is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCP Router as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCP Router MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "lazy-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCP Router MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCP Router MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP Router to help me with this task?
MCP Router
Sure. I read it.
Here is what I found using MCP Router.

Option 2: Add an MCP server URL

Use this when MCP Router is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter the MCP server URL from the provider in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste the MCP server URL from the provider into the Server URL field.
  2. Enter a connection name for MCP Router.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the MCP Router connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the MCP Router tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the MCP Router tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP Router to help me with this task?
MCP Router
Sure. I read it.
Here is what I found using MCP Router.

Frequently asked questions

What is the MCP Router MCP server used for?

MCP Router is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCP Router MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCP Router with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCP Router MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCP Router connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCP Router MCP to TypingMind?

MCP Router can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does MCP Router MCP provide in TypingMind?

MCP Router exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCP Router MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCP Router requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇