logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

polyglot-mcp-gateway

A robust Python-based Model Context Protocol (MCP) orchestrator engineered for software development workflows. This system abstracts multiple proprietary Large Language Model (LLM) backends, delivering integrated features such as performance visualization, operational expenditure tracking, and synchronized execution across cooperative autonomous agents.

Author

polyglot-mcp-gateway logo

arthurcolle

No License

Quick Info

GitHub GitHub Stars 35
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

apisopenaimcpopenai mcpmcp servermcp python

Security Compliance Seal

Universal LLM Interaction Hub with MCP Support

A sophisticated Python implementation mirroring the structure of specialized coding assistants, but extended with superior real-time telemetry, financial oversight, and a fully compliant Model Context Protocol (MCP) service layer. This platform furnishes developers with a fluid, natural language interface adaptable to numerous foundational AI models.

Build Status Runtime Language

Core Capabilities

  • Model Agnosticism: Seamless interoperability with major AI vendors including OpenAI, Anthropic, and others via standardized adapters.
  • MCP Architecture Adherence:
  • Functions as an external MCP service endpoint for client applications (e.g., specialized IDE extensions).
  • Includes an embedded MCP client for connecting to external protocol servers.
  • Facilitates coordinated operations among multiple specialized AI entities.
  • Execution Monitoring: Live graphical feedback on tool invocation status and resultant outputs.
  • Financial Governance: Detailed telemetry for token consumption and proactive budget enforcement mechanisms.
  • Extensive Utility Belt: Provides file manipulation (read/write/search), shell command execution, and pattern matching capabilities.
  • Advanced Terminal Interface: Features syntax highlighting, detailed progress indicators, and an interactive layout.
  • Context Efficiency: Intelligent history compression and state retention logic.
  • Agent Orchestration: Manages collaborative workflows between distinct, role-defined autonomous agents.

Deployment Instructions

  1. Obtain a local copy of the source repository.
  2. Resolve dependencies:

bash pip install -r requirements.txt

  1. Configure credentials in a .env file:

Select one or more providers

OPENAI_API_KEY=your_openai_api_key_here ANTHROPIC_API_KEY=your_anthropic_api_key_here

Optional selection of default models

OPENAI_MODEL=gpt-4o ANTHROPIC_MODEL=claude-3-opus-20240229

Operational Modes

Interactive Command Line (CLI)

Initiate the CLI, defaulting to the first available API key holder:

bash python claude.py chat

Explicitly setting the engine and model:

bash python claude.py chat --provider openai --model gpt-4o

Applying monetary constraints:

bash python claude.py chat --budget 5.00

MCP Service Provisioning

Activate the local environment as an MCP endpoint:

bash python claude.py serve

Start in debugging mode with the MCP introspection utility:

bash python claude.py serve --dev

Specify network binding parameters:

bash python claude.py serve --host 0.0.0.0 --port 8000

Injecting external libraries at runtime:

bash python claude.py serve --dependencies pandas numpy

Loading configurations from a specific file:

bash python claude.py serve --env-file .env

MCP Client Interaction

Connect to a remote MCP service using this system as the reasoning core:

bash python claude.py mcp-client path/to/server.py

Selecting a different reasoning engine model for the connection:

bash python claude.py mcp-client path/to/server.py --model claude-3-5-sonnet-20241022

Demonstration using the provided echo service:

bash

Terminal 1: Launch the backend service

python examples/echo_server.py

Terminal 2: Initiate client connection

python claude.py mcp-client examples/echo_server.py

Synchronized Multi-Agent Execution

Engage the client in a coordinated multi-agent session:

bash python claude.py mcp-multi-agent path/to/server.py

Utilizing a custom blueprint for agent configuration:

bash python claude.py mcp-multi-agent path/to/server.py --config examples/agents_config.json

Example with the echo service:

bash

Terminal 1: Start the service interface

python examples/echo_server.py

Terminal 2: Launch the multi-agent client interface

python claude.py mcp-multi-agent examples/echo_server.py --config examples/agents_config.json

Available Operational Functions (Tools)

  • View: Securely retrieve file content, optionally limiting line count.
  • Edit: Perform targeted textual modifications within files.
  • Replace: Write new content or completely overwrite existing files.
  • GlobTool: Locate files across directories based on wildcard patterns.
  • GrepTool: Execute regular expression searches across file contents.
  • LS: Enumerate directory listings.
  • Bash: Execute arbitrary operating system shell commands.

Session Commands

  • /help: Display the command reference guide.
  • /compact: Initiate history summarization to conserve context tokens.
  • /version: Report the current software release number.
  • /providers: List all accessible LLM integration endpoints.
  • /cost: Query current usage statistics and financial outlay.
  • /budget [value]: Establish a spending ceiling.
  • /quit, /exit: Terminate the current session.

Internal Structure

The Python realization of this assistant employs a modular organizational schema:

/claude_code/ /lib/ /providers/ # LLM adapter implementations /tools/ # Function/tool implementations /context/ # State and memory management routines /ui/ # Presentation layer components /monitoring/ # Cost tracking and performance metrics /commands/ # Command line interface handlers /config/ # Parameter loading utilities /util/ # General purpose support modules claude.py # Primary execution script (CLI) mcp_server.py # Model Context Protocol service implementation

Utilizing the Model Context Protocol

Deploying as an MCP Backend

After initiating the local MCP service layer: bash python claude.py serve

Access the configuration interface in a web browser:

http://localhost:8000

Follow prompts to integrate with external clients (e.g., Claude Desktop), which typically involves: - Copying the generated configuration payload. - Downloading the auto-generated configuration artifact. - Reviewing the detailed setup guide.

Utilizing as an MCP Initiator (Client)

To interface with any external MCP host using this software as the AI engine:

  1. Ensure the required AI vendor API key is configured in the environment or .env file.
  2. Verify the target MCP server is operational.
  3. Connect via the client module: bash python claude.py mcp-client path/to/server.py

  4. Input queries into the interactive dialogue shell.

Multi-Agent Operational Mode

For complex, multi-faceted challenges, multi-agent concurrency is enabled:

  1. Define the agent roles and interaction schema (or use an existing configuration).
  2. Activate the target MCP service.
  3. Invoke the multi-agent client module: bash python claude.py mcp-multi-agent path/to/server.py --config examples/agents_config.json

  4. Interact using specialized commands:

  5. Standard input broadcasts to all active agents.
  6. Use /talk Agent_Name message for direct targeted communication.
  7. Use /agents to list participants.
  8. Use /history to review the collaborative transcript.

Development Guidelines

  1. Fork the primary repository.
  2. Establish a dedicated feature branch for your contribution.
  3. Develop changes alongside corresponding unit tests.
  4. Submit a Pull Request for review.

Licensing

MIT

Attributions

This foundational project draws inspiration from the Anthropic Claude Code CLI, redeveloped in Python to incorporate advanced monitoring, cost accountability, and full MCP server functionality.# OpenA-Codex Interface

A streamlined command-line utility and service layer leveraging OpenAI's API functionalities, including function invocation and real-time data streaming.

Core Capabilities

  • Interactive command-line reasoning interface.
  • Accessible Web Service for external application linkage.
  • Native implementation of the Model Context Protocol (MCP) server.
  • Infrastructure replication support for enhanced uptime.
  • Extensible, function-driven operational structure.
  • Support for optimizing tool selection via reinforcement learning (RL).
  • Browser-accessible front-end portal.

Installation Procedure

  1. Clone the repository source code.
  2. Install required modules: bash pip install -r requirements.txt

  3. Set the requisite OpenAI API access credential: bash export OPENAI_API_KEY=your_api_key

Utilization Scenarios

Command Line Interface (CLI)

Run the reasoning assistant interactively from the terminal:

bash python cli.py

Available command-line arguments: - --model, -m: Designation of the AI engine (default: gpt-4o). - --temperature, -t: Value influencing response randomness (default: 0). - --verbose, -v: Enable detailed diagnostic output. - --enable-rl/--disable-rl: Toggle the RL mechanism for tool preference tuning. - --rl-update: Manual trigger for refreshing the RL configuration model.

Application Service Backend

Deploy the assistant as a RESTful service endpoint:

bash python cli.py serve

Configuration flags: - --host: Network interface binding address (default: 127.0.0.1). - --port, -p: TCP port number to monitor (default: 8000). - --workers, -w: Number of concurrent process threads (default: 1). - --enable-replication: Activate state synchronization protocols. - --primary/--secondary: Designate this instance's role in replication. - --peer: Specify address(es) of partner instances (host:port format, repeatable).

MCP Service Interface

Activate the system specifically as an MCP-compliant server:

bash python cli.py mcp-serve

Arguments specific to MCP service: - --host: Network binding address (default: 127.0.0.1). - --port, -p: Listening port (default: 8000). - --dev: Activate enhanced logging for development activities. - --dependencies: List of supplementary Python packages to ensure availability. - --env-file: Path to an alternative environment variable source file.

MCP Client Mode

Connect this system to an existing MCP server, using it for task resolution:

bash python cli.py mcp-client path/to/server.py

Overrides for client behavior: - --model, -m: AI model designated for the remote reasoning (default: gpt-4o). - --host: IP address of the target MCP endpoint (default: 127.0.0.1). - --port, -p: Port number of the target MCP endpoint (default: 8000).

Deployment Script Automation

Use the provided shell script for streamlined deployment setups:

bash ./deploy.sh --host 0.0.0.0 --port 8000 --workers 4

To enable synchronous operation across nodes:

bash

Primary node startup

./deploy.sh --enable-replication --port 8000

Secondary node startup, linking to primary

./deploy.sh --enable-replication --secondary --port 8001 --peer 127.0.0.1:8000

Web Interface Access

Access the graphical user interface by navigating to web-client.html in a compatible browser, contingent on the API service running.

Service Contract Endpoints

Standard RESTful Endpoints

  • POST /conversation: Initialize a new dialogue session.
  • POST /conversation/{conversation_id}/message: Transmit a query within an ongoing session.
  • POST /conversation/{conversation_id}/message/stream: Stream response data for the current message.
  • GET /conversation/{conversation_id}: Retrieve session metadata.
  • DELETE /conversation/{conversation_id}: Terminate and erase a session.
  • GET /health: Endpoint for service operational status checks.

MCP Protocol Endpoints

  • GET /: Health check aligned with the MCP specification.
  • POST /context: Request contextual data for a specified prompt template.
  • GET /prompts: List all defined prompt schemas.
  • GET /prompts/{prompt_id}: Fetch details for a specific prompt schema.
  • POST /prompts: Register a new prompt schema.
  • PUT /prompts/{prompt_id}: Modify an existing prompt schema.
  • DELETE /prompts/{prompt_id}: Decommission a prompt schema.

State Synchronization (Replication)

Replication facilitates running redundant instances of the assistant, thereby achieving:

  • Elevated system availability.
  • Automated load distribution.
  • Robust failure recovery mechanisms.

Setup protocol: 1. Launch the initial node with the --enable-replication flag set as primary. 2. Start subsequent nodes using --enable-replication --secondary --peer [primary-host:port].

Available Functionalities (Toolset)

The assistant incorporates a comprehensive suite of integrated capabilities: - Weather: Acquire current meteorological conditions for a specified geographic location. - View: System file content retrieval. - Edit: System file modification. - Replace: System file content writing/overwriting. - Bash: Execution context for system shell commands. - GlobTool: File system pattern matching utility. - GrepTool: Advanced content searching using regular expressions. - LS: Directory structure listing. - JinaSearch: Internet data retrieval powered by Jina.ai. - JinaFactCheck: Verification service utilizing Jina.ai knowledge bases. - JinaReadURL: Web page fetching and abstract generation.

CLI Control Commands

  • /help: Displays the comprehensive command index.
  • /compact: Truncates session history to optimize token usage.
  • /status: Outputs current token metrics and session parameters.
  • /config: Reveals the active operational configuration variables.
  • /rl-status: Reports on the status of the RL tool tuner (if active).
  • /rl-update: Initiates a manual recalibration of the RL model.
  • /rl-stats: Shows usage frequency statistics for invoked tools (if active).

WIKIPEDIA: XMLHttpRequest (XHR) represents a JavaScript API, structured as an object, designed to facilitate the transmission of Hypertext Transfer Protocol (HTTP) requests from a web browser environment to a remote web server. Its methods enable browser-based applications to dispatch asynchronous requests subsequent to page initialization, allowing for the reception of server-side data without necessitating a full page reload. XMLHttpRequest is fundamental to the programming paradigm known as Ajax. Before its widespread adoption, server interaction primarily relied on traditional page navigations triggered by form submissions or hyperlink clicks, which inherently caused the current view to be replaced.

== Historical Development == The foundational concept underpinning XMLHttpRequest was formulated in the year 2000 by the development team responsible for Microsoft Outlook. This concept was subsequently integrated into the Internet Explorer 5 browser release in 1999. However, the initial implementation did not utilize the standardized XMLHttpRequest identifier. Instead, developers leveraged COM object instantiation via ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). By the time Internet Explorer 7 was released in 2006, comprehensive support for the canonical XMLHttpRequest identifier was universally established across all major browser engines. The XMLHttpRequest identifier has since solidified its status as the prevailing standard across all dominant browser platforms, including Mozilla's Gecko rendering engine (adopted in 2002), Apple's Safari 1.2 (2004), and Opera 8.0 (2005).

=== Standardization Efforts === The World Wide Web Consortium (W3C) released the first Working Draft specification for the XMLHttpRequest object on April 5, 2006. Subsequently, on February 25, 2008, the W3C issued the Level 2 specification. Level 2 introduced critical enhancements such as event progress monitoring capabilities, permission for cross-origin requests, and methods for handling raw byte streams. Towards the close of 2011, the Level 2 specifications were formally merged back into the primary document. As of late 2012, the Web Hypertext Application Technology Working Group (WHATWG) assumed responsibility for ongoing maintenance, now sustaining a continuously evolving document defined using Web IDL syntax.

== Operational Procedure == In typical application, performing a server request using XMLHttpRequest necessitates adherence to a sequence of programming stages.

Instantiation of the XMLHttpRequest object via its constructor call: Invocation of the open method to define the request method (GET/POST, etc.), specify the target URI, and declare whether the operation will be synchronous or asynchronous: For asynchronous requests, the assignment of an event handler function designed to execute upon changes in the request's state: Initiation of the network transmission by executing the send method: Processing the state transitions within the assigned event listener. When the server concludes data transmission, the state transitions to 4, signifying the "complete" status, at which point the response payload is typically accessible via the responseText property. Beyond these fundamental steps, XMLHttpRequest offers extensive configuration options governing transmission methodology and response parsing. Custom request headers can be appended to influence server behavior, and data payloads can be uploaded using arguments supplied to the send call. The incoming data stream can be automatically deserialized from JSON format into native JavaScript objects, or processed incrementally as segments arrive rather than waiting for the entire body. Furthermore, requests can be terminated prematurely via abort, or configured to time out if completion is not achieved within a predefined duration.

== Cross-Domain Transactions ==

During the nascent stages of the World Wide Web's development, vulnerabilities were identified that allowed breaches of the same-origin policy, permitting unintended data exchange betwee

See Also

`