A Next.js application that provides a natural language interface for database queries through the MCP-DB Connector.
- Natural Language Queries: Enter prompts in plain English to query your database
- Multiple Database Targets: Support for SQLAlchemy and Snowflake databases
- Real-time Results: View query results in a formatted table
- Error Handling: Comprehensive error handling with user-friendly messages
- Modern UI: Built with TailwindCSS for a clean, responsive interface
- Node.js 18+
- npm or pnpm
- MCP-DB Connector server running on
http://localhost:8000
- Install dependencies:
npm install
- Start the development server:
npm run dev
- Open http://localhost:3000 in your browser
Navigate to /db-console
to access the database query interface:
-
Enter a Prompt: Describe what you want to query in natural language
- Example: "Show me all users who registered in the last 30 days"
- Example: "Find the top 10 products by sales"
-
Select Database Target: Choose between:
- SQLAlchemy: For SQLAlchemy-based applications
- Snowflake: For Snowflake data warehouse
-
Execute Query: Click "Execute Query" to run your prompt
-
View Results: Results are displayed in a formatted table with:
- Generated SQL query (if available)
- Query execution time
- Data results in tabular format
Execute a database query using natural language.
Request Body:
{
"prompt": "string",
"target": "sqlalchemy" | "snowflake"
}
Response:
{
"success": true,
"data": [...],
"query": "SELECT ...",
"executionTime": 150
}
Error Response:
{
"success": false,
"error": "Error message"
}
app/
├── api/
│ └── db/
│ └── [query]/
│ └── route.ts # API route for database queries
├── components/
│ └── DbConsole.tsx # Main database console component
├── db-console/
│ └── page.tsx # Database console page
├── types/
│ └── database.ts # TypeScript types for database operations
├── globals.css # Global styles with TailwindCSS
├── layout.tsx # Root layout component
└── page.tsx # Home page
The application expects the MCP-DB Connector server to be running on http://localhost:8000
. Update the URL in /app/api/db/[query]/route.ts
if your MCP server runs on a different port.
The project uses TailwindCSS for styling. Configuration files:
tailwind.config.js
- TailwindCSS configurationpostcss.config.js
- PostCSS configurationapp/globals.css
- Global styles
npm run build
npm start
The project is fully typed with TypeScript. All API responses and component props are properly typed.
The application includes comprehensive error handling:
- Network Errors: When the MCP server is unreachable
- Validation Errors: For missing or invalid request parameters
- Server Errors: When the MCP server returns an error
- Client Errors: For malformed requests
All errors are displayed to the user with clear, actionable messages.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.