A generic MCP browser with context optimization for AI systems
Go to file
Andre Heinecke 546c5ed0a7
Fix ngrok invocation
- The OAUTH from ngrok could not be handled by OpenAI and was
only haölf implemented. The policy file is the right way but it still
wont detect it..

- Most importantly we trail the logs at the end of the script to
avoid the script from terminating.
2025-10-11 12:32:03 +02:00
config Initial prototype of MCP Browser 2025-06-27 12:30:20 +02:00
docs fix: respect user config in ngrok helper 2025-10-11 07:52:25 +02:00
examples feat: support legacy streamable-http config entries 2025-10-10 23:55:27 +02:00
mcp_browser Initialize earlier 2025-10-11 12:30:39 +02:00
mcp_servers Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00
scripts Fix ngrok invocation 2025-10-11 12:32:03 +02:00
systemd feat: add built-in streamable-http gateway 2025-10-11 02:19:39 +02:00
tests Add enhanced interactive mode and cmem integration 2025-06-28 12:00:52 +02:00
.gitignore Add package distribution files and cleanup 2025-06-27 12:36:25 +02:00
.gitmodules Add python-sdk and modelcontextprocol as doc submodules 2025-10-10 22:27:29 +02:00
.tags Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00
CLAUDE.md Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00
HANDOFF_INSTRUCTIONS.md Add enhanced interactive mode and cmem integration 2025-06-28 12:00:52 +02:00
LICENSE Update project metadata for Xilope0 namespace 2025-06-27 12:45:34 +02:00
MANIFEST.in Fix package installation and remove demo script 2025-06-27 16:29:17 +02:00
MCP_QUICK_REFERENCE.md Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00
Makefile Add daemon management targets to Makefile 2025-06-28 00:07:56 +02:00
README.md Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00
RELEASE_NOTES.md Add release notes for v0.1.0 2025-06-27 12:47:58 +02:00
init-cmd.json Fix MCP initialization timeout and add daemon management 2025-06-27 22:00:32 +02:00
mcp-browser-interactive Add enhanced interactive mode and cmem integration 2025-06-28 12:00:52 +02:00
mcp_api_documentation.json Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00
requirements.txt feat: add built-in streamable-http gateway 2025-10-11 02:19:39 +02:00
setup.py feat: add built-in streamable-http gateway 2025-10-11 02:19:39 +02:00
test_claude_desktop_flow.py Fix MCP initialization timeout and add daemon management 2025-06-27 22:00:32 +02:00
test_discovery.py Add dynamic config reloading and comprehensive onboarding 2025-06-27 22:10:52 +02:00
test_mcp_protocol.py Fix MCP initialization timeout and add daemon management 2025-06-27 22:00:32 +02:00
test_screen_multiuser.py Add multiuser support to screen server 2025-06-27 23:50:45 +02:00
test_screen_utf8.py Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00
test_tmux_session.py Add tmux session management and screen to tmux conversion 2025-06-28 15:28:32 +02:00

README.md

MCP Browser

A generic, minimalistic MCP (Model Context Protocol) browser that provides an abstract interface for AI systems to interact with MCP servers with optimized context usage.

License: GPL v3 Python 3.8+ AI Generated

Overview

MCP Browser acts as a smart proxy between AI systems and MCP servers, providing:

  • Generic JSON-RPC interface: Single call() method for all operations
  • Context optimization: Sparse mode to minimize initial tool exposure
  • Tool discovery: Dynamic exploration of available tools via JSONPath
  • Automatic routing: Transparent routing to appropriate MCP servers
  • Built-in servers: Automatically starts useful MCP servers (screen, memory, patterns, onboarding)

Key Features

  1. Minimalistic API

    • call(jsonrpc_object): Execute any JSON-RPC call
    • discover(jsonpath): Explore available tools and their schemas
    • onboarding(identity): Get/set identity-specific instructions
  2. Context Optimization

    • Only exposes 3 essential tools initially in sparse mode
    • Tools are loaded on-demand to minimize context usage
    • Full tool descriptions cached but not exposed until needed
  3. Generic Design

    • Protocol-agnostic (works with any MCP server)
    • No hardcoded tool knowledge
    • Configuration-driven server management
  4. Built-in Servers

    • Tmux: tmux session management for persistent processes (default)
    • Screen: GNU screen session management (legacy, disabled by default)
    • Memory: Project memory, tasks, decisions, and knowledge management
    • Patterns: Auto-response pattern management for automation
    • Onboarding: Identity-aware onboarding for AI contexts

Architecture

mcp-browser/
├── mcp_browser/
│   ├── __init__.py
│   ├── proxy.py          # Main MCP proxy
│   ├── server.py         # MCP server management
│   ├── multi_server.py   # Multi-server manager
│   ├── registry.py       # Tool registry and discovery
│   ├── filter.py         # Message filtering and sparse mode
│   ├── buffer.py         # JSON-RPC message buffering
│   └── config.py         # Configuration management
├── mcp_servers/          # Built-in MCP servers
│   ├── base.py           # Base server implementation
│   ├── screen/           # Session management (tmux + screen)
│   ├── memory/           # Memory and context management
│   ├── pattern_manager/  # Pattern automation
│   └── onboarding/       # Identity-aware onboarding
├── tests/
├── docs/
│   ├── DESIGN.md         # Architecture and design details
│   ├── WORKING_DIRECTORIES.md  # Working directory and process guide
│   └── ...
└── config/
    └── default.yaml      # Default configuration

Important: See docs/WORKING_DIRECTORIES.md for detailed information about working directories, process architecture, and file path handling.

Installation

# Clone the repository
git clone https://github.com/Xilope0/mcp-browser.git
cd mcp-browser

# Install in development mode
pip install -e .

# Or install directly from GitHub
pip install git+https://github.com/Xilope0/mcp-browser.git

Quick Start

# Run enhanced interactive mode (NEW!)
./mcp-browser-interactive

# Run basic interactive mode
mcp-browser

# Run as MCP server (for chaining)
mcp-browser --mode server

# Connect to specific MCP server
mcp-browser --server claude-code

# Generate AI documentation
python setup.py aidocs

Usage

from mcp_browser import MCPBrowser

# Initialize browser (built-in servers start automatically)
async with MCPBrowser() as browser:
    # Execute any JSON-RPC call
    response = await browser.call({
        "jsonrpc": "2.0",
        "id": 1,
        "method": "tools/list",
        "params": {}
    })
    
    # Discover tool details
    tool_info = browser.discover("$.tools[?(@.name=='Bash')]")
    
    # Use identity-aware onboarding
    response = await browser.call({
        "jsonrpc": "2.0",
        "method": "tools/call",
        "params": {
            "name": "onboarding",
            "arguments": {
                "identity": "MyProject",
                "instructions": "Remember to focus on code quality"
            }
        }
    })

Sparse Mode

In sparse mode (default), only 3 tools are initially visible:

  1. mcp_discover: Explore available tools using JSONPath
  2. mcp_call: Execute any tool by name
  3. onboarding: Get/set identity-specific instructions

All other tools (potentially hundreds) are hidden but fully accessible through these meta-tools.

Enhanced Interactive Mode

The new ./mcp-browser-interactive provides a much better testing and exploration experience:

Features:

  • Tab completion for commands and tool names
  • Command history with readline support
  • Smart argument parsing with key=value syntax
  • Built-in help and tool discovery
  • Test mode to try tools with sample data
  • Direct tool calls without verbose JSON-RPC syntax

Interactive Commands:

help                    # Show available commands
list [pattern]          # List tools (with optional filter)
discover <jsonpath>     # Explore using JSONPath
call <tool> key=value   # Call tool with arguments
test <tool>             # Test tool with sample data
<tool> key=value        # Direct tool call (shortcut)
onboard <identity>      # Manage onboarding instructions
status                  # Show connection status

Example Session:

mcp> list bash                              # Find bash-related tools
mcp> discover $.tools[*].name               # List all tool names  
mcp> test Bash                              # Test Bash tool
mcp> Bash command="ls -la"                  # Direct tool call
mcp> onboard Claude "Focus on code quality" # Set onboarding

Design Principles

  1. Generic: No tool-specific knowledge built into the browser
  2. Minimal: Smallest possible API surface
  3. Efficient: Optimized for minimal context usage
  4. Transparent: Acts as a pass-through proxy with intelligent enhancements

Contributing

This project is developed exclusively by AI assistants. See CLAUDE.md for details about the AI-only development process.

If you're an AI assistant working on this project:

  1. Read CLAUDE.md for development guidelines
  2. Generate documentation with python setup.py aidocs
  3. Test changes with the example scripts
  4. Maintain context efficiency as the primary goal

License

This project is licensed under the GNU General Public License v3.0 or later (GPLv3+) - see the LICENSE file for details.

Acknowledgments

  • Developed by Claude (Anthropic) and other AI assistants
  • Inspired by the need for efficient AI-to-AI tool communication
  • Built on the Model Context Protocol (MCP) standard