File tree Expand file tree Collapse file tree 3 files changed +84
-15
lines changed
src/main/java/com/github/mcp/examples/server/chat2mysql Expand file tree Collapse file tree 3 files changed +84
-15
lines changed Original file line number Diff line number Diff line change @@ -25,4 +25,5 @@ If you are looking for servers implemented with Typescript MCP SDK or Python MCP
2525
2626These servers aim to demonstrate MCP features and the MCP Java SDK.
2727
28+ - [ Chat2MySQL] ( https://github.com/codeboyzhou/mcp-java-sdk-examples/blob/main/mcp-server-chat2mysql/README.md ) - Use AI agent to chat with your MySQL database
2829- [ Filesystem] ( https://github.com/codeboyzhou/mcp-java-sdk-examples/blob/main/mcp-server-filesystem/README.md ) - Secure file operations with configurable access controls
Original file line number Diff line number Diff line change 1+ # Chat2MySQL MCP Server
2+
3+ Java server implementing Model Context Protocol (MCP) for chat2mysql operations.
4+
5+ ## Features
6+
7+ - Generate SQL optimization tips.
8+
9+ ## API
10+
11+ ### Prompts
12+
13+ - ** generate_sql_optimization_tips**
14+ - Generate SQL optimization tips.
15+ - Input:
16+ * ` sql ` (string): The SQL query to optimize, required.
17+ - Output: A prompt message like below.
18+ ``` sql
19+ There is an SQL statement along with its EXPLAIN plan and table schemas.
20+ Please analyze the query performance and provide optimization recommendations.
21+
22+ The SQL statement is: SELECT * FROM ` test` WHERE id = 1 ;
23+
24+ The table schema for ` test` is: < actual table schema of ` test` >
25+
26+ The EXPLAIN plan for the SQL statement is: < actual EXPLAIN plan of the query >
27+
28+ Please provide optimization recommendations for the SQL statement.
29+ ```
30+
31+ ## Usage with MCP Client
32+
33+ You can use any MCP client such as Cursor (IDE) or Cline (VS Code plugin) to interact with MCP server.
34+
35+ ### Build
36+
37+ ``` bash
38+ mvn clean package
39+ ```
40+
41+ ### Configuration
42+
43+ ``` json
44+ {
45+ "mcpServers" : {
46+ "mcp-server-chat2mysql" : {
47+ "command" : " java" ,
48+ "args" : [
49+ " -jar" ,
50+ " ${your_jar_path}/mcp-server-chat2mysql.jar"
51+ ],
52+ "env" : {
53+ "MYSQL_HOST" : " localhost" ,
54+ "MYSQL_PORT" : " 3306" ,
55+ "MYSQL_USER" : " root" ,
56+ "MYSQL_PASSWORD" : " your_mysql_password" ,
57+ "MYSQL_DB_NAME" : " test"
58+ }
59+ }
60+ }
61+ }
62+ ```
63+
64+ ## Usage with FastAgent
65+
66+ ### Build
67+
68+ ``` bash
69+ mvn clean package
70+ ```
71+
72+ ### Configuration
73+
74+ Rename ` fastagent-config.yaml.example ` to ` fastagent-config.yaml ` and configure the default LLM you want to use.
75+
76+ Rename ` fastagent-secrets.yaml.example ` to ` fastagent-secrets.yaml ` and configure your LLM API key.
77+
78+ ``` bash
79+ pip install uv
80+ uv pip install fast-agent-mcp
81+ uv run ./agent/agent.py
82+ ```
Original file line number Diff line number Diff line change @@ -23,21 +23,7 @@ public class McpPrompts {
2323 * sql (string): The SQL query to optimize, required.
2424 * ------------------------------------------------------
2525 * Prompt Return:
26- * """
27- * There is an SQL statement along with its EXPLAIN plan and table schemas. │
28- * Please analyze the query performance and provide optimization recommendations. │
29- * │
30- * The SQL statement is: SELECT * FROM `test` │
31- * │
32- * The table schema for `test` is: CREATE TABLE `test` (
33- * // Omit details here
34- * ) ENGINE=InnoDB AUTO_INCREMENT=12345 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci │
35- * │
36- * The EXPLAIN plan for the SQL statement is: │
37- * id = 1 | select_type = SIMPLE | table = payment | partitions = null | type = ALL | possible_keys = null | key = null | key_len = null | ref = null | rows = 16500 | filtered = 100.0 | Extra = null | │
38- * |
39- * Please provide optimization recommendations for the SQL statement.
40- * """
26+ * Please see the README.md of this project for more details.
4127 *
4228 * @return {@link McpServerFeatures.SyncPromptSpecification}
4329 */
You can’t perform that action at this time.
0 commit comments