Skip to content

Commit 70932b0

Browse files
authored
Merge pull request #21 from GregorySHowe/15-mysql_mcp_server
Adding MySQL Support/Tools [POSTFIX]
2 parents dc4cea7 + dd198b5 commit 70932b0

File tree

3 files changed

+61
-18
lines changed

3 files changed

+61
-18
lines changed

src/dbtools-mcp-server/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ dbtools-mcp-server.py is a FastMCP-based server that provides various tools for
3535
- HeatWave similarity search and RAG on existing vector stores
3636
- HeatWave AutoML syntax reference helper
3737
- Create HeatWave vector store from objects in Object Store
38+
- [NOTE] MySQL AI is not compatible with DBTools MCP Server
39+
- [NOTE] MySQL MCP Server relies on MySQL connector python and is recommended for new MySQL HeatWave or MySQL AI users
3840

3941
- **Additional Features**
4042
- OCI Object Store list buckets and objects
@@ -145,11 +147,11 @@ python dbtools-mcp-server.py
145147
16. `list_reports(dbtools_connection_display_name)`: Lists all reports for a connection
146148
17. `find_matching_reports(dbtools_connection_display_name, search_text, limit=5)`: Finds similar reports using vector similarity search
147149
18. `ragify_column(dbtools_connection_display_name, table_name, column_names, vector_column_name)`: Creates and populates a vector column for RAG integration
148-
19. `call_nl2ml(dbtools_connection_display_name: string, question: string)`: Ask natural language questions to machine learning help tool to get answers about heatwave ML (AutoML)
149-
20. `ask_ml_rag(dbtools_connection_display_name: string, question: string)`: Ask ml_rag - retrieval augmented generation tool a question. This is the preferred tool for answering questions using vector stores.
150-
21. `call_load_vector_store(dbtools_connection_display_name: string, namespace: string, bucket_name: string, document_prefix: string, schema_name: string, table_name: string)`: Load documents from object storage into a vector store for similarity search and RAG. Path can be file name, prefix, or full path.
151-
22. `call_list_buckets(dbtools_connection_display_name: string, compartment_id: string)`: List all accessible object store buckets
152-
23. `call_list_objects(dbtools_connection_display_name: string, namespace: string, bucket_name: string)`: List objects/files stored in a given object store bucket
150+
19. `heatwave_ask_help(dbtools_connection_display_name: string, question: string)`: Ask natural language questions to machine learning help tool to get answers about heatwave ML (AutoML)
151+
20. `heatwave_ask_ml_rag(dbtools_connection_display_name: string, question: string)`: Ask ml_rag - retrieval augmented generation tool a question. This is the preferred tool for answering questions using vector stores.
152+
21. `heatwave_load_vector_store(dbtools_connection_display_name: string, namespace: string, bucket_name: string, document_prefix: string, schema_name: string, table_name: string)`: Load documents from object storage into a vector store for similarity search and RAG. Path can be file name, prefix, or full path.
153+
22. `object_storage_list_buckets(compartment_id: string)`: List all accessible object store buckets
154+
23. `object_storage_list_objects(namespace: string, bucket_name: string)`: List objects/files stored in a given object store bucket
153155

154156
## Security
155157

src/mysql-mcp-server/README.md

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ A Python-based MCP (Model Context Protocol) server that provides a suite of tool
44

55
## Overview
66

7-
`mysql_mcp_server.py` is a FastMCP-based server that provides tools for managing MySQL connections, executing SQL, using MySQL AI ML/AI features, and working with OCI Object Storage.
7+
`mysql_mcp_server.py` is a FastMCP-based server that provides tools for managing MySQL connections, executing SQL, using MySQL AI or MySQL HeatWave ML/GenAI features, and working with OCI Object Storage. MySQL MCP Server is the recommended server to get started with MySQL HeatWave or MySQL AI and the only server in this repo that supports MySQL AI.
88

99
## Features
1010

1111
- **Database Connection Management**
1212
- Load connection configs from JSON or environment variables
1313
- List all configured database connections
14-
- Validate connectivity and resolve provider mode (MySQL AI vs. OCI)
14+
- Validate connectivity and resolve provider mode (MySQL AI vs. MySQL HeatWave)
1515

1616
- **Database Operations**
1717
- Execute SQL queries
1818

19-
- **MySQL AI ML and AI Tools**
20-
- `ml_generate`: Text generation with MySQL AI GenAI
19+
- **MySQL AI and MySQL HeatWave ML and GenAI Tools**
20+
- `ml_generate`: Text generation with GenAI
2121
- `ragify_column`: Create/populate vector columns for embeddings
2222
- `ask_ml_rag`: Retrieval-augmented generation from vector stores
23+
- `heatwave_ask_help`: Answers questions about how to use HeatWave ML
2324

2425
- **Vector Store Management**
2526
- List files in `secure_file_priv` (local mode)
@@ -62,14 +63,13 @@ see the [OCI SDK documentation](https://docs.oracle.com/en-us/iaas/Content/API/C
6263
## Required Python Packages
6364

6465
- `oci`
65-
- `requests`
6666
- `fastmcp`
6767
- `mysql-connector-python`
6868

6969
## Supported Database Modes
7070

71-
- **MYSQL_AI** (local MySQL AI AI mode)
72-
- **OCI** (Oracle Cloud Infrastructure-managed databases)
71+
- `MySQL AI`
72+
- `HeatWave`
7373

7474
## MCP Server Configuration
7575

@@ -202,16 +202,17 @@ python mysql_mcp_server.py
202202

203203
1. `list_all_connections()`: List configured database connections and modes
204204
2. `execute_sql_tool_by_connection_id(connection_id, sql, params)`: Execute SQL on a database connection
205-
3. `ml_generate(connection_id, question)`: Generate text via MySQL AI ML
205+
3. `ml_generate(connection_id, question)`: Generate text
206206
4. `ragify_column(connection_id, table, input_col, embedding_col)`: Embed text into a VECTOR column
207207
5. `list_vector_store_files_local(connection_id)`: List available files in `secure_file_priv`
208208
6. `load_vector_store_local(connection_id, file_path)`: Load documents from local filesystem
209209
7. `load_vector_store_oci(connection_id, namespace, bucket, prefix, schema, table)`: Load documents from OCI Object Storage
210210
8. `ask_ml_rag_vector_store(connection_id, question)`: RAG query on default vector store
211211
9. `ask_ml_rag_innodb(connection_id, question, segment_col, embedding_col)`: RAG query restricted to InnoDB tables
212-
10. `list_all_compartments()`: List OCI compartments
213-
11. `object_storage_list_buckets(compartment_name | compartment_id)`: List buckets in a compartment
214-
12. `object_storage_list_objects(namespace, bucket_name)`: List objects in a bucket
212+
10. `heatwave_ask_help(connection_id, question)`: Ask natural language questions about MySQL HeatWave AutoML via NL2ML
213+
11. `list_all_compartments()`: List OCI compartments
214+
12. `object_storage_list_buckets(compartment_name | compartment_id)`: List buckets in a compartment
215+
13. `object_storage_list_objects(namespace, bucket_name)`: List objects in a bucket
215216

216217
## Security
217218

@@ -230,10 +231,10 @@ Here are example prompts you can use to interact with the MCP server, note that
230231
"Add embeddings for 'body' column into 'embedding' column in docs table"
231232
```
232233

233-
### 2. MySQL AI AI
234+
### 2. MySQL AI/MySQL HeatWave
234235

235236
```
236-
"Generate a summary of error logs using MySQL AI ML"
237+
"Generate a summary of error logs"
237238
"Ask ml_rag: Show me refund policy from the vector store"
238239
```
239240

@@ -251,3 +252,38 @@ Here are example prompts you can use to interact with the MCP server, note that
251252
"Load all documents with prefix 'manuals/' into schema hr, table product_docs"
252253
"List local files for vector store ingestion"
253254
```
255+
256+
---
257+
258+
## Appendix: Feature Compatibility and Common Questions
259+
260+
### Q&A Reference
261+
262+
**Q: Is the repo for both HeatWave and MySQL AI?**
263+
A: Yes. This repository supports both MySQL HeatWave and MySQL AI.
264+
265+
**Q: What happened to call_nl2ml for HeatWave? Does one need to use the dbtools server for that?**
266+
A: The `heatwave_ask_help` (NL2ML) tool works only for HeatWave (not for MySQL AI connections). It provides clear, useful error messages if used with an unsupported connection. The dbtools MCP server is not required.
267+
268+
**Q: Do all tools work with both MySQL HeatWave and MySQL AI, with only the connection differing?**
269+
A: No. Not all tools are universally supported. Some are exclusive to MySQL HeatWave (OCI), while others are only for MySQL AI. Refer to the specific tool answers in this appendix.
270+
271+
**Q: What happens if you try to use `list_vector_store_files_local` with a HeatWave connection?**
272+
A: The `list_vector_store_files_local` tool does not function with HeatWave connections. If called on a MySQL HeatWave connection, it will fail gracefully with an error message. When working with MySQL HeatWave, use `load_vector_store_oci` to load documents from object store instead.
273+
274+
**Q: Can `load_vector_store_oci` be used with MySQL AI (e.g., to load files from OCI Object Store into the InnoDB vector store)?**
275+
A: No. The `load_vector_store_oci` tool only works with MySQL HeatWave (OCI) connections. If called on a MySQL AI connection, it will fail gracefully with an error message. When working with MySQL AI, use `load_vector_store_local` to load documents from the local file system instead.
276+
277+
**Q: Will `ragify_column` work with both HeatWave and MySQL AI?**
278+
A: Yes. The `ragify_column` tool is fully supported on both MySQL AI and MySQL HeatWave connections. Its operation and results are the same on both platforms.
279+
280+
**Q: Where does `ask_ml_rag_innodb` execute its vector processing? For example, does it always run solely in MySQL Database Service (MDS), or will the table be loaded into HeatWave and the vector computations performed on the HeatWave cluster?**
281+
A: On MySQL HeatWave (OCI) connections, `ask_ml_rag_innodb` loads the relevant InnoDB table into the HeatWave cluster, and all vector search and processing are executed on the HeatWave cluster for maximum performance. On MySQL AI connections, the processing takes place within the database service instance itself (not a distributed cluster).
282+
283+
**Q: Is the `.oci/config` always needed, or only when (a) listing Compartments/Object Store or (b) loading files from the Object Store?**
284+
A: The OCI config file is required only for features that interact with Oracle Cloud Infrastructure—such as listing compartments, accessing Object Store, or loading files from Object Store. All other functionality can be used without `.oci/config`.
285+
286+
**Q: Will the MCP server work with MySQL AI if there is no OCI config present? Will it support a purely on-premises user?**
287+
A: Yes. The MCP server supports MySQL AI connections without requiring an OCI config file, making it suitable for on-premises environments. For MySQL HeatWave (OCI) connections, any features not dependent on cloud resources will also continue to work if the OCI config is absent. Cloud-dependent requests (such as for OCI Object Store or Compartments) will fail gracefully if attempted without an OCI config.
288+
289+
---

src/mysql-mcp-server/test_mysql_mcp_server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Copyright (c) 2025, Oracle and/or its affiliates.
3+
Licensed under the Universal Permissive License v1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
"""
5+
16
import contextlib
27
import importlib.util
38
import json

0 commit comments

Comments
 (0)