Skip to main content
Glama

title: Universal AI Hub emoji: ๐Ÿ›ก๏ธ colorFrom: indigo colorTo: red sdk: docker pinned: true license: apache-2.0 short_description: Secure Multi-HUB i craft since month

Universal AI Hub ๐Ÿ›ก๏ธ

๐Ÿšง Status: Under active development. Built strictly for private spaces with hardened anti-spam and anti-scammer guardrails. Use at your own discretion.

aka: a clean, secure starting point for your own projects. Pick the description that fits your use case. They're all correct.

A the-thing that actually thinks about security. Built on PyFundaments โ€” running on simpleCity.

No key โ†’ no tool โ†’ no crash โ†’ no exposed secrets

This is not a MCP agent or collection of bullshit skill and agent files! This is an hub and has a real architecture.

IMPORTANT

This project is under active development โ€” always use the latest release fromCodey Lab (more stable builds land here first). This repo (DEV) is where the chaos happens. ๐Ÿ”ฌ A โญ on the repos will be cool ๐Ÿ˜™


I created this code on my own. And it took a toll on me - I mean really took a toll. We're not talking about my code not working, but more like I've been looking at my own design for so long that my brain is a mess. That's when AI came into the picture - not to do the coding for me, but to help me make sense of my thoughts and organize the ideas that were already floating around in my head.

So, is this something called vibecoding? No, it's not. Vibecoding is when you send off code without really understanding what it does, and just hope it works out. But I know exactly what's going on here - every single line, even the weird parts. I made some specific choices, like using the guardian pattern, setting up a sandbox, and creating a .pyfun file that's the single source of truth. I also followed the no-key-no-tool rule. These were all my decisions, made before any AI even got involved. My coding style is pretty unique, and you'll notice it as soon as you look at the source code. The AI was more like a partner that helped me out, typing fast and sometimes making mistakes that I had to fix.

...or am I just making it up? Don't just listen to me, go check the code for yourself.


Full changelog (with proof) in REVIEW.md. The short version, my words:

  • Memory orchestration. persist_result without DATABASE_URL used to throw a RuntimeError. Now everything lands in a restart-safe persist_queue in SQLite โ€” proven: 3 entries in, reboot, 3 entries out โ€” and a background flusher pushes them into PostgreSQL whenever the bridge is back. persist_status (MCP + /api) shows queue depth, attempts and bridge state.

  • Auto-pricing, konsequent. I asked whether the manual cost_* lines still make sense. OpenRouter FAQ, checked live: no markup, per-token = vendor list price (the ~5.5 % fee hits credit purchase, not tokens). So 34 cost lines are gone. What stays: my own models (smollm2-360m = 0.0 โ€” no external source knows my own deployment). .pyfun values still win as override, always.

  • ShellMaster = SECURITY LEVEL ROT. My CLI commander for the local Quart agent (localhost:5004) โ€” commands run on YOUR machine, so: local only, never on a public Space. Token lives in .env via SHELLMASTER_TOKEN (same pattern as every provider); the .pyfun field is only a local test fallback. active = "false". Stays off until someone consciously flips it.

  • Score slot for my filter. hub_results.score exists โ€” the hub passes it through completely uninterpreted. What's worth remembering long-term gets decided by my own filter, not by the hub. That part is my code, my rules.

Tests: 26/26 orchestration + 4/4 smoke โ€” green.

  • Fixed: /mcp 404 (mount middleware stripped the prefix FastMCP expects) and the missing session-manager lifespan โ€” MCP is fully functional again.

  • New: Auto model pricing โ€” costs fetched from the public OpenRouter models API + the LiteLLM community price list, cached in db_sync (24h TTL). .pyfun [MODELS] values win as override.

  • New: Brave + Tavily search providers with fallback chain โ€” web_search registers as soon as BRAVE_API_KEY or TAVILY_API_KEY is set.

  • New: db_query as MCP tool (SELECT-only, app/* tables).

  • Cleanup: dead code removed, requirements.txt pins mcp>=1.10,<2 (not fastmcp), LF line endings.


The AI ecosystem is full of servers with hardcoded keys, os.environ scattered everywhere, zero sandboxing. One misconfigured fork and your API keys are gone.

This is exactly the kind of negligence (and worse โ€” outright fraud) that Wall of Shames documents: fake "AI tools" exploiting non-technical users โ€” API wrappers dressed up as custom models, Telegram payment funnels, bought stars. If you build on open source, you should know this exists.

This hub is the antidote:

  • Structural sandboxing โ€” app/* can never touch fundaments/ or .env. Not by convention. By design.

  • Guardian pattern โ€” main.py is the only process that reads secrets. It injects validated services as a dict. app/* never sees the raw environment.

  • Graceful degradation โ€” No key? Tool doesn't register. Server still starts. No crash, no error, no empty None floating around.

  • Single source of truth โ€” All tool/provider/model config lives in app/.pyfun. Adding a provider = edit one file. No code changes.


Two completely independent interfaces on the same hypercorn instance:

POST /api          โ†’ REST interface โ€” for custom clients, desktop apps, CMS plugins
GET+POST /mcp      โ†’ MCP interface โ€” for Claude Desktop, Cursor, Windsurf, any MCP client
GET /              โ†’ Health check โ€” uptime, status

They share the same tool registry, provider config, and fallback chain. Adding a tool once makes it available on both interfaces automatically.

REST (/api) โ€” simple JSON POST, no protocol overhead, works with any HTTP client:

POST /api
{"tool": "llm_complete", "params": {"prompt": "Hello", "provider": "anthropic"}}

Used by: Desktop Client (DESKTOP_CLIENT/*), WordPress plugin, any custom integration.

MCP (/mcp) โ€” full MCP protocol: tool discovery, structured calls, streaming responses.

  • Primary transport: Streamable HTTP (MCP spec 2025-11-25)

  • Fallback transport: SSE (legacy, configurable via .pyfun)

[HUB]
HUB_TRANSPORT = "streamable-http"   # default โ€” MCP spec 2025-11-25
# HUB_TRANSPORT = "sse"             # legacy fallback for older clients
[HUB_END]

Auth, rate limiting and logging can all hook into the /mcp route in app/app.py before a request ever reaches FastMCP.


main.py (Guardian)
โ”‚
โ”‚  reads .env / HF Secrets
โ”‚  initializes fundaments/* conditionally
โ”‚  injects validated services as dict
โ”‚
โ””โ”€โ”€โ–บ app/app.py (Orchestrator, sandboxed)
     โ”‚
     โ”‚  unpacks fundaments ONCE, at startup, never stores globally
     โ”‚  starts hypercorn (async ASGI)
     โ”‚  routes: GET / | POST /api | /mcp (transport-dependent)
     โ”‚
     โ”œโ”€โ”€ app/mcp.py         โ† FastMCP + transport handler (Streamable HTTP / SSE)
     โ”œโ”€โ”€ app/tools.py       โ† Tool registry (key-gated)
     โ”œโ”€โ”€ app/providers.py   โ† LLM + Search execution + fallback chain
     โ”œโ”€โ”€ app/models.py      โ† Model limits, costs, capabilities
     โ”œโ”€โ”€ app/shellmaster.py โ† CLI commander (SECURITY LEVEL ROT โ€” local only)
     โ”œโ”€โ”€ app/pricing.py     โ† Auto model pricing (OpenRouter + LiteLLM)
     โ”œโ”€โ”€ app/config.py      โ† .pyfun parser (single source of truth)
     โ””โ”€โ”€ app/db_sync.py     โ† SQLite: short-term state + persist_queue (memory bridge)
                              โ‰  fundaments/postgresql.py (Guardian-only, long-term)
# app/app.py โ€” fundaments unpacked ONCE, NEVER stored globally
async def start_application(fundaments: Dict[str, Any]) -> None:
    config_service         = fundaments["config"]
    db_service             = fundaments["db"]          # None if not configured
    encryption_service     = fundaments["encryption"]  # None if keys missing
    access_control_service = fundaments["access_control"]
    ...
    # From here: app/* reads its own config from app/.pyfun only.
    # fundaments are never passed into other app/* modules.

app/app.py never calls os.environ. Never imports from fundaments/. Never reads .env. This isn't documentation. It's enforced by the import structure.

Why Quart + hypercorn?

Quart is async Flask โ€” fully async/await native. FastMCP's handlers are async; mixing sync Flask would require thread hacks. With Quart, /mcp hands off directly to FastMCP โ€” no bridging, no blocking.

hypercorn is an ASGI server (vs. waitress/gunicorn which are WSGI). WSGI servers handle one request per thread โ€” wrong for long-lived MCP connections. hypercorn handles both Streamable HTTP and SSE natively, and runs without extra config on HuggingFace Spaces. HTTP/2 support (config.h2 = True) is built-in.


The design is deliberately simple:

SQLite  = short-term memory  โ€” all AI tools read & write here, nobody waits for the cloud
SQLite persist_queue = the bridge โ€” restart-safe, survives reboots (proven)
PostgreSQL = long-term memory โ€” what survived MY filter goes here
persist_result (MCP + /api)
   โ†“ enqueue_persist()        โ† immediately, ALWAYS, no crash โ€” even without DATABASE_URL
persist_queue (SQLite)        โ† survives restarts; on HF Spaces /tmp, PG is the only durable memory
   โ†“ flush_persist_queue()    โ† background flusher, retry every 60 s (configurable)
PostgreSQL hub_results        โ† (id, created_at, source, model, score, payload JSONB)
  • No DATABASE_URL? status: "queued" โ€” no RuntimeError, no 502, nothing lost.

  • PostgreSQL down? Entry stays, attempts +1, sanitized last_error. Flusher catches up when the bridge returns.

  • score REAL โ€” a reserved slot for my own quality filter. The hub passes it through untouched; the filter writes it (or filters on read) later. No hub code interprets it. That's on purpose โ€” my filter, my rules.

  • Limits: queue max 500 (oldest evicted, like tool_cache) ยท at-least-once semantics (a duplicate beats a loss) ยท observability via persist_status (queue depth, oldest entry, attempts, bridge state).

Guardian layer vs app layer โ€” table ownership, hard rule:

Table

Owner

Access

users

fundaments/user_handler.py

Guardian only

sessions

fundaments/user_handler.py

Guardian only

hub_state, tool_cache, persist_queue

app/db_sync.py

app/* only

hub_results

PostgreSQL / Guardian

via persist_result โ†’ queue โ†’ flusher


Tools register at startup โ€” only if the required API key exists. No key, no tool. Server always starts.

ENV Secret

Tool

Notes

ANTHROPIC_API_KEY

llm_complete

Claude Haiku / Sonnet / Opus

GEMINI_API_KEY

llm_complete

Gemini 2.0 / 2.5 / 3.x Flash & Pro

OPENROUTER_API_KEY

llm_complete

100+ models via OpenRouter

HF_TOKEN

llm_complete

HuggingFace Inference API

BRAVE_API_KEY

web_search

Independent web index

TAVILY_API_KEY

web_search

AI-optimized search with synthesized answers

DATABASE_URL

persist_result, persist_status

Long-term memory bridge (queue without it)

SHELLMASTER_TOKEN

shellmaster*

โ›” SECURITY LEVEL RED โ€” local only, active="false"

(always)

list_active_tools

Shows key names only โ€” never values. Plus pricing_stats

(always)

health_check

Status + uptime + active transport

(always)

get_model_info

Limits, costs, capabilities per model (auto-merged)

(always)

get_model_pricing

Auto-fetched costs โ€” .pyfun values win as override

(always)

refresh_pricing

Force refresh from OpenRouter + LiteLLM

(always)

db_query

Read-only SELECT on internal hub state

For all key names see app/.pyfun.

Tools are configured in .pyfun โ€” including system prompts:

[TOOL.code_review]
active           = "true"
description      = "Review code for bugs, security issues and improvements"
provider_type    = "llm"
default_provider = "anthropic"
timeout_sec      = "60"
system_prompt    = "You are an expert code reviewer. Analyze the given code for bugs, security issues, and improvements. Be specific and concise."
[TOOL.code_review_END]

Current built-in tools: llm_complete, code_review, summarize, translate, web_search, db_query, persist_result, persist_status Future hooks (commented, ready): image_gen, code_exec, ShellMaster 2.0 (ROT โ€” local only), Discord, GitHub webhooks


All LLM providers share one llm_complete tool. If a provider fails, the hub walks the fallback chain from .pyfun:

e.g. anthropic โ†’ gemini โ†’ openrouter โ†’ huggingface
[LLM_PROVIDER.anthropic]
fallback_to = "gemini"
[LLM_PROVIDER.anthropic_END]

[LLM_PROVIDER.gemini]
fallback_to = "openrouter"
[LLM_PROVIDER.gemini_END]

Same pattern applies to search providers (brave โ†’ tavily).


  1. Fork / duplicate this Space

  2. Go to Settings โ†’ Variables and secrets

  3. Add the API keys you have (any subset works)

  4. Space starts automatically โ€” only tools with valid keys register

โ†’ Live Demo Space (no LLM keys set) -- last Version

Local / Docker

git clone https://github.com/VolkanSah/Multi-LLM-API-Gateway
cd Multi-LLM-API-Gateway
cp example-mcp___.env .env
# fill in your keys
pip install -r requirements.txt
python main.py

Minimum required ENV vars (everything else is optional):

PYFUNDAMENTS_DEBUG=""
LOG_LEVEL="INFO"
LOG_TO_TMP=""
ENABLE_PUBLIC_LOGS="false"
HF_TOKEN=""
HUB_SPACE_URL=""

Note: HF Spaces prints stdout to a publicly visible log tab. ENABLE_PUBLIC_LOGS="false" keeps your logs yours. Default in code is still true โ€” my fundament, my call, documented everywhere; flip it consciously.

Transport is configured in app/.pyfun [HUB] โ€” not via ENV.


Streamable HTTP (default โ€” MCP spec 2025-11-25)

{
  "mcpServers": {
    "universal-mcp-hub": {
      "url": "https://YOUR_USERNAME-universal-mcp-hub.hf.space/mcp"
    }
  }
}

Streamable HTTP โ€” Private Space (with HF token)

{
  "mcpServers": {
    "universal-mcp-hub": {
      "url": "https://YOUR_USERNAME-universal-mcp-hub.hf.space/mcp",
      "headers": {
        "Authorization": "Bearer hf_..."
      }
    }
  }
}

SSE legacy fallback (set HUB_TRANSPORT = "sse" in .pyfun)

{
  "mcpServers": {
    "universal-mcp-hub": {
      "url": "https://YOUR_USERNAME-universal-mcp-hub.hf.space/mcp"
    }
  }
}

Same URL (/mcp) for both transports โ€” the protocol is negotiated automatically. SSE fallback is for older clients that don't support Streamable HTTP yet. (HUB_STATELESS="true" is intentional for HF Spaces โ€” no Mcp-Session-Id header is expected, not a bug.)


A full PySide6 desktop client is included in DESKTOP_CLIENT/hub.py. Communicates via the REST /api endpoint โ€” no MCP protocol overhead. Ideal for private or non-public Spaces.

pip install PySide6 httpx
# optional file handling:
pip install Pillow PyPDF2 pandas openpyxl
python DESKTOP_CLIENT/hub.py

Features:

  • Multi-chat with persistent history

  • Tool / Provider / Model selector loaded live from your Hub

  • File attachments: images, PDF, CSV, Excel, ZIP, source code

  • Connect tab with health check + auto-load

  • Settings: HF Token + Hub URL saved locally, never sent anywhere except your own Hub

  • Full request/response log with timestamps

  • Runs on Windows, Linux, macOS

โ†’ Desktop Client docs - Warning 80 % Vibecode, was so lazy! will fix it soon! But it works!


Client

Interface used

Notes

Desktop Client

REST /api

old PySide6 vibecode, recraft in tkinter selfmade, will be optimzed

WP AI Hub

REST /api

WordPress Boilerplate plugin

TYPO3 (soon)

REST /api

โ€”

Claude Desktop

MCP /mcp

Streamable HTTP

Cursor / Windsurf

MCP /mcp

Streamable HTTP


app/.pyfun is the single source of truth for all app behavior. Three tiers:

LAZY:       [HUB] + one [LLM_PROVIDER.*]                    โ†’ works
NORMAL:     + [SEARCH_PROVIDER.*] + [MODELS.*]              โ†’ works better
PRODUCTIVE: + [TOOLS] + [HUB_LIMITS] + [DB_SYNC]           โ†’ full power

Key settings in [HUB]:

[HUB]
HUB_TRANSPORT   = "streamable-http"   # streamable-http | sse
HUB_STATELESS   = "true"              # true = HF Spaces safe, no session state
HUB_PORT        = "7860"
[HUB_END]

About [MODELS] costs (v1.2.0): auto-pricing fills everything from OpenRouter + LiteLLM. Manual cost_* lines only remain for models no external source can know โ€” my own deployments. If you ever get different conditions than the public lists (custom deals exist), just add cost_* lines for THAT model โ€” .pyfun wins, always. The section also carries requests_per_min/day, context_tokens, capabilities and the provider mapping โ€” none of that exists in any price API.

Adding a new LLM provider โ€” two steps:

# 1. app/.pyfun
[LLM_PROVIDER.mistral]
active        = "true"
base_url      = "https://api.mistral.ai/v1"
env_key       = "MISTRAL_API_KEY"
default_model = "mistral-large-latest"
models        = "mistral-large-latest, mistral-small-latest"
fallback_to   = ""
[LLM_PROVIDER.mistral_END]
# 2. app/providers.py โ€” uncomment the dummy
_PROVIDER_CLASSES = {
    ...
    "mistral": MistralProvider,   # โ† uncomment to activate
}

# PyFundaments Core (always required)
asyncpg          โ€” async PostgreSQL pool (Guardian/cloud DB)
python-dotenv    โ€” .env loading
passlib          โ€” PBKDF2 password hashing in user_handler.py
cryptography     โ€” encryption layer in fundaments/

# MCP Hub
mcp              โ€” MCP protocol + FastMCP (Streamable HTTP + SSE)
httpx            โ€” async HTTP for all provider API calls
quart            โ€” async Flask (ASGI) โ€” needed for MCP + hypercorn
hypercorn        โ€” ASGI server โ€” Streamable HTTP + SSE, HF Spaces native
requests         โ€” sync HTTP for tool workers

# Optional (uncomment in requirements.txt as needed)
# aiofiles         โ€” async file ops (ML pipelines, file uploads)
# discord.py       โ€” Discord bot integration (planned)
# PyNaCl           โ€” Discord signature verification
# psycopg2-binary  โ€” alternative PostgreSQL driver

Note: The package is mcp (not fastmcp) โ€” FastMCP is imported from mcp.server.fastmcp. Streamable HTTP support requires mcp >= 1.6.0.


  • API keys live in HF Secrets / .env โ€” never in .pyfun, never in code

  • list_active_tools returns key names only โ€” never values

  • db_query is SELECT-only, enforced at application level (not just docs)

  • app/* has zero import access to fundaments/ internals

  • Direct execution of app/app.py blocked by design โ€” warning + null-fundaments fallback

  • fundaments/ initialized conditionally โ€” missing services degrade gracefully, never crash

  • Streamable HTTP uses standard Bearer headers โ€” no token-in-URL (unlike SSE)

  • ShellMaster: SECURITY LEVEL ROT โ€” hardblock list (rm -rf, mkfs, โ€ฆ), JSONL command registry, explicit confirmation before every execution, local-only (localhost:5004), token via .env

PyFundaments is not perfect. But it's more secure than most of what runs in production today.

โ†’ Full Security Policy


Built on PyFundaments โ€” a security-first Python boilerplate, crafted by hand over months (see the usernote at the top):

  • config_handler.py โ€” env loading with validation

  • postgresql.py โ€” async DB pool (Guardian-only)

  • encryption.py โ€” key-based encryption layer

  • access_control.py โ€” role/permission management

  • user_handler.py โ€” user lifecycle management

  • security.py โ€” unified security manager composing the above

  • debug.py โ€” conditional startup diagnostics

None accessible from app/*. Injected as a validated dict by main.py.

โ†’ PyFundaments Function Overview โ†’ Module Docs โ†’ Source Repo


Related MCP server: Nervora

haha that's good!

  • 10 months before...

  • some blackouts

  • more blackouts

  • ... month 6 WTF... runs but only stupid secure LLM wrapper and tools...

  • ... pff brick again!

  • ... fuck!

  • ... rewrite

  • fuck Neon DB + MCP changes secure stuff! fuck

  • rewritten

  • AI comes to this project

  • much more blackouts, fuck you ai, want rewrite my stuff! fuck you you are an electron Bitch!

  • GLM checked it, stupid guy! but finds 2 hidden design bugs, no execution but stupid fail!

  • Claude checks again and again and again, my 5 hours limit used in 1.23 min. A record of my self, normally need 2 minutes

  • wtf, fuck you Claude, fuck you Gemini, fuck you GLM, fuck you Kimi, fuck you DeepSeek, all others I do not use

  • fuck! but runs again! I see my first instinct was the best, AI made me crazy!

  • new rewrite with Claude Sonnet, first kick this asshole in his fucking balls 12 times! I get poor bitch!

  • it runs...

  • Fuck yeah, stable fast, secure and against scammers! only for privates!

  • fail architecture for vibecoders!

  • README AI slop from AI with a fucking touch of me!

  • conditional initialization of fundament modules...

  • Fundament modules are ready for the app logic.

  • PostgreSQL bridge activ

  • ShellMaster & Discord API not 100 % finished!

  • Claude best practice bricked tools.py - VolkanSah fix it again! How can Vibecoders release so an trash!

  • some futers.. still crafting


ShellMaster (2023, MIT) was the precursor โ€” browser-accessible shell for ChatGPT with session memory, built before MCP was a concept. Universal AI Hub is its natural evolution: same idea, proper architecture, dual interface. And yes โ€” the ShellMaster idea is back as a tool hook, now with a red security level and a conscience.

Related:


  • Projekt GNU Affero General Public License v3.0 see License + Ethical Security Operations License v2.1 see License โ€” mandatory, non-severable

  • Some scripts i made Apache License 2.0 see License + GNU General Public License v3.0 see License + MIT License see License (only for as for examples, some skills and agents public on MIT or other open source license i use here in this hub for showcases, see files for more infos)

By using this software you agree to all ethical constraints defined in ESOL v2.1.

Architecture, security decisions and 100 % of brocken code ( ok 100 % Running with less than 1 % mistakes) and PyFundaments by me. Built with Claude (Anthropic not claude coder or codex or wtf!) after 20 % own desaster 5 seps bevor relase, played with GLM to see an outher focus but at the end as a typing assistant for docs (and the occasional bug) after i brick my hole work after i made it to complex... so i mean its not ready!

crafted with passion - just wanted to understand how it works, don't actually need it, have a CLI ๐Ÿ˜„

README.md craftet (rewritten) by gemini 3 Pro , snippets from claude and me, terrible,i know! fix later! not important yet cause the code is the showcase!

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A security gateway that enforces policies, tracks data taints, and sandboxes tool calls between AI agents and MCP servers. It provides a secure chokepoint to prevent prompt injection and ensure OWASP ASI compliance through audit logging and deterministic execution.
      14 PyPI
      2
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      A secure MCP gateway for enterprise AI tool execution, enabling governed invocation of business tools with authentication, RBAC, audit logging, PII redaction, and async processing.
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      A security-hardened MCP gateway that enables AI agents to call LLM APIs (Gemini, OpenAI, Claude, etc.) using ephemeral proxy tokens, eliminating exposure of real API keys.
      42 npm
      6
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      A zero-trust gateway for securely brokering interactions between AI models and internal tools via the Model Context Protocol, with DLP, prompt injection defense, and LLM-as-a-Judge.
      -