File size: 6,970 Bytes
46bc2e2
 
 
 
 
 
 
 
 
 
 
02805c2
be5ee6d
 
 
 
 
 
 
 
02805c2
be5ee6d
 
 
 
02805c2
be5ee6d
02805c2
 
 
be5ee6d
02805c2
be5ee6d
 
 
02805c2
be5ee6d
02805c2
be5ee6d
02805c2
 
 
be5ee6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02805c2
be5ee6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02805c2
be5ee6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02805c2
be5ee6d
02805c2
be5ee6d
 
 
 
 
 
 
 
 
 
 
 
02805c2
 
 
be5ee6d
02805c2
be5ee6d
 
 
 
 
 
 
 
 
 
02805c2
 
 
 
 
be5ee6d
 
 
 
 
 
 
 
 
 
02805c2
be5ee6d
02805c2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
---
title: Universal MCP Hub
emoji: πŸ‘€
colorFrom: indigo
colorTo: red
sdk: docker
pinned: false
license: apache-2.0
short_description: 'Universal MCP Server(Sandboxed) built on PyFundaments '
---

# Universal MCP Hub (Sandboxed)
The only real (MCP) HUB you need!

> running on simpleCity and **paranoidMode** β€” built on [PyFundaments](PyFundaments.md).

... because too many (Hype) MCP servers exist with no sandboxing, hardcoded keys, and zero security thought. 


#### This one is different.

- **No key β†’ no tool β†’ no crash**
- `main.py` = Guardian (controls everything, nothing bypasses it)
- `app/app.py` receives only injected, validated services β€” never reads `os.environ` directly
- Every tool is registered dynamically β€” only if the API key exists

> *"I use AI as a tool, not as a replacement for thinking."* β€” Volkan KΓΌcΓΌkbudak

---

## Quick Start

1. **Fork/Clone** this Repo (Space)
2. Add your API keys as **Space Secrets** (Settings β†’ Variables and secrets)
3. Space starts automatically β€” only tools with valid keys are registered

That's it. No config files to edit, no code to touch.

[Demo for `cloning space`](https://huggingface.co/spaces/codey-lab/Universal-MCP-Hub-DEMO) on HF

---

## Available Tools

Tools are registered automatically based on which keys you configure. No key = tool doesn't exist. No crashes, no errors, no exposed secrets.

| Secret | Tool | Description |
| :--- | :--- | :--- |
| `ANTHROPIC_API_KEY` | `llm_complete` | Claude Haiku / Sonnet / Opus |
| `GEMINI_API_KEY` | `llm_complete` | Gemini Flash / Pro |
| `OPENROUTER_API_KEY` | `llm_complete` | 100+ models via OpenRouter |
| `HF_TOKEN` | `llm_complete` | HuggingFace Inference API |
| `BRAVE_API_KEY` | `web_search` | Web Search (independent index) |
| `TAVILY_API_KEY` | `web_search` | AI-optimized Search |
| `DATABASE_URL` | `db_query` | Read-only DB access (SELECT only) |
| *(always active)* | `list_active_tools` | Lists all currently active tools |
| *(always active)* | `health_check` | System health + uptime |

All LLM providers share a single `llm_complete` tool with automatic **fallback chain**: `anthropic β†’ gemini β†’ openrouter β†’ huggingface`

---

## MCP Client Configuration (SSE)

Connect Claude Desktop or any MCP-compatible client:

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

For private Spaces, add your HF token:

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

---

## Desktop Client
#### Perfect for non-public spaces


- A standalone PySide6 desktop client is included: `hub.py`, with help of ClaudeAi, was to lazy πŸ˜„
- Features: Chat tab, Tools inspector, Settings (provider/model override, font size), Logs β€” all saved locally in `~/.mcp_desktop.json`. Token never leaves your machine except to your own Hub.
- more about the [Desktop Client](DESKTOP_CLIENT/README.md)

---

## Architecture
```
UMH
β”œβ”€β”€ main.py # run main!
β”œβ”€β”€ README.md
β”œβ”€β”€ ESOL
β”œβ”€β”€ LICENSE
β”œβ”€β”€ PyFundaments.md
β”œβ”€β”€ PyFundaments – Function Overview.md
β”œβ”€β”€ SECURITY.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .gitignore
β”œβ”€β”€ example.Dockerfile
β”œβ”€β”€ example-mcp___.env
β”œβ”€β”€ DESKTOP_CLIENT
β”‚   └── hub.py        ← light MCP Desktop client
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ app.py        ←  sandboxed Orchestrator
β”‚   β”œβ”€β”€ mcp.py        ← MCP SSE server (FastMCP + Quart)
β”‚   β”œβ”€β”€ tools.py      ← Tool registry (from .pyfun)
β”‚   β”œβ”€β”€ provider.py   ← LLM + Search execution + fallback
β”‚   β”œβ”€β”€ models.py     ← Model limits + costs
β”‚   β”œβ”€β”€ db_sync.py    ← Internal SQLite state (IPC)
β”‚   β”œβ”€β”€ config.py     ← .pyfun parser (single source of truth)
β”‚   └── .pyfun        ←  single source of truth
β”œβ”€β”€ fundaments/ # do not touch!
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ access_control.py
β”‚   β”œβ”€β”€ config_handler.py
β”‚   β”œβ”€β”€ encryption.py
β”‚   β”œβ”€β”€ postgresql.py
β”‚   β”œβ”€β”€ security.py
β”‚   └── user_handler.py
└── docs/
    β”œβ”€β”€ access_control.py.md
    β”œβ”€β”€ encryption.py.md
    β”œβ”€β”€ postgresql.py.md
    β”œβ”€β”€ security.py.md
    └── user_handler.py.md



```

**The Guardian pattern:** `app/*` never touches `os.environ`, `.env`, or `fundaments/` directly. Everything is injected by `main.py` as a validated `fundaments` dict. The sandbox is structural β€” not optional.

---

## Configuration (.pyfun)

All app behavior is configured via `app/.pyfun` β€” a structured, human-readable config format:

```ini
[LLM_PROVIDER.anthropic]
active           = "true"
env_key          = "ANTHROPIC_API_KEY"
default_model    = "claude-haiku-4-5-20251001"
fallback_to      = "gemini"
[LLM_PROVIDER.anthropic_END]

[TOOL.llm_complete]
active           = "true"
provider_type    = "llm"
default_provider = "anthropic"
timeout_sec      = "60"
[TOOL.llm_complete_END]
```

Add a new tool/Provider/API_URL or something else just = edit `.pyfun` only. No code changes required.

---

## Security Design

- All API keys via e.g. HF Space Secrets β€” never hardcoded, never in `.pyfun`
- `list_active_tools` returns key **names** only, never values
- DB tools are `SELECT`-only, enforced at application level
- Direct execution of `app/*` is blocked by design
- `app/*` has zero access to `fundaments/` internals
- Built on [PyFundaments](PyFundaments.md) β€” security-first Python architecture

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

---

## Foundation

- [PyFundaments](PyFundaments.md) β€” Security-first Python boilerplate
- [PyFundaments Function Overview](Fundaments-–-Function---Overview.md)
- [PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md)
- [SECURITY.md](SECURITY.md)

---

## History

[ShellMaster](https://github.com/VolkanSah/ChatGPT-ShellMaster) (2023, archived, MIT) was the precursor β€” a browser-accessible shell for ChatGPT with session memory via `/tmp/shellmaster_brain.log`, built before MCP was a word. Universal MCP Hub is its natural evolution.

---

## License

Dual-licensed:

- [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)
- [Ethical Security Operations License v1.1 (ESOL)](ESOL) β€” mandatory, non-severable

By using this software you agree to all ethical constraints defined in ESOL v1.1. Misuse may result in automatic license termination and legal liability.

---

*Architecture, security decisions, and PyFundaments by Volkan KΓΌcΓΌkbudak. Built with Claude (Anthropic) as a typing assistant for docs & some bugs*

> crafted with passion by {Volkan KΓΌcΓΌkbudak](https://github.com/volkansah/) - just want to feel how it works, mean i do not need it, have cli πŸ˜„