Skip to content

fix: correct mock MCP tool names to match real M365 server contracts#301

Merged
sellakumaran merged 2 commits intomicrosoft:mainfrom
pratapladhani:fix/mock-tool-fidelity-contract
Mar 6, 2026
Merged

fix: correct mock MCP tool names to match real M365 server contracts#301
sellakumaran merged 2 commits intomicrosoft:mainfrom
pratapladhani:fix/mock-tool-fidelity-contract

Conversation

@pratapladhani
Copy link
Contributor

Summary

Fixes #300 — All four mock tool definition files had drifted from the tool catalogs exposed by real M365 MCP servers. Agents developed against the mocks would encounter tool-not-found errors when switched to real servers. There was no mechanism to detect or prevent this drift.

This PR:

  • Corrects all four mock files to match the real M365 MCP server tool catalogs
  • Introduces a snapshot-based fidelity contract that prevents future drift via CI-enforced tests

Changes

Mock file corrections

Server Changes
CalendarTools Renamed 9 tools camelCase→PascalCase (e.g. createEventCreateEvent, deleteEventDeleteEventById). Removed 3 phantom tools not on real server (getEvent, getOrganization, getSchedule). Added 4 missing tools (TentativelyAcceptEvent, ForwardEvent, GetUserDateAndTimeZoneSettings, GetRooms).
MailTools Stripped incorrect Async suffix from all 20 tool names (e.g. SendEmailWithAttachmentsAsyncSendEmailWithAttachments). Added missing FlagEmail tool.
MeServer Renamed all 5 tools to match real server (e.g. getMyProfileGetMyDetails, listUsersGetMultipleUsersDetails).
KnowledgeTools Replaced 3 disabled placeholder entries with 5 real snake_case tools from the live server.

Fidelity infrastructure (new)

Component Purpose
snapshots/*.snapshot.json (4 files) Authoritative tool catalogs captured from live M365 MCP servers — the source of truth.
MockToolFidelityTests.cs CI gate — asserts bidirectional coverage between mocks and snapshots. Runs on every PR with no credentials needed. 8 test cases (4 servers x 2 directions).
MockToolSnapshotCaptureTests.cs Developer tool — queries live M365 servers to detect drift or refresh snapshots. Requires MCP_BEARER_TOKEN env var (skips gracefully when absent).
snapshots/README.md Schema reference and update instructions.

Documentation updates

  • MockToolingServer/README.md — Updated server table with correct tool names, added Fidelity Contract and Keeping Mocks Current sections
  • MockToolingServer/design.md — Added fidelity architecture to flowchart and design description

How the fidelity contract works

Real M365 servers ──(capture tests)──▶ Snapshots ──(fidelity tests)──▶ Mock files
                   (developer-run)                 (CI-enforced)
  • Fidelity tests run in CI on every PR — no credentials needed. If mocks drift from snapshots, CI fails.
  • Capture tests are developer-run when real servers change — requires MCP_BEARER_TOKEN. Detects drift or writes updated snapshots:
# Detect drift (read-only)
MCP_BEARER_TOKEN=<token> dotnet test --filter "FullyQualifiedName~MockToolSnapshotCaptureTests"

# Refresh snapshot files
MCP_BEARER_TOKEN=<token> MCP_UPDATE_SNAPSHOTS=true dotnet test --filter "FullyQualifiedName~MockToolSnapshotCaptureTests"

Test plan

  • MockToolFidelityTests — 8/8 passing (4 servers x 2 directions)
  • MockToolSnapshotCaptureTests — 4/4 passing (skip gracefully with no token)
  • Full test suite — 1121 passed, 0 failed, 17 skipped (pre-existing skips)
  • No existing tests reference old tool names (zero impact verified)
  • CLI built from source and tested with mock server + MeetingAssistant agent (PlaygroundMock profile, all automated tests pass)
  • Code review completed — 10 findings, 0 critical, all high/medium items resolved

🤖 Generated with Claude Code

All four mock tool definition files had drifted from the tool catalogs
exposed by real M365 MCP servers, causing agents developed against the
mocks to encounter tool-not-found errors when switched to real servers.

Mock corrections:
- CalendarTools: rename 9 tools camelCase->PascalCase, remove 3 phantom
  tools (getEvent, getOrganization, getSchedule), add 4 missing tools
  (TentativelyAcceptEvent, ForwardEvent, GetUserDateAndTimeZoneSettings,
  GetRooms)
- MailTools: strip Async suffix from all 20 tool names, add FlagEmail
- MeServer: rename all 5 tools to match real server names
- KnowledgeTools: replace 3 disabled placeholders with 5 real tools

Fidelity infrastructure to prevent future drift:
- snapshots/*.snapshot.json: authoritative tool catalogs captured from
  live M365 MCP servers (contract layer)
- MockToolFidelityTests: CI gate asserting bidirectional coverage
  between mocks and snapshots (no credentials needed)
- MockToolSnapshotCaptureTests: developer tool for drift detection and
  snapshot refresh (requires MCP_BEARER_TOKEN env var)

Fixes microsoft#300

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pratapladhani pratapladhani requested a review from a team as a code owner February 28, 2026 22:54
Copilot AI review requested due to automatic review settings February 28, 2026 22:54
@pratapladhani pratapladhani requested a review from a team as a code owner February 28, 2026 22:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Mock Tooling Server’s MCP mock catalogs to better align with the live M365 MCP tool catalogs, and adds snapshot-driven tests intended to prevent future drift.

Changes:

  • Added snapshot capture + fidelity test suites for mock-vs-live tool catalog alignment.
  • Added checked-in snapshot JSON catalogs for four MCP servers.
  • Updated mock JSON tool definitions and Mock Tooling Server documentation to reflect the new contract approach.

Reviewed changes

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

Show a summary per file
File Description
src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/MockTools/MockToolSnapshotCaptureTests.cs New developer-run integration tests to query live MCP servers and refresh/verify snapshots.
src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/MockTools/MockToolFidelityTests.cs New CI-facing tests to check mock/snapshot coverage.
src/Microsoft.Agents.A365.DevTools.MockToolingServer/snapshots/*.snapshot.json New authoritative tool catalogs captured from live servers (4 files).
src/Microsoft.Agents.A365.DevTools.MockToolingServer/snapshots/README.md New documentation describing snapshot schema and update flow.
src/Microsoft.Agents.A365.DevTools.MockToolingServer/mocks/mcp_CalendarTools.json Renamed/adjusted CalendarTools tool entries.
src/Microsoft.Agents.A365.DevTools.MockToolingServer/mocks/mcp_MailTools.json Renamed MailTools tool entries and added FlagEmail.
src/Microsoft.Agents.A365.DevTools.MockToolingServer/mocks/mcp_MeServer.json Renamed MeServer tools to match live names.
src/Microsoft.Agents.A365.DevTools.MockToolingServer/mocks/mcp_KnowledgeTools.json Replaced placeholder tools with live server snake_case tools.
src/Microsoft.Agents.A365.DevTools.MockToolingServer/README.md Updated server/tool documentation and described the fidelity contract.
src/Microsoft.Agents.A365.DevTools.MockToolingServer/design.md Updated design doc/diagram to include snapshots + fidelity testing.
Comments suppressed due to low confidence (2)

src/Microsoft.Agents.A365.DevTools.MockToolingServer/mocks/mcp_MailTools.json:489

  • The mock SearchMessages tool schema/description still reflects a KQL-based Graph search (queryString, optional fields), but the real-server snapshot defines a natural-language message field that is required (plus conversationId). To prevent schema-mismatch when switching from mock to real servers, update the mock’s inputSchema/description to match the snapshot contract.
    "name": "SearchMessages",
    "description": "Search Outlook messages using Microsoft Graph Search API with KQL-style queries.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "queryString": {
          "type": "string",
          "description": "KQL-style search string (e.g., 'contoso OR from:user@example.com')"
        },

src/Microsoft.Agents.A365.DevTools.MockToolingServer/mocks/mcp_MeServer.json:72

  • The mock GetUserDetails tool uses userId as the required parameter, but the snapshot contract for mcp_MeServer requires userIdentifier (name/email/id) and includes additional optional fields (select, expand). This mismatch can cause agents built against the mock to send the wrong argument name to the real server. Update the mock inputSchema to match the snapshot.
    "name": "GetUserDetails",
    "description": "Get the profile of a specific user by their ID or userPrincipalName.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "string",
          "description": "The unique identifier (GUID) or userPrincipalName (email) of the user to retrieve."
        },
        "select": {
          "type": "string",
          "description": "Comma-separated list of properties to return."
        }
      },
      "required": ["userId"]
    },

sellakumaran
sellakumaran previously approved these changes Mar 5, 2026
…ot refresh

- Extend MockToolFidelityTests to validate inputSchema required fields and
  property names (not just tool names) against snapshots — CI-enforced
- Add MergeMockFile to MockToolSnapshotCaptureTests so MCP_UPDATE_SNAPSHOTS=true
  refreshes both snapshot and mock files in one step; preserves existing
  responseTemplate/delayMs/errorRate for unchanged tools, adds new tools with
  defaults, marks removed tools as enabled=false for review
- Fix pre-existing mock schema drift detected by the new fidelity tests:
  CalendarTools: CreateEvent, UpdateEvent, DeleteEventById, FindMeetingTimes,
  AcceptEvent, DeclineEvent, CancelEvent (remove OData-style userId path param,
  replace flat scalar fields for start/end/attendees)
  MailTools: GetMessage (add bodyPreviewOnly property)
  MeServer: GetMyDetails (add expand), GetMultipleUsersDetails (replace search/
  filter with searchValues array, add required), GetManagerDetails (add select,
  fix required), GetDirectReportsDetails (replace top with select, fix required)
- Update README files to document auto-merge workflow and inputSchema enforcement

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sellakumaran sellakumaran enabled auto-merge (squash) March 6, 2026 00:14
@sellakumaran sellakumaran merged commit def9e6e into microsoft:main Mar 6, 2026
4 checks passed
@pratapladhani pratapladhani deleted the fix/mock-tool-fidelity-contract branch March 6, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: mock MCP tool names have drifted from real M365 MCP server contracts

4 participants