Skip to content

Commit c7927fa

Browse files
souvikghosh04CopilotJerryNixonAniruddh25
authored
Cherry pick MCP fixes and improvements for 1.7 (#2960)
## Why make this change? Cherry pick MCP fixes and improvements for 1.7. ## What is this change? The PR contains cherry picks from main branch. Following commits from main are taken- - Improve MCP tool descriptions for ChatGPT compatibility 21dde31 - Bug fix for setting dml tools based on bool value as set in config 7228e60 - Expand ALL permissions in MCP describe_entities to explicit operations 3b48c49 - User provided dml-tools property serialization 3adf04f - Honoring incoming request role in determining allowed permissions for describe-entities MCP tool 7b31e9a ## How was this tested? - [ ] Integration Tests - [ ] Unit Tests --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: JerryNixon <[email protected]> Co-authored-by: Aniruddh Munde <[email protected]>
1 parent 5ba8682 commit c7927fa

File tree

51 files changed

+897
-155
lines changed

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

+897
-155
lines changed

src/Azure.DataApiBuilder.Mcp/BuiltInTools/CreateRecordTool.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ public Tool GetToolMetadata()
3131
return new Tool
3232
{
3333
Name = "create_record",
34-
Description = "Creates a new record in the specified entity.",
34+
Description = "STEP 1: describe_entities -> find entities with CREATE permission and their fields. STEP 2: call this tool with matching field names and values.",
3535
InputSchema = JsonSerializer.Deserialize<JsonElement>(
3636
@"{
3737
""type"": ""object"",
3838
""properties"": {
3939
""entity"": {
4040
""type"": ""string"",
41-
""description"": ""The name of the entity""
41+
""description"": ""Entity name with CREATE permission.""
4242
},
4343
""data"": {
4444
""type"": ""object"",
45-
""description"": ""The data for the new record""
45+
""description"": ""Required fields and values for the new record.""
4646
}
4747
},
4848
""required"": [""entity"", ""data""]

src/Azure.DataApiBuilder.Mcp/BuiltInTools/DeleteRecordTool.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ public Tool GetToolMetadata()
4444
return new Tool
4545
{
4646
Name = "delete_record",
47-
Description = "Deletes a record from a table based on primary key or composite key",
47+
Description = "STEP 1: describe_entities -> find entities with DELETE permission and their key fields. STEP 2: call this tool with full key values.",
4848
InputSchema = JsonSerializer.Deserialize<JsonElement>(
4949
@"{
5050
""type"": ""object"",
5151
""properties"": {
5252
""entity"": {
5353
""type"": ""string"",
54-
""description"": ""The name of the entity (table) as configured in dab-config. Required.""
54+
""description"": ""Entity name with DELETE permission.""
5555
},
5656
""keys"": {
5757
""type"": ""object"",
58-
""description"": ""Primary key values to identify the record to delete. For composite keys, provide all key columns as properties. Required.""
58+
""description"": ""All key fields identifying the record.""
5959
}
6060
},
6161
""required"": [""entity"", ""keys""]

src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs

Lines changed: 111 additions & 34 deletions
Large diffs are not rendered by default.

src/Azure.DataApiBuilder.Mcp/BuiltInTools/ExecuteEntityTool.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ public Tool GetToolMetadata()
4444
return new Tool
4545
{
4646
Name = "execute_entity",
47-
Description = "Executes a stored procedure or function, returns the results (if any)",
47+
Description = "STEP 1: describe_entities -> find entities with EXECUTE permission and their parameters. STEP 2: call this tool with matching parameter values. Used for entities that perform actions or return computed results.",
4848
InputSchema = JsonSerializer.Deserialize<JsonElement>(
4949
@"{
5050
""type"": ""object"",
5151
""properties"": {
5252
""entity"": {
5353
""type"": ""string"",
54-
""description"": ""The entity name of the procedure or function to execute. Must match a stored-procedure entity as configured in dab-config. Required.""
54+
""description"": ""Entity name with EXECUTE permission.""
5555
},
5656
""parameters"": {
5757
""type"": ""object"",
58-
""description"": ""A dictionary of parameter names and values to pass to the procedure. Parameters must match those defined in dab-config. Optional if no parameters.""
58+
""description"": ""Optional parameter names and values.""
5959
}
6060
},
6161
""required"": [""entity""]

src/Azure.DataApiBuilder.Mcp/BuiltInTools/ReadRecordsTool.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,38 @@ public Tool GetToolMetadata()
3535
return new Tool
3636
{
3737
Name = "read_records",
38-
Description = "Retrieves records from a given entity.",
38+
Description = "STEP 1: describe_entities -> find entities with READ permission and their fields. STEP 2: call this tool with select, filter, sort, or pagination options.",
3939
InputSchema = JsonSerializer.Deserialize<JsonElement>(
4040
@"{
4141
""type"": ""object"",
4242
""properties"": {
4343
""entity"": {
4444
""type"": ""string"",
45-
""description"": ""The name of the entity to read, as provided by the describe_entities tool. Required.""
45+
""description"": ""Entity name with READ permission.""
4646
},
4747
""select"": {
4848
""type"": ""string"",
49-
""description"": ""A comma-separated list of field names to include in the response. If omitted, all fields are returned. Optional.""
49+
""description"": ""Comma-separated field names.""
5050
},
5151
""filter"": {
5252
""type"": ""string"",
53-
""description"": ""A case-insensitive OData-like expression that defines a query predicate. Supports logical grouping with parentheses and the operators eq, ne, gt, ge, lt, le, and, or, not. Examples: year ge 1990, date lt 2025-01-01T00:00:00Z, (title eq 'Foundation') and (available ne false). Optional.""
54-
},
55-
""first"": {
56-
""type"": ""integer"",
57-
""description"": ""The maximum number of records to return in the current page. Optional.""
53+
""description"": ""OData expression: eq, ne, gt, ge, lt, le, and, or, not.""
5854
},
5955
""orderby"": {
6056
""type"": ""array"",
6157
""items"": { ""type"": ""string"" },
62-
""description"": ""A list of field names and directions for sorting, for example 'name asc' or 'year desc'. Optional.""
58+
""description"": ""Sort fields and directions, e.g., ['name asc', 'year desc'].""
59+
},
60+
""first"": {
61+
""type"": ""integer"",
62+
""description"": ""Max number of records (page size).""
6363
},
6464
""after"": {
6565
""type"": ""string"",
66-
""description"": ""A cursor token for retrieving the next page of results. Returned as 'after' in the previous response. Optional.""
66+
""description"": ""Cursor token for next page.""
6767
}
68-
}
68+
},
69+
""required"": [""entity""]
6970
}"
7071
)
7172
};

src/Azure.DataApiBuilder.Mcp/BuiltInTools/UpdateRecordTool.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,22 @@ public Tool GetToolMetadata()
4646
return new Tool
4747
{
4848
Name = "update_record",
49-
Description = "Updates an existing record in the specified entity. Requires 'keys' to locate the record and 'fields' to specify new values.",
49+
Description = "STEP 1: describe_entities -> find entities with UPDATE permission and their key fields. STEP 2: call this tool with keys and new field values.",
5050
InputSchema = JsonSerializer.Deserialize<JsonElement>(
5151
@"{
5252
""type"": ""object"",
5353
""properties"": {
5454
""entity"": {
5555
""type"": ""string"",
56-
""description"": ""The name of the entity""
56+
""description"": ""Entity name with UPDATE permission.""
5757
},
5858
""keys"": {
5959
""type"": ""object"",
60-
""description"": ""Key fields and their values to identify the record""
60+
""description"": ""Primary or composite keys identifying the record.""
6161
},
6262
""fields"": {
6363
""type"": ""object"",
64-
""description"": ""Fields and their new values to update""
64+
""description"": ""Fields and their new values.""
6565
}
6666
},
6767
""required"": [""entity"", ""keys"", ""fields""]

src/Cli.Tests/ConfigGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void TestSpecialCharactersInConnectionString()
166166
""mcp"": {
167167
""enabled"": true,
168168
""path"": ""/mcp""
169-
},
169+
},
170170
""host"": {
171171
""cors"": {
172172
""origins"": [],

src/Cli.Tests/Snapshots/EndToEndTests.TestAddingStoredProcedureWithRestMethodsAndGraphQLOperations.verified.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,23 @@
1818
},
1919
Mcp: {
2020
Enabled: true,
21-
Path: /mcp
21+
Path: /mcp,
22+
DmlTools: {
23+
AllToolsEnabled: true,
24+
DescribeEntities: true,
25+
CreateRecord: true,
26+
ReadRecords: true,
27+
UpdateRecord: true,
28+
DeleteRecord: true,
29+
ExecuteEntity: true,
30+
UserProvidedAllTools: false,
31+
UserProvidedDescribeEntities: false,
32+
UserProvidedCreateRecord: false,
33+
UserProvidedReadRecords: false,
34+
UserProvidedUpdateRecord: false,
35+
UserProvidedDeleteRecord: false,
36+
UserProvidedExecuteEntity: false
37+
}
2238
},
2339
Host: {
2440
Cors: {

src/Cli.Tests/Snapshots/EndToEndTests.TestConfigGeneratedAfterAddingEntityWithSourceAsStoredProcedure.verified.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,23 @@
1818
},
1919
Mcp: {
2020
Enabled: true,
21-
Path: /mcp
21+
Path: /mcp,
22+
DmlTools: {
23+
AllToolsEnabled: true,
24+
DescribeEntities: true,
25+
CreateRecord: true,
26+
ReadRecords: true,
27+
UpdateRecord: true,
28+
DeleteRecord: true,
29+
ExecuteEntity: true,
30+
UserProvidedAllTools: false,
31+
UserProvidedDescribeEntities: false,
32+
UserProvidedCreateRecord: false,
33+
UserProvidedReadRecords: false,
34+
UserProvidedUpdateRecord: false,
35+
UserProvidedDeleteRecord: false,
36+
UserProvidedExecuteEntity: false
37+
}
2238
},
2339
Host: {
2440
Cors: {

src/Cli.Tests/Snapshots/EndToEndTests.TestConfigGeneratedAfterAddingEntityWithSourceWithDefaultType.verified.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,23 @@
1818
},
1919
Mcp: {
2020
Enabled: true,
21-
Path: /mcp
21+
Path: /mcp,
22+
DmlTools: {
23+
AllToolsEnabled: true,
24+
DescribeEntities: true,
25+
CreateRecord: true,
26+
ReadRecords: true,
27+
UpdateRecord: true,
28+
DeleteRecord: true,
29+
ExecuteEntity: true,
30+
UserProvidedAllTools: false,
31+
UserProvidedDescribeEntities: false,
32+
UserProvidedCreateRecord: false,
33+
UserProvidedReadRecords: false,
34+
UserProvidedUpdateRecord: false,
35+
UserProvidedDeleteRecord: false,
36+
UserProvidedExecuteEntity: false
37+
}
2238
},
2339
Host: {
2440
Cors: {

0 commit comments

Comments
 (0)