mirror of
https://github.com/samanhappy/mcphub.git
synced 2026-01-02 04:39:23 -05:00
fix: rename DATABASE_URL to DB_URL for consistency across configurations (#545)
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -106,7 +106,7 @@ jobs:
|
||||
|
||||
# - name: Run integration tests
|
||||
# run: |
|
||||
# export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mcphub_test"
|
||||
# export DB_URL="postgresql://postgres:postgres@localhost:5432/mcphub_test"
|
||||
# node test-integration.ts
|
||||
# env:
|
||||
# NODE_ENV: test
|
||||
|
||||
@@ -106,7 +106,7 @@ services:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
- JWT_SECRET=${JWT_SECRET:-your-jwt-secret}
|
||||
- DATABASE_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
- DB_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
volumes:
|
||||
- ./mcp_settings.json:/app/mcp_settings.json:ro
|
||||
- ./servers.json:/app/servers.json:ro
|
||||
@@ -180,7 +180,7 @@ services:
|
||||
- PORT=3000
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-24h}
|
||||
- DATABASE_URL=postgresql://mcphub:${POSTGRES_PASSWORD}@postgres:5432/mcphub
|
||||
- DB_URL=postgresql://mcphub:${POSTGRES_PASSWORD}@postgres:5432/mcphub
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- REDIS_URL=redis://redis:6379
|
||||
volumes:
|
||||
@@ -293,7 +293,7 @@ services:
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- PORT=3000
|
||||
- DATABASE_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
- DB_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
volumes:
|
||||
- .:/app
|
||||
- /app/node_modules
|
||||
|
||||
@@ -47,7 +47,7 @@ PORT=3000
|
||||
NODE_ENV=development
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL=postgresql://username:password@localhost:5432/mcphub
|
||||
DB_URL=postgresql://username:password@localhost:5432/mcphub
|
||||
|
||||
# JWT Configuration
|
||||
JWT_SECRET=your-secret-key
|
||||
|
||||
@@ -69,7 +69,7 @@ Smart Routing requires additional setup compared to basic MCPHub usage:
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
- DB_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
- OPENAI_API_KEY=your_openai_api_key
|
||||
- ENABLE_SMART_ROUTING=true
|
||||
depends_on:
|
||||
@@ -114,7 +114,7 @@ Smart Routing requires additional setup compared to basic MCPHub usage:
|
||||
|
||||
2. **Set Environment Variables**:
|
||||
```bash
|
||||
export DATABASE_URL="postgresql://mcphub:your_password@localhost:5432/mcphub"
|
||||
export DB_URL="postgresql://mcphub:your_password@localhost:5432/mcphub"
|
||||
export OPENAI_API_KEY="your_openai_api_key"
|
||||
export ENABLE_SMART_ROUTING="true"
|
||||
```
|
||||
@@ -178,7 +178,7 @@ Smart Routing requires additional setup compared to basic MCPHub usage:
|
||||
- name: mcphub
|
||||
image: samanhappy/mcphub:latest
|
||||
env:
|
||||
- name: DATABASE_URL
|
||||
- name: DB_URL
|
||||
value: "postgresql://mcphub:password@postgres:5432/mcphub"
|
||||
- name: OPENAI_API_KEY
|
||||
valueFrom:
|
||||
@@ -202,7 +202,7 @@ Configure Smart Routing with these environment variables:
|
||||
|
||||
```bash
|
||||
# Required
|
||||
DATABASE_URL=postgresql://user:password@host:5432/database
|
||||
DB_URL=postgresql://user:password@host:5432/database
|
||||
OPENAI_API_KEY=your_openai_api_key
|
||||
|
||||
# Optional
|
||||
@@ -219,10 +219,10 @@ EMBEDDING_BATCH_SIZE=100
|
||||
<Accordion title="Database Configuration">
|
||||
```bash
|
||||
# Full PostgreSQL connection string
|
||||
DATABASE_URL=postgresql://username:password@host:port/database?schema=public
|
||||
DB_URL=postgresql://username:password@host:port/database?schema=public
|
||||
|
||||
# SSL configuration for cloud databases
|
||||
DATABASE_URL=postgresql://user:pass@host:5432/db?sslmode=require
|
||||
DB_URL=postgresql://user:pass@host:5432/db?sslmode=require
|
||||
|
||||
# Connection pool settings
|
||||
DATABASE_POOL_SIZE=20
|
||||
@@ -673,11 +673,11 @@ curl -X POST http://localhost:3000/api/smart-routing/feedback \
|
||||
|
||||
**Solutions:**
|
||||
1. Verify PostgreSQL is running
|
||||
2. Check DATABASE_URL format
|
||||
2. Check DB_URL format
|
||||
3. Ensure pgvector extension is installed
|
||||
4. Test connection manually:
|
||||
```bash
|
||||
psql $DATABASE_URL -c "SELECT 1;"
|
||||
psql $DB_URL -c "SELECT 1;"
|
||||
```
|
||||
|
||||
</Accordion>
|
||||
|
||||
@@ -445,7 +445,7 @@ Set the following environment variables:
|
||||
|
||||
```bash
|
||||
# Database connection
|
||||
DATABASE_URL=postgresql://mcphub:your_password@localhost:5432/mcphub
|
||||
DB_URL=postgresql://mcphub:your_password@localhost:5432/mcphub
|
||||
|
||||
# OpenAI API for embeddings
|
||||
OPENAI_API_KEY=your_openai_api_key
|
||||
@@ -563,10 +563,10 @@ curl -X POST http://localhost:3000/mcp \
|
||||
**Database connection failed:**
|
||||
```bash
|
||||
# Test database connection
|
||||
psql $DATABASE_URL -c "SELECT 1;"
|
||||
psql $DB_URL -c "SELECT 1;"
|
||||
|
||||
# Check if pgvector is installed
|
||||
psql $DATABASE_URL -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
||||
psql $DB_URL -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
||||
```
|
||||
|
||||
**Embedding service errors:**
|
||||
|
||||
@@ -106,7 +106,7 @@ services:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
- JWT_SECRET=${JWT_SECRET:-your-jwt-secret}
|
||||
- DATABASE_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
- DB_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
volumes:
|
||||
- ./mcp_settings.json:/app/mcp_settings.json:ro
|
||||
- ./servers.json:/app/servers.json:ro
|
||||
@@ -180,7 +180,7 @@ services:
|
||||
- PORT=3000
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-24h}
|
||||
- DATABASE_URL=postgresql://mcphub:${POSTGRES_PASSWORD}@postgres:5432/mcphub
|
||||
- DB_URL=postgresql://mcphub:${POSTGRES_PASSWORD}@postgres:5432/mcphub
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- REDIS_URL=redis://redis:6379
|
||||
volumes:
|
||||
@@ -293,7 +293,7 @@ services:
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- PORT=3000
|
||||
- DATABASE_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
- DB_URL=postgresql://mcphub:password@postgres:5432/mcphub
|
||||
volumes:
|
||||
- .:/app
|
||||
- /app/node_modules
|
||||
|
||||
@@ -290,7 +290,7 @@ MCPHub 支持使用 `${VAR_NAME}` 语法进行环境变量替换:
|
||||
"command": "python",
|
||||
"args": ["-m", "db_server"],
|
||||
"env": {
|
||||
"DB_URL": "${NODE_ENV:development == 'production' ? DATABASE_URL : DEV_DATABASE_URL}"
|
||||
"DB_URL": "${NODE_ENV:development == 'production' ? DB_URL : DEV_DB_URL}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ PORT=3000
|
||||
NODE_ENV=development
|
||||
|
||||
# 数据库配置
|
||||
DATABASE_URL=postgresql://username:password@localhost:5432/mcphub
|
||||
DB_URL=postgresql://username:password@localhost:5432/mcphub
|
||||
|
||||
# JWT 配置
|
||||
JWT_SECRET=your-secret-key
|
||||
|
||||
@@ -480,7 +480,7 @@ docker run -d \
|
||||
--name mcphub \
|
||||
-p 3000:3000 \
|
||||
-e NODE_ENV=production \
|
||||
-e DATABASE_URL=postgresql://user:pass@host:5432/mcphub \
|
||||
-e DB_URL=postgresql://user:pass@host:5432/mcphub \
|
||||
-e JWT_SECRET=your-secret-key \
|
||||
mcphub/server:latest
|
||||
|
||||
@@ -504,7 +504,7 @@ docker run -d \
|
||||
--name mcphub \
|
||||
-p 3000:3000 \
|
||||
-e NODE_ENV=production \
|
||||
-e DATABASE_URL=postgresql://user:pass@host:5432/mcphub \
|
||||
-e DB_URL=postgresql://user:pass@host:5432/mcphub \
|
||||
-e JWT_SECRET=your-secret-key \
|
||||
mcphub/server:latest
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ services:
|
||||
- '3000:3000'
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DATABASE_URL=postgresql://user:pass@db:5432/mcphub
|
||||
- DB_URL=postgresql://user:pass@db:5432/mcphub
|
||||
```
|
||||
````
|
||||
|
||||
@@ -172,7 +172,7 @@ services:
|
||||
- '3000:3000'
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DATABASE_URL=postgresql://user:pass@db:5432/mcphub
|
||||
- DB_URL=postgresql://user:pass@db:5432/mcphub
|
||||
```
|
||||
|
||||
### 终端命令
|
||||
|
||||
@@ -245,11 +245,11 @@ curl -X POST http://localhost:3000/api/smart-routing/feedback \
|
||||
|
||||
**解决方案:**
|
||||
1. 验证 PostgreSQL 是否正在运行
|
||||
2. 检查 DATABASE_URL 格式
|
||||
2. 检查 DB_URL 格式
|
||||
3. 确保安装了 pgvector 扩展
|
||||
4. 手动测试连接:
|
||||
```bash
|
||||
psql $DATABASE_URL -c "SELECT 1;"
|
||||
psql $DB_URL -c "SELECT 1;"
|
||||
```
|
||||
|
||||
</Accordion>
|
||||
|
||||
@@ -420,7 +420,7 @@ description: '各种平台的详细安装说明'
|
||||
|
||||
```bash
|
||||
# 数据库连接
|
||||
DATABASE_URL=postgresql://mcphub:your_password@localhost:5432/mcphub
|
||||
DB_URL=postgresql://mcphub:your_password@localhost:5432/mcphub
|
||||
|
||||
# 用于嵌入的 OpenAI API
|
||||
OPENAI_API_KEY=your_openai_api_key
|
||||
@@ -538,10 +538,10 @@ curl -X POST http://localhost:3000/mcp \
|
||||
**数据库连接失败:**
|
||||
```bash
|
||||
# 测试数据库连接
|
||||
psql $DATABASE_URL -c "SELECT 1;"
|
||||
psql $DB_URL -c "SELECT 1;"
|
||||
|
||||
# 检查是否安装了 pgvector
|
||||
psql $DATABASE_URL -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
||||
psql $DB_URL -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
||||
```
|
||||
|
||||
**嵌入服务错误:**
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"env": {
|
||||
"API_KEY": "${MY_API_KEY}",
|
||||
"DEBUG": "${DEBUG_MODE}",
|
||||
"DATABASE_URL": "${DATABASE_URL}"
|
||||
"DB_URL": "${DB_URL}"
|
||||
}
|
||||
},
|
||||
"example-stdio-with-proxy": {
|
||||
@@ -96,7 +96,10 @@
|
||||
"clientId": "${OAUTH_CLIENT_ID}",
|
||||
"clientSecret": "${OAUTH_CLIENT_SECRET}",
|
||||
"accessToken": "${OAUTH_ACCESS_TOKEN}",
|
||||
"scopes": ["read", "write"]
|
||||
"scopes": [
|
||||
"read",
|
||||
"write"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -118,4 +121,4 @@
|
||||
"baseUrl": "${MCPROUTER_BASE_URL}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ export interface SmartRoutingConfig {
|
||||
*
|
||||
* Priority order for each setting:
|
||||
* 1. Specific environment variables (ENABLE_SMART_ROUTING, SMART_ROUTING_ENABLED, etc.)
|
||||
* 2. Generic environment variables (OPENAI_API_KEY, DATABASE_URL, etc.)
|
||||
* 2. Generic environment variables (OPENAI_API_KEY, DB_URL, etc.)
|
||||
* 3. Settings configuration (systemConfig.smartRouting)
|
||||
* 4. Default values
|
||||
*
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'reflect-metadata';
|
||||
Object.assign(process.env, {
|
||||
NODE_ENV: 'test',
|
||||
JWT_SECRET: 'test-jwt-secret-key',
|
||||
DATABASE_URL: 'sqlite::memory:',
|
||||
DB_URL: 'sqlite::memory:',
|
||||
});
|
||||
|
||||
// Mock moduleDir to avoid import.meta parsing issues in Jest
|
||||
@@ -40,7 +40,7 @@ expect.extend({
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
toBeValidUUID(received: any) {
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
const pass = typeof received === 'string' && uuidRegex.test(received);
|
||||
|
||||
Reference in New Issue
Block a user