loading…
Search for a command to run...
loading…
A FastAPI-based server that enables executing SQL queries, managing database connections, and retrieving analytics reports through MCP-integrated endpoints. It
A FastAPI-based server that enables executing SQL queries, managing database connections, and retrieving analytics reports through MCP-integrated endpoints. It allows users to interact with database schemas, performance metrics, and access logs using structured queries.
app/main.py: FastAPI app initialization and router registrationapp/core: config and security helpersapp/db: DB engine/session and initapp/models: SQLAlchemy ORM modelsapp/schemas: Pydantic request/response schemasapp/api/routes: endpoint routesapp/services: business logic servicesapp/mcp: MCP integration stubsalembic: migration configurationInstall dependencies:
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
Open docs at http://localhost:8000/docs.
POST /api/auth/register: create userPOST /api/auth/token: login and retrieve JWTGET /api/auth/me: get current userPOST /api/connections/test: validate DB connectionPOST /api/connections: save connection (admin only)POST /api/queries/execute: execute SQL queryGET /api/reports/users/total: return user totalGET /api/reports/access-logsGET /api/reports/objects/summaryGET /api/metrics/performanceGET /api/metrics/top-objectsGET /api/metrics/frequencyPOST /api/mcp/run-queryGET /api/mcp/schemacurl -X POST "http://localhost:8000/api/auth/register" -H "Content-Type: application/json" -d '{"username":"admin","email":"[email protected]","password":"password","role":"admin"}'
curl -X POST "http://localhost:8000/api/auth/token" -H "Content-Type: application/x-www-form-urlencoded" -d "username=admin&password=password"
curl -H "Authorization: Bearer <TOKEN>" "http://localhost:8000/api/reports/users/total"
Successful registration returns:
HTTP/1.1 200 OK
{
"id": 1,
"username": "admin",
"email": "[email protected]",
"role": "admin",
"is_active": true,
"created_at": "2026-03-25T12:34:56.789000"
}
If the user exists:
HTTP/1.1 400 Bad Request
{
"detail": "User already exists"
}
alembic revision --autogenerate -m "init"
alembic upgrade head
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"db-analytics-query-platform": {
"command": "npx",
"args": []
}
}
}