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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
---
title: 'Installation Guide'
description: 'Detailed installation instructions for all platforms'
---

## Prerequisites

Before installing MCPHub, ensure you have the following prerequisites:

- **Node.js** 18+ (for local development)
- **Docker** (recommended for production)
- **pnpm** (for local development)

Optional for Smart Routing:

- **PostgreSQL** with pgvector extension
- **OpenAI API Key** or compatible embedding service

## Installation Methods

<Tabs>
  <Tab title="Docker (Recommended)">
    ### Docker Installation

    Docker is the recommended way to deploy MCPHub in production.

    #### 1. Basic Installation

    ```bash
    # Pull the latest image
    docker pull samanhappy/mcphub:latest

    # Run with default settings
    docker run -d \
      --name mcphub \
      -p 3000:3000 \
      samanhappy/mcphub:latest
    ```

    #### 2. With Custom Configuration

    ```bash
    # Create your configuration file
    cat > mcp_settings.json << 'EOF'
    {
      "mcpServers": {
        "fetch": {
          "command": "uvx",
          "args": ["mcp-server-fetch"]
        },
        "playwright": {
          "command": "npx",
          "args": ["@playwright/mcp@latest", "--headless"]
        }
      }
    }
    EOF

    # Run with mounted config
    docker run -d \
      --name mcphub \
      -p 3000:3000 \
      -v $(pwd)/mcp_settings.json:/app/mcp_settings.json \
      samanhappy/mcphub:latest
    ```

    #### 3. With Environment Variables

    ```bash
    docker run -d \
      --name mcphub \
      -p 3000:3000 \
      -e PORT=3000 \
      -e BASE_PATH="" \
      -e REQUEST_TIMEOUT=60000 \
      samanhappy/mcphub:latest
    ```

    #### 4. Docker Compose

    Create a `docker-compose.yml` file:

    ```yaml
    version: '3.8'
    services:
      mcphub:
        image: samanhappy/mcphub:latest
        ports:
          - "3000:3000"
        volumes:
          - ./mcp_settings.json:/app/mcp_settings.json
        environment:
          - PORT=3000
          - BASE_PATH=""
          - REQUEST_TIMEOUT=60000
        restart: unless-stopped

      # Optional: PostgreSQL for Smart Routing
      postgres:
        image: pgvector/pgvector:pg16
        environment:
          POSTGRES_DB: mcphub
          POSTGRES_USER: mcphub
          POSTGRES_PASSWORD: mcphub_password
        volumes:
          - postgres_data:/var/lib/postgresql/data
        ports:
          - "5432:5432"

    volumes:
      postgres_data:
    ```

    Run with:
    ```bash
    docker-compose up -d
    ```

  </Tab>

  <Tab title="npm Package">
    ### npm Package Installation

    Install MCPHub as a global npm package:

    #### 1. Global Installation

    ```bash
    # Install globally
    npm install -g @samanhappy/mcphub

    # Or with yarn
    yarn global add @samanhappy/mcphub

    # Or with pnpm
    pnpm add -g @samanhappy/mcphub
    ```

    #### 2. Running MCPHub

    ```bash
    # Run with default settings
    mcphub

    # Run with custom port
    PORT=8080 mcphub

    # Run with custom config path
    MCP_SETTINGS_PATH=/path/to/mcp_settings.json mcphub
    ```

    #### 3. Local Installation

    You can also install MCPHub locally in a project:

    ```bash
    # Create a new directory
    mkdir my-mcphub
    cd my-mcphub

    # Initialize package.json
    npm init -y

    # Install MCPHub locally
    npm install @samanhappy/mcphub

    # Create a start script
    echo '#!/bin/bash\nnpx mcphub' > start.sh
    chmod +x start.sh

    # Run MCPHub
    ./start.sh
    ```

  </Tab>

  <Tab title="Local Development">
    ### Local Development Setup

    For development, customization, or contribution:

    #### 1. Clone Repository

    ```bash
    # Clone the repository
    git clone https://github.com/samanhappy/mcphub.git
    cd mcphub
    ```

    #### 2. Install Dependencies

    ```bash
    # Install dependencies with pnpm (recommended)
    pnpm install

    # Or with npm
    npm install

    # Or with yarn
    yarn install
    ```

    #### 3. Development Mode

    ```bash
    # Start both backend and frontend in development mode
    pnpm dev

    # This will start:
    # - Backend on http://localhost:3001
    # - Frontend on http://localhost:5173
    # - Frontend proxies API calls to backend
    ```

    #### 4. Build for Production

    ```bash
    # Build both backend and frontend
    pnpm build

    # Start production server
    pnpm start
    ```

    #### 5. Development Scripts

    ```bash
    # Backend only (for API development)
    pnpm backend:dev

    # Frontend only (when backend is running separately)
    pnpm frontend:dev

    # Run tests
    pnpm test

    # Lint code
    pnpm lint

    # Format code
    pnpm format
    ```

    <Note>
      On Windows, you may need to run backend and frontend separately:
      ```bash
      # Terminal 1: Backend
      pnpm backend:dev

      # Terminal 2: Frontend
      pnpm frontend:dev
      ```
    </Note>

  </Tab>

  <Tab title="Kubernetes">
    ### Kubernetes Deployment

    Deploy MCPHub on Kubernetes with these manifests:

    #### 1. ConfigMap for Settings

    ```yaml
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: mcphub-config
    data:
      mcp_settings.json: |
        {
          "mcpServers": {
            "fetch": {
              "command": "uvx",
              "args": ["mcp-server-fetch"]
            },
            "playwright": {
              "command": "npx",
              "args": ["@playwright/mcp@latest", "--headless"]
            }
          }
        }
    ```

    #### 2. Deployment

    ```yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mcphub
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mcphub
      template:
        metadata:
          labels:
            app: mcphub
        spec:
          containers:
          - name: mcphub
            image: samanhappy/mcphub:latest
            ports:
            - containerPort: 3000
            env:
            - name: PORT
              value: "3000"
            volumeMounts:
            - name: config
              mountPath: /app/mcp_settings.json
              subPath: mcp_settings.json
          volumes:
          - name: config
            configMap:
              name: mcphub-config
    ```

    #### 3. Service

    ```yaml
    apiVersion: v1
    kind: Service
    metadata:
      name: mcphub-service
    spec:
      selector:
        app: mcphub
      ports:
      - port: 80
        targetPort: 3000
      type: ClusterIP
    ```

    #### 4. Ingress (Optional)

    ```yaml
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: mcphub-ingress
      annotations:
        nginx.ingress.kubernetes.io/proxy-buffering: "off"
    spec:
      rules:
      - host: mcphub.yourdomain.com
        http:
          paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: mcphub-service
                port:
                  number: 80
    ```

    Deploy with:
    ```bash
    kubectl apply -f mcphub-configmap.yaml
    kubectl apply -f mcphub-deployment.yaml
    kubectl apply -f mcphub-service.yaml
    kubectl apply -f mcphub-ingress.yaml
    ```

  </Tab>
</Tabs>

## Smart Routing Setup (Optional)

Smart Routing provides AI-powered tool discovery using vector semantic search.

### Prerequisites

1. **PostgreSQL with pgvector**
2. **OpenAI API Key** (or compatible embedding service)

### Database Setup

<Tabs>
  <Tab title="Docker PostgreSQL">
    ```bash
    # Run PostgreSQL with pgvector
    docker run -d \
      --name mcphub-postgres \
      -e POSTGRES_DB=mcphub \
      -e POSTGRES_USER=mcphub \
      -e POSTGRES_PASSWORD=your_password \
      -p 5432:5432 \
      pgvector/pgvector:pg16
    ```
  </Tab>

  <Tab title="Existing PostgreSQL">
    If you have an existing PostgreSQL instance:

    ```sql
    -- Connect to your PostgreSQL instance
    -- Create database
    CREATE DATABASE mcphub;

    -- Connect to the mcphub database
    \c mcphub;

    -- Enable pgvector extension
    CREATE EXTENSION IF NOT EXISTS vector;
    ```

  </Tab>

  <Tab title="Cloud PostgreSQL">
    For cloud providers (AWS RDS, Google Cloud SQL, etc.):

    1. Enable the pgvector extension in your cloud provider's console
    2. Create a database named `mcphub`
    3. Note down the connection details

  </Tab>
</Tabs>

### Environment Configuration

Set the following environment variables:

```bash
# Database connection
DATABASE_URL=postgresql://mcphub:your_password@localhost:5432/mcphub

# OpenAI API for embeddings
OPENAI_API_KEY=your_openai_api_key

# Optional: Custom embedding model
EMBEDDING_MODEL=text-embedding-3-small

# Optional: Enable smart routing
ENABLE_SMART_ROUTING=true
```

## Verification

After installation, verify MCPHub is working:

### 1. Health Check

```bash
curl http://localhost:3000/api/health
```

Expected response:

```json
{
  "status": "ok",
  "version": "x.x.x",
  "uptime": 123
}
```

### 2. Dashboard Access

Open your browser and navigate to:

```
http://localhost:3000
```

### 3. API Test

```bash
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list",
    "params": {}
  }'
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Docker Issues">
    **Port already in use:**
    ```bash
    # Check what's using port 3000
    lsof -i :3000

    # Use a different port
    docker run -p 8080:3000 samanhappy/mcphub
    ```

    **Container won't start:**
    ```bash
    # Check container logs
    docker logs mcphub

    # Run interactively for debugging
    docker run -it --rm samanhappy/mcphub /bin/bash
    ```

  </Accordion>

  <Accordion title="npm Installation Issues">
    **Permission errors:**
    ```bash
    # Use npx instead of global install
    npx @samanhappy/mcphub

    # Or fix npm permissions
    npm config set prefix ~/.npm-global
    export PATH=~/.npm-global/bin:$PATH
    ```

    **Node version issues:**
    ```bash
    # Check Node version
    node --version

    # Install Node 18+ using nvm
    nvm install 18
    nvm use 18
    ```

  </Accordion>

  <Accordion title="Network Issues">
    **Can't access dashboard:**
    - Check if MCPHub is running: `ps aux | grep mcphub`
    - Verify port binding: `netstat -tlnp | grep 3000`
    - Check firewall settings
    - Try accessing via `127.0.0.1:3000` instead of `localhost:3000`

    **AI clients can't connect:**
    - Ensure the endpoint URL is correct
    - Check if MCPHub is behind a proxy
    - Verify network policies in Kubernetes/Docker environments

  </Accordion>

  <Accordion title="Smart Routing Issues">
    **Database connection failed:**
    ```bash
    # Test database connection
    psql $DATABASE_URL -c "SELECT 1;"

    # Check if pgvector is installed
    psql $DATABASE_URL -c "CREATE EXTENSION IF NOT EXISTS vector;"
    ```

    **Embedding service errors:**
    - Verify OpenAI API key is valid
    - Check internet connectivity
    - Monitor rate limits

  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Configuration" icon="cog" href="/configuration/mcp-settings">
    Configure your MCP servers and settings
  </Card>
  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Get up and running in 5 minutes
  </Card>
  <Card title="Server Management" icon="server" href="/features/server-management">
    Learn how to manage your MCP servers
  </Card>
  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore the complete API documentation
  </Card>
</CardGroup>