Skip to content

Comprehensive MCP tool integration tests and refactoring#3649

Open
souvikghosh04 wants to merge 11 commits into
mainfrom
Usr/sogh/mcpintegrationtests
Open

Comprehensive MCP tool integration tests and refactoring#3649
souvikghosh04 wants to merge 11 commits into
mainfrom
Usr/sogh/mcpintegrationtests

Conversation

@souvikghosh04

Copy link
Copy Markdown
Contributor

Why make this change?

Add comprehensive integration test coverage for MCP built-in tools (ReadRecords, CreateRecord, UpdateRecord, DeleteRecord, AggregateRecords) and refactor existing tests to eliminate code duplication.

What is this change?

  • New McpToolTestBase shared base class with reusable service provider builders and assertion helpers
  • New integration tests for 5 MCP DML tools covering success paths and error cases
  • Refactored ExecuteEntityToolMsSqlIntegrationTests and DynamicCustomToolMsSqlIntegrationTests to inherit from base class
  • Used [DataTestMethod]/[DataRow] to collapse similar test cases

How was this tested?

  • Integration Tests
  • Unit Tests

Sample Request(s)

N/A - test-only change.

- Add McpToolTestBase with shared service provider builders and assertion helpers
- Add ReadRecordsToolMsSqlIntegrationTests (filter, select, orderby, first, errors)
- Add CreateRecordToolMsSqlIntegrationTests (valid data, missing fields, errors)
- Add UpdateRecordToolMsSqlIntegrationTests (valid update, numeric fields, errors)
- Add DeleteRecordToolMsSqlIntegrationTests (create-then-delete, verify-gone)
- Add AggregateRecordsToolMsSqlIntegrationTests (count, sum/avg/min/max, groupby)
- Refactor ExecuteEntityToolMsSqlIntegrationTests to use McpToolTestBase
- Refactor DynamicCustomToolMsSqlIntegrationTests to use McpToolTestBase
- Use DataTestMethod/DataRow to collapse similar test cases
@souvikghosh04 souvikghosh04 force-pushed the Usr/sogh/mcpintegrationtests branch from 16ed93d to 2f9745e Compare June 4, 2026 09:38
@souvikghosh04 souvikghosh04 requested a review from Copilot June 4, 2026 10:00
@souvikghosh04 souvikghosh04 self-assigned this Jun 4, 2026
@souvikghosh04 souvikghosh04 added the testing Test related issue. label Jun 4, 2026
@souvikghosh04 souvikghosh04 added this to the June 2026 milestone Jun 4, 2026
@souvikghosh04 souvikghosh04 linked an issue Jun 4, 2026 that may be closed by this pull request
@souvikghosh04 souvikghosh04 moved this from Todo to In Progress in Data API builder Jun 4, 2026
@souvikghosh04 souvikghosh04 changed the title Add MCP tool integration tests with shared base class Comprehensive MCP tool integration tests and refactoring Jun 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a shared McpToolTestBase to centralize MCP tool test setup and introduces/expands MsSql integration test coverage for MCP built-in tools (read, create, update, delete, aggregate), while refactoring existing MCP integration tests to reduce duplication.

Changes:

  • Added McpToolTestBase with reusable service-provider builders and common MCP response/assertion helpers.
  • Added new MsSql integration tests for ReadRecordsTool, CreateRecordTool, UpdateRecordTool, DeleteRecordTool, and AggregateRecordsTool.
  • Refactored existing MsSql MCP integration tests to inherit from McpToolTestBase and reuse shared helpers.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/Service.Tests/Mcp/McpToolTestBase.cs New shared base class providing MCP tool execution helpers and DI setup for query/mutation tools.
src/Service.Tests/Mcp/ReadRecordsToolMsSqlIntegrationTests.cs New integration tests for read_records covering select/filter/orderby/first and error cases.
src/Service.Tests/Mcp/CreateRecordToolMsSqlIntegrationTests.cs New integration tests for create_record covering success and validation/error scenarios.
src/Service.Tests/Mcp/UpdateRecordToolMsSqlIntegrationTests.cs New integration tests for update_record covering success and error scenarios.
src/Service.Tests/Mcp/DeleteRecordToolMsSqlIntegrationTests.cs New integration tests for delete_record, including delete-then-read verification.
src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs New integration tests for aggregate_records including scalar aggregates, group-by, pagination, and error paths.
src/Service.Tests/Mcp/ExecuteEntityToolMsSqlIntegrationTests.cs Refactor to inherit from McpToolTestBase and reuse shared helpers/service provider.
src/Service.Tests/Mcp/DynamicCustomToolMsSqlIntegrationTests.cs Refactor to inherit from McpToolTestBase and reuse shared helpers/service provider.

Comment thread src/Service.Tests/Mcp/UpdateRecordToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/UpdateRecordToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/DeleteRecordToolMsSqlIntegrationTests.cs Outdated
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs Outdated
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
@anushakolan

Copy link
Copy Markdown
Contributor

Thanks, Souvik for this broad test coverage. I have added some comments that needs to be addressed. Also, the CosmosDB and MSSQL integration tests are failing, please take a look at that as well.

Comment thread src/Service.Tests/Mcp/CreateRecordToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/CreateRecordToolMsSqlIntegrationTests.cs Outdated
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs Outdated
Comment thread src/Service.Tests/Mcp/DeleteRecordToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/McpToolTestBase.cs
Comment thread src/Service.Tests/Mcp/UpdateRecordToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/DeleteRecordToolMsSqlIntegrationTests.cs Outdated
@github-project-automation github-project-automation Bot moved this from In Progress to Review In Progress in Data API builder Jun 9, 2026
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Comment thread src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 mcp-server testing Test related issue.

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

[Fundamentals] Add integration tests for MCP tools

4 participants