This is a small implementation of MCP Client in Django. The MCP Server is currently hard coded with the Django client application.
- The MCP client sends 2 things to OpenAI via API call:
- The user prompt received from the Django app
- The list of available MCP Tools
- The OpenAI LLM reads the user prompts and evaluates if any tool from the received list of tools can be utilized
- If the LLM decides to use a tool, it fetches the Python arguments from the user prompt and feeds them to the tool, the tool is then called on the MCP Server side
Note: a tool is a Python function with a mcp.tool decorator.
Run the django server
python manage.py runserverA chat application that allows you to interact with an AI assistant using natural language. The assistant can help you with various tasks, including writing and executing code, analyzing data, and answering questions.
- Natural language interaction with AI
- Code execution and visualization
- Markdown support with syntax highlighting
- Interactive data visualization
- Tool selection and management
- Real-time response streaming
- Python 3.8 or higher
- Node.js 16 or higher
uvpackage manager (recommended for faster dependency installation)
- Clone the repository:
git clone <repository-url>
cd chatapp- Configs and Virtual Env:
Update the configs:
SQLITE_PATHinsidechatapp/chatapp/mcp/sql.py- All other configs in
chatapp/config.py
Create Environment Variables:
OPENAI_KEYstoring the API Key of Open AI
Create a Python virtual environment and install all Python dependencies:
cd chatapp
uv syncActivate the Python virtual environment:
.venv\Scripts\activate- Install Node.js dependencies:
npm install- Start the Django server:
python manage.py runserver-
Open your browser and navigate to
http://localhost:8000 -
You can now:
- Chat with an AI assistant -> use the Notebook app
- Develop SQL queries with an AI assistant (very rough state) -> use the model app
The application uses Tailwind CSS for styling. To compile the CSS:
- Start the Tailwind CSS build process:
npm run buildThis will:
- Watch your HTML files for changes
- Compile the CSS from
static/css/input.csstostatic/css/output.css - Automatically rebuild when you make changes
The build process will continue running until you stop it (Ctrl+C). You can leave it running while developing.
chatapp/
├── chatapp/
│ ├── __init__.py
│ ├── app.py
│ ├── config.py
│ ├── mcp/
│ │ ├── __init__.py
│ │ └── client.py
│ ├── static/
│ │ ├── css/
│ │ │ ├── input.css
│ │ │ └── output.css
│ │ └── js/
│ │ └── main.js
│ └── templates/
│ ├── index.html
│ ├── input_cell.html
│ ├── output_cell.html
│ └── sidebar.html
├── pyproject.toml
├── package.json
└── tailwind.config.js




