Unified Cognitive Orchestrator System
A high-performance, MCP-native middleware engine designed to manage, optimize, and augment AI agents by intelligently routing complex tasks across a heterogeneous ecosystem of specialized LLMs, proprietary tools, and local system capabilities, focusing heavily on cost governance and performance balancing.
Author

Dicklesworthstone
Quick Info
Actions
Tags
🧠 Unified Cognitive Orchestrator System (UCOS)
🎯 Core Concepts: Beyond Simple Proxying
UCOS transcends conventional API gateways by embedding deep intelligence into the task routing mechanism. It functions as an AI Operating Environment, enabling agents (like advanced LLMs) to operate autonomously across digital domains without being constrained by their native training data or context windows.
While efficient cost delegation remains a key outcome (e.g., routing simple summarization from Claude 3.7 Opus to Gemini Flash 2.0), the primary focus is capability augmentation and workflow resilience.
The system exposes dozens of integrated capabilities via the Model Context Protocol (MCP), transforming a stateless conversational model into a powerful, stateful, autonomous processing engine capable of multi-step operations involving data manipulation, external system interaction, and persistent knowledge management.
⚙️ Capability Matrix: The Augmented AI Toolkit
UCOS provides unified access to a vast array of specialized functions, categorized by their primary operational domain:
| Domain | Key Functionalities Exposed via MCP Tools |
|---|---|
| Reasoning & Synthesis | Cost-Aware LLM Routing, Multi-Model Tournament Evaluation, Response Synthesis, Prompt Templating (Jinja2) |
| Data & Document Processing | Semantic Chunking, Parallel Document Processing, Structured Extraction (JSON/Tables), OCR Enhancement (Tesseract + LLM refinement), HTML/Markdown Conversion |
| System & Environment | Secure Filesystem R/W/Search, Command-Line Execution Wrapper (e.g., jq, ripgrep), Dynamic REST API Registration/Invocation |
| Knowledge & Memory | Persistent Hierarchical Memory (Episodic, Semantic), Knowledge Graph Construction & Querying, Vector Operations for Retrieval-Augmented Generation (RAG) |
| External Interaction | Headless Browser Automation (Playwright for navigation, scraping, screenshotting), Full Spreadsheet Manipulation (Excel/Sheets) |
| Meta-Intelligence | Autonomous Documentation Refinement (Testing, Failure Analysis, Schema Patching), Tool Discovery (list_tools), Workflow Orchestration Engine |
💰 Cost Governance & Provider Abstraction
A critical function of UCOS is managing the economic viability of complex AI operations. This is achieved through:
- Provider Agnostic Layer: A unified interface shields consuming agents from provider-specific idiosyncrasies, supporting OpenAI, Anthropic, Google Gemini, DeepSeek, Grok, and OpenRouter via a single communication channel.
- Intelligent Cost Routing: The system analyzes the complexity, required quality, and urgency of a request to route it to the model/provider offering the best Quality-to-Cost Ratio for that specific task.
- Advanced Caching: Implements multi-level caching (exact match, semantic similarity, task-aware) to eliminate redundant inference calls.
- Non-LLM Offloading: Routinely offloading tasks like file manipulation, string processing, or simple data retrieval to local, zero-cost tools.
This orchestration can lead to 70-90% reduction in operational costs compared to routing all requests to a single, premium-tier model.
⚛️ MCP-Native Design
The entire system adheres strictly to the Model Context Protocol (MCP). All functionalities are exposed as typed, discoverable MCP tools. This design ensures:
- Interoperability: Seamless integration with any client adhering to the MCP specification.
- Schema Fidelity: All inputs and outputs are strongly typed, reducing ambiguity for the consuming agent.
- Discoverability: Agents can query the server to understand available tools and their exact schema requirements (
list_tools).
🚀 Key Features Deep Dive
Autonomous Documentation Refiner (ADR)
This internal diagnostic capability systematically analyzes tool documentation (docstrings and schemas) by:
- Simulating agent calls to detect ambiguities.
- Generating schema-aware unit tests based on expected behavior.
- Using LLM ensembles to diagnose failure points.
- Proposing validated JSON Schema patches or docstring rewrites to resolve ambiguities.
This ensures that documentation remains accurate as tool implementations evolve, leading to higher agent success rates.
Workflow Orchestration Engine
Enables the definition of multi-stage pipelines where the output of one tool execution becomes the input for subsequent stages. The engine automatically handles:
- Dependency resolution (Stage B runs only after Stage A completes).
- Parallel execution where dependencies allow.
- Dynamic resource allocation based on cost/quality preferences set at the stage level.
Resilience and Observability
- Provider Fallbacks: Configurable logic to switch to a secondary provider if the primary one fails or times out.
- Automatic Retries: Transparent exponential backoff for transient network or rate-limiting errors.
- Telemetry: Comprehensive logging of every tool invocation, LLM usage (tokens, cost), cache hits/misses, and execution latency, viewable via CLI or an integrated analytics endpoint.
📦 Deployment & Setup
Installation requires Python 3.13+ and dependency management via uv.
bash
Install uv package manager if necessary
curl -LsSf https://astral.sh/uv/install.sh | sh
Clone and setup environment
git clone [REPO_URL] cd unified_cognitive_orchestrator uv venv --python 3.13 source .venv/bin/activate uv sync --all-extras # Install all required tools including browser, OCR, etc.
Configuration (.env file):
API credentials (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY) and server settings (SERVER_HOST, SERVER_PORT) are loaded from this file.
Startup Command: bash umcp run --transport-mode shttp # Start server with streaming HTTP transport
⚙️ CLI Reference (umcp)
The accompanying CLI offers robust utilities for server control and direct interaction:
umcp run: Manages server lifecycle, including tool selection (--include-tools,--exclude-tools).umcp providers: Displays configured LLM backends and available models.umcp test <provider>: Verifies connectivity and runs a baseline prompt against a specific provider/model.umcp complete: Direct text generation interface, allowing specification of provider, model, temperature, and streaming.umcp cache: Monitors and manages the response cache to ensure performance and cost savings.umcp benchmark: Executes defined performance tests across multiple models to empirically determine optimal cost/speed/quality pairings.umcp tools: Lists all registered MCP capabilities with descriptions and schema details.umcp examples: Runs bundled Python scripts demonstrating complex feature integration (RAG, Excel manipulation, Multi-Provider calls).
Cloud Computing Context Note: UCOS provides the necessary abstraction layer (essential characteristic: Abstraction) to utilize various cloud-hosted LLM and service providers effectively, managing the dynamic allocation and pooling of these external compute resources (essential characteristic: Resource Pooling and Rapid Elasticity), all while providing transparent usage metrics to the consumer (essential characteristic: Measured Service).
