Sponsored by Deepsite.site

MCP-Codex: Model Context Protocol Tool Orchestration

Created By
twolven8 months ago
A MCP server for calling MCP tools remotely without requiring installation.
Content

MCP-Codex: Model Context Protocol Tool Orchestration

DISCLAIMER: This project was discontinued after Cloudflare released a similar service that addressed many of the same problems. I'm sharing this codebase as an educational resource and example of MCP orchestration architecture. While no longer actively developed, the concepts and implementations may still be valuable to those interested in AI tool orchestration. Please see Cloudflare's new Remote MCP service and their blogpost announcement here: https://blog.cloudflare.com/remote-model-context-protocol-servers-mcp/

License

A service for orchestrating Model Context Protocol (MCP) servers and allowing AI assistants to dynamically discover and utilize tools without requiring restarts, powered by "The Librarian" - an intelligent agent that understands user needs and connects them with the perfect tools.

Overview

MCP-Codex solves a core problem with the Model Context Protocol ecosystem: the need to restart AI assistants when adding new tools. It enables dynamic tool discovery and execution through a central service, allowing AI assistants to use any compatible MCP tool on demand.

The Librarian: Intelligent Tool Discovery

At the heart of MCP-Codex is "The Librarian" - an intelligent agent designed to understand user needs and connect them with the right tools. The Librarian functions as an agentic RAG (Retrieval-Augmented Generation) system with:

  • Multi-Vector Knowledge Base: Separate vector databases for industry knowledge and internal documentation
  • MCP Repository Awareness: Deep understanding of available MCP tools across the ecosystem
  • Just-in-Time Tool Installation: Capability to install tools on-demand before they're needed
  • Context-Aware Recommendations: Uses the full context of user queries to identify the optimal tools
  • Seamless Integration: Handles all details of tool discovery, installation, and execution

The Librarian effectively serves as a universal adapter between user intent and technical capabilities, eliminating the cognitive load of tool selection for both users and AI assistants.

The Problem

Model Context Protocol (MCP) is a powerful standard for connecting AI assistants to external tools and data sources. However, traditional MCP implementations have a significant limitation:

  • Static Configuration: Tools must be configured at startup, requiring restarts whenever new capabilities are needed
  • Local-Only Operation: Tools typically run on the same machine as the assistant
  • Limited Discovery: Assistants have no standardized way to discover what tools are available
  • High Cognitive Load: Users must know exactly which tool they need for a specific task

The Solution

MCP-Codex provides a bridge between AI assistants and the broader MCP ecosystem by offering:

  1. Intelligent Tool Discovery: The Librarian service analyzes user intent and recommends the perfect tools
  2. Dynamic Tool Management: Tools can be installed, configured, and executed on-demand
  3. Remote Execution: Tools can run anywhere, not just on the local machine
  4. Centralized Management: Tools can be added, updated, or removed without restarting assistants
  5. Standardized Protocol: A consistent interface for interacting with any MCP tool

Architecture

The project consists of three main components:

  1. Codex Service (codex-serv.py): The core execution service that manages tool discovery and invocation
  2. Librarian Service (planned): An AI-powered tool recommendation system
  3. MCP Client (mcp-codex.py): The MCP-compatible interface for AI assistants

How It Works

  1. The AI assistant connects to the MCP-Codex client
  2. The client presents two main tools: search and call_tool
  3. The assistant can search for capabilities using natural language
  4. Once a tool is identified, it can be executed through a standardized call
  5. The Codex service handles the actual tool execution and returns results

Components

Codex Service

The central orchestration service that:

  • Manages the registry of available MCP tools
  • Handles tool execution requests
  • Routes requests to the appropriate tool subprocess
  • Manages tool lifecycle

MCP Client

The MCP-compliant interface that allows any MCP-compatible assistant to:

  • Connect to the Codex ecosystem
  • Search for available tools
  • Execute tools through a standardized interface

Included Tool Examples

The repository includes several example MCP tools:

  • StockFlow: Financial data and stock market analysis tools
  • OptionsFlow: Options trading analysis and strategy evaluation
  • CodeSavant: Code management, editing, and execution tools
  • StockScreen: Stock screening and filtering capabilities

Installation

Prerequisites

  • Python 3.10+
  • Required Python packages (see requirements.txt)

Setup

  1. Clone the repository:
git clone https://github.com/your-username/mcp-codex.git
cd mcp-codex
  1. Install dependencies:
pip install -r requirements.txt
  1. Create required directories:
mkdir -p config data logs tools
  1. Configure your environment:
cp .env.example .env
# Edit .env with your configuration

Usage

Starting the Codex Service

python codex-serv.py

Starting the MCP Client

python mcp-codex.py

Using with Claude Desktop

  1. Install the MCP Client in Claude Desktop:
mcp install mcp-codex.py
  1. The client will register two tools:

    • search: Find relevant tools for your task
    • call_tool: Execute discovered tools
  2. Example usage in Claude:

I need to analyze stock data for Apple. Can you help me find the right tool?

Roadmap

The project was planned to include several fully-realized components:

The Librarian (In-Depth)

The Librarian was envisioned as a sophisticated AI-powered tool orchestration system that would:

  • Function as an Agentic RAG System: Combining retrieval capabilities with generative intelligence
  • Maintain Multiple Knowledge Sources:
    • Industry knowledge vector database (general technical information)
    • Internal documentation vector database (specific tool capabilities)
    • Real-time MCP repository indexing (available tools in the ecosystem)
  • Execute Complex Tool Selection Logic:
    • Analyze user queries for underlying intent
    • Match intent to required capabilities
    • Identify optimal tools across the entire MCP ecosystem
    • Consider tool compatibility, performance, and reliability
  • Provide Just-in-Time Tool Management:
    • Detect when required tools aren't installed
    • Automatically install needed tools from repositories
    • Configure tools appropriately for the specific task
    • Verify successful installation before execution
  • Handle the Full Execution Lifecycle:
    • Prepare tools with appropriate context
    • Monitor execution progress
    • Manage error handling and recovery
    • Provide results in the most useful format
  • Learn and Improve Continuously:
    • Track tool performance and reliability
    • Learn from user feedback and corrections
    • Improve recommendations based on historical success
    • Adapt to new tools and capabilities

Additional Planned Features

  • User authentication and authorization
  • Tool sandboxing for security
  • Cloud deployment support
  • Tool versioning and compatibility checking
  • Performance monitoring and analytics

Documentation

Tool Registry Configuration

Tools are defined in the config/codex.yaml file with the following structure:

tools:
  - name: tool_name
    description: Tool description
    server: path/to/tool/server.py
    methods:
      - method_name
    schemas:
      method_name:
        type: object
        properties:
          # Parameter definitions

API Endpoints

The Codex service provides the following REST endpoints:

  • /health: Health check endpoint
  • /search: Search for tools matching a query
  • /call_tool: Execute a specific tool method
  • /reload: Reload tool configurations

Why This Project

This project was created to address several limitations in the current AI tool ecosystem:

  1. Enable True Agent Capabilities: Allow AI assistants to dynamically discover and use tools based on user needs
  2. Reduce Operational Complexity: Eliminate the need to restart AI services when adding new capabilities
  3. Centralize Tool Management: Provide a single point of control for tool deployment and updates
  4. Standardize Tool Interaction: Create a consistent interface for tool discovery and execution
  5. Support Remote Execution: Allow tools to run anywhere, not just on the local machine

Unfortunately, similar functionality was recently released by Cloudflare, making aspects of this project redundant. However, the codebase still provides valuable insights into MCP orchestration and dynamic tool discovery.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Model Context Protocol for the inspiration and core protocol design
  • The open-source MCP community for their valuable contributions
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
WindsurfThe new purpose-built IDE to harness magic
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Amap Maps高德地图官方 MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
ChatWiseThe second fastest AI chatbot™
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Playwright McpPlaywright MCP server
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Serper MCP ServerA Serper MCP Server
DeepChatYour AI Partner on Desktop