Running mcp servers closer what enterprises doe
-
Organizations run mcp servers in 3 ways
- on virtual machines
- inside containers on a dedicated servers
- cloud hosted
-
We will be using containerized option
-
Step 1: Lets run mysql in a docker container
-
Step 2: To view the data in mysql we have multiple ways
-
IN the the following code i have create a docker compose file with
- mysql
- phpmyadmin
- Mysql runs on 3306 on localhost and phpmyadmin on 18080
# to bring up
docker compose up -d
# to bring down
docker compose down
# to bring down and wipe database contents
docker compose down -v
-
Refer Here for the changeset
-
To get my changes
# create some folder cd into it
git clone https://github.com/GenAIDevelopment/agenticai.git
cd agenticai/may26/mcp/library-mcp
uv sync
code .
- Small research
Explore the idea of how to create a record in mysql table from python
* SQL statement
* ORM Frameworks
- Now lets setup the mysql connection details into mcp sever
- Environmental variables for mysql connection details
MYSQL_USERNAME
MYSQL_PASSWORD
MYSQL_HOST
MYSQL_DATABASE
- Lets add a depenency called as
python-dotenv
uv add python-dotenv
- Create a .env file with following content
MYSQL_USERNAME=root
MYSQL_PASSWORD=rootpassword
MYSQL_HOST=localhost
MYSQL_DATABASE=library
- To load environment variables
from dotenv import load_dotenv
import os
load_dotenv()
print(os.getenv('MYSQL_USERNAME'))
