MCP_Agent_CRUD_Operation
An intelligent conversational database management system that enables natural language interactions with MySQL databases using OpenAI's GPT-4 Turbo and Model Context Protocol (MCP).
GitHub Stars
0
User Rating
Not Rated
Favorites
0
Views
18
Forks
0
Issues
0
README
MCP_Agent_CRUD_Operation
An intelligent conversational database management system that enables natural language interactions with MySQL databases using OpenAI's GPT-4 Turbo and Model Context Protocol (MCP).
Features
- Natural language interface for MySQL database operations
- Uses OpenAI GPT-4 Turbo for intelligent query understanding
- Secure execution of SQL queries
- Easily extensible with custom MCP tools
- Connection testing utility
Requirements
- Python 3.8+
- MySQL server
- OpenAI API key (for GPT-4 Turbo)
- pip packages:
mysql-connector-python,loguru,mcp(and dependencies)
Installation
Clone the repository:
git clone https://github.com/yourusername/MCP_Agent_CRUD_Operation.git cd MCP_Agent_CRUD_OperationInstall dependencies:
pip install mysql-connector-python loguru mcpConfigure MySQL:
- Ensure a MySQL server is running.
- Create a database named
ai_agent(or update the code to use your database). - Update the credentials in
mcp_server.pyif needed.
Usage
Start the MCP server:
python mcp_server.pyTest MySQL connection:
- The server will automatically test the connection on startup.
Interact with the server:
- Use the MCP protocol (e.g., via compatible clients or tools) to send natural language queries or SQL commands.
Example
from mcp.client import MCPClient
client = MCPClient("Demo")
response = client.query_data("SELECT * FROM your_table;")
print(response)
Customization
- Add new tools by decorating Python functions with
@mcp.tool(). - Modify database credentials in
mcp_server.pyas needed.
Security
- Only trusted users should have access to the server.
- Validate or sanitize SQL queries as needed for your use case.
License
MIT License