Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 9303b25

Browse files
ramnovCopilot
andauthored
Adds support for Azure Database for MySQL (#855)
* Adds support for Azure Database for MySQL * Update areas/mysql/src/AzureMcp.MySql/Services/MySqlService.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update areas/mysql/src/AzureMcp.MySql/Services/MySqlService.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * dotnet format * Update areas/mysql/src/AzureMcp.MySql/Commands/BaseDatabaseCommand.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update areas/mysql/src/AzureMcp.MySql/Commands/BaseServerCommand.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update areas/mysql/src/AzureMcp.MySql/Services/MySqlService.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * removing select check * Addressing PR comments * using only user * Update --user in unit tests * fixing blank lines * Use ObjectVerb semantics * updated codeowners * update description * Updated changelog * Add notices.txt * Update command description * update description * add tenant service * push mysql to build native * excluding project for AOT * add query validation * remove mcp.json * remove unnecessary file * reverting cspell to original * updating cspell * updating unit tests * resolve PR comments * remove empty files * refactor options * dotnet format * reduce unit tests * update changelog * fix unit tests * Trigger build * using requireresourcegroup * improving descriptions * update description * limit results * dotnet format * updating notice.txt * Updating command descriptions * Trigger Build * addressing comments --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b08d6b5 commit 9303b25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2852
-0
lines changed

‎.github/CODEOWNERS‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@
136136
# ServiceLabel: %area-AzureManagedLustre
137137
# ServiceOwners: @wolfgang-desalvador
138138

139+
# PRLabel: %area-MySQL
140+
/areas/mysql/ @ramnov @mattkohnms @Azure/azure-mcp
141+
142+
# ServiceLabel: %area-MySQL
143+
# ServiceOwners: @ramnov @mattkohnms
144+
145+
139146
# PRLabel: %area-Postgres
140147
/areas/postgres/ @kk-src @shreyaaithal @maxluk @xiangyan99 @Azure/azure-mcp
141148

‎.vscode/cspell.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
"bdylan",
268268
"bestpractices",
269269
"bicepschema",
270+
"BINLOG",
270271
"binutils",
271272
"brazilsouth",
272273
"brazilsoutheast",
@@ -290,6 +291,7 @@
290291
"CONTENTAZUREFILECONNECTIONSTRING",
291292
"CONTENTSHARE",
292293
"contoso",
294+
"CONV",
293295
"copilotmd",
294296
"Cosell",
295297
"csdevkit",
@@ -308,6 +310,7 @@
308310
"dotnettools",
309311
"dotenv",
310312
"drawcord",
313+
"DUMPFILE",
311314
"eastasia",
312315
"eastus",
313316
"eastus2euap",
@@ -340,6 +343,7 @@
340343
"idempotency",
341344
"idtyp",
342345
"indonesiacentral",
346+
"INFILE",
343347
"israelcentral",
344348
"italynorth",
345349
"japaneast",
@@ -399,6 +403,7 @@
399403
"onboarded",
400404
"openai",
401405
"operationalinsights",
406+
"OUTFILE",
402407
"packability",
403408
"pageable",
404409
"payg",
@@ -462,6 +467,8 @@
462467
"uaenorth",
463468
"uksouth",
464469
"ukwest",
470+
"UNCOMPRESS",
471+
"UNHEX",
465472
"Upns",
466473
"usersession",
467474
"vectorizable",

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ The Azure MCP Server updates automatically by default whenever a new release com
77
### Features Added
88

99
- Introduced `BaseAzureResourceService` class to perform Azure Resource read operations using Azure Resource Graph queries. [[#938](https://github.com/Azure/azure-mcp/pull/938)]
10+
- Added support for the following Azure MySQL operations: [[#855](https://github.com/Azure/azure-mcp/issues/855)]
11+
- `azmcp_mysql_database_list` - List all databases in a MySQL server.
12+
- `azmcp_mysql_database_query` - Executes a SELECT query on a MySQL Database. The query must start with SELECT and cannot contain any destructive SQL operations for security reasons.
13+
- `azmcp_mysql_table_list` - List all tables in a MySQL database.
14+
- `azmcp_mysql_table_schema_get` - Get the schema of a specific table in a MySQL database.
15+
- `azmcp_mysql_server_config_get` - Retrieve the configuration of a MySQL server.
16+
- `azmcp_mysql_server_list` - List all MySQL servers in a subscription & resource group.
17+
- `azmcp_mysql_server_param_get` - Retrieve a specific parameter of a MySQL server.
18+
- `azmcp_mysql_server_param_set` - Set a specific parameter of a MySQL server to a specific value.
1019

1120
### Breaking Changes
1221

‎Directory.Packages.props‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<PackageVersion Include="Azure.ResourceManager.ContainerService" Version="1.2.5" />
3131
<PackageVersion Include="Azure.ResourceManager.Kusto" Version="1.6.1" />
3232
<PackageVersion Include="Azure.ResourceManager.CognitiveServices" Version="1.5.1" />
33+
<PackageVersion Include="Azure.ResourceManager.MySql" Version="1.1.2" />
3334
<PackageVersion Include="Azure.ResourceManager.PostgreSql" Version="1.3.1" />
3435
<PackageVersion Include="Azure.ResourceManager.Redis" Version="1.5.1" />
3536
<PackageVersion Include="Azure.ResourceManager.Resources" Version="1.11.0" />
@@ -64,6 +65,7 @@
6465
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.51.0" />
6566
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.6" />
6667
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.6" />
68+
<PackageVersion Include="MySqlConnector" Version="2.4.0" />
6769
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
6870
<PackageVersion Include="Npgsql" Version="9.0.3" />
6971
<PackageVersion Include="YamlDotNet" Version="16.3.0" />

‎NOTICE.txt‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11995,6 +11995,35 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1199511995

1199611996
---------------------------------------------------------
1199711997

11998+
MySqlConnector 2.4.0 - MIT
11999+
(https://github.com/mysql-net/MySqlConnector?tab=MIT-1-ov-file#readme)
12000+
12001+
MIT License
12002+
12003+
Copyright (c) 2016-2024 Bradley Grainger
12004+
12005+
Permission is hereby granted, free of charge, to any person obtaining a copy
12006+
of this software and associated documentation files (the "Software"), to deal
12007+
in the Software without restriction, including without limitation the rights
12008+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12009+
copies of the Software, and to permit persons to whom the Software is
12010+
furnished to do so, subject to the following conditions:
12011+
12012+
The above copyright notice and this permission notice shall be included in all
12013+
copies or substantial portions of the Software.
12014+
12015+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12016+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12017+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
12018+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
12019+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12020+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
12021+
SOFTWARE.
12022+
12023+
---------------------------------------------------------
12024+
12025+
---------------------------------------------------------
12026+
1199812027
nearley 2.20.1 - MIT
1199912028
https://github.com/hardmath123/nearley#readme
1200012029

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ The Azure MCP Server supercharges your agents with Azure context. Here are some
155155
* List and get schema for tables.
156156
* List, get configuration and get parameters for servers.
157157

158+
### 🐬 Azure Database for MySQL - Flexible Server
159+
160+
* List and query databases.
161+
* List and get schema for tables.
162+
* List, get configuration and get parameters for servers.
163+
158164
### 🛠️ Azure Developer CLI (azd) Extension
159165

160166
* Execute Azure Developer CLI commands directly
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System.Runtime.CompilerServices;
5+
6+
[assembly: InternalsVisibleTo("AzureMcp.MySql.UnitTests")]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<IsAotCompatible>true</IsAotCompatible>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<EmbeddedResource Include="**\Resources\*.txt" />
7+
<EmbeddedResource Include="**\Resources\*.json" />
8+
</ItemGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="..\..\..\..\core\src\AzureMcp.Core\AzureMcp.Core.csproj" />
11+
</ItemGroup>
12+
<ItemGroup />
13+
<ItemGroup>
14+
<PackageReference Include="Azure.Core" />
15+
<PackageReference Include="Azure.ResourceManager" />
16+
<PackageReference Include="Azure.ResourceManager.MySql" />
17+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
18+
<PackageReference Include="ModelContextProtocol" />
19+
<PackageReference Include="MySqlConnector" />
20+
<PackageReference Include="System.CommandLine" />
21+
</ItemGroup>
22+
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System.CommandLine;
5+
using System.CommandLine.Parsing;
6+
using System.Diagnostics.CodeAnalysis;
7+
using AzureMcp.Core.Commands;
8+
using AzureMcp.Core.Commands.Subscription;
9+
using AzureMcp.MySql.Options;
10+
using Microsoft.Extensions.Logging;
11+
12+
namespace AzureMcp.MySql.Commands;
13+
14+
public abstract class BaseMySqlCommand<
15+
[DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] TOptions>(ILogger<BaseMySqlCommand<TOptions>> logger)
16+
: SubscriptionCommand<TOptions> where TOptions : BaseMySqlOptions, new()
17+
{
18+
protected readonly Option<string> _userOption = MySqlOptionDefinitions.User;
19+
20+
protected readonly ILogger<BaseMySqlCommand<TOptions>> _logger = logger;
21+
22+
protected override void RegisterOptions(Command command)
23+
{
24+
base.RegisterOptions(command);
25+
RequireResourceGroup();
26+
command.AddOption(_userOption);
27+
}
28+
29+
protected override TOptions BindOptions(ParseResult parseResult)
30+
{
31+
var options = base.BindOptions(parseResult);
32+
options.User = parseResult.GetValueForOption(_userOption);
33+
return options;
34+
}
35+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System.CommandLine;
5+
using System.CommandLine.Parsing;
6+
using System.Diagnostics.CodeAnalysis;
7+
using AzureMcp.Core.Commands;
8+
using AzureMcp.MySql.Commands.Server;
9+
using AzureMcp.MySql.Options;
10+
using Microsoft.Extensions.Logging;
11+
12+
namespace AzureMcp.MySql.Commands.Database;
13+
14+
public abstract class BaseDatabaseCommand<
15+
[DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] TOptions>(ILogger<BaseMySqlCommand<TOptions>> logger)
16+
: BaseServerCommand<TOptions>(logger) where TOptions : MySqlDatabaseOptions, new()
17+
{
18+
private readonly Option<string> _databaseOption = MySqlOptionDefinitions.Database;
19+
20+
protected override void RegisterOptions(Command command)
21+
{
22+
base.RegisterOptions(command);
23+
command.AddOption(_databaseOption);
24+
}
25+
26+
protected override TOptions BindOptions(ParseResult parseResult)
27+
{
28+
var options = base.BindOptions(parseResult);
29+
options.Database = parseResult.GetValueForOption(_databaseOption);
30+
return options;
31+
}
32+
}

0 commit comments

Comments
 (0)