microsoft / microsoft/Dataverse-skills
fix: Hard Rule 0 should verify MCP environment affinity before use
- Dominant language
- No language data
- Stars
- 226
- Forks
- 61
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 7
Description
## Problem
When the user specifies a target org URL (e.g. `Dataverse organization: https://orga14dc4b7.crm.dynamics.com`) and an MCP server is registered for a DIFFERENT environment, Hard Rule 0 says "use MCP directly, skip setup." The agent queries the wrong MCP, gets empty/incorrect results, then has to fall back to CLI -- wasting 10-20s on a dead-end path.
Observed in Codex evals: MCP was registered for `aurorabapenv9880b` but the eval prompt targeted `orga14dc4b7`. The agent used MCP (empty results), then spent time diagnosing before finding the CLI profile for the correct org.
## Root cause
Hard Rule 0 in dv-overview currently says:
> "If any Dataverse MCP tool is found, use it directly -- skip the init check and all setup."
This assumes a single-environment session. Multi-environment scenarios (evals, consultants, dev/test switching) break this assumption.
## Proposed fix
Add environment affinity verification to Hard Rule 0:
1. If the user prompt specifies an org URL, extract the org identifier
2. Check whether the discovered MCP tool name contains a matching org ID (tools are named like `mcp__dataverse___read_query`)
3. If MCP matches the requested org -- use it directly (current behavior)
4. If MCP does NOT match -- skip MCP, fall through to CLI/SDK for the requested org
This keeps the fast path for single-environment sessions while preventing wrong-org queries in multi-environment scenarios.
## Impact
Every eval prompt in the compete suite includes an explicit org URL. When the Codex sandbox has an MCP from a previous session or a different org, every prompt wastes 10-20s on a wrong-MCP dead end before falling back.
## Acceptance criteria
- Agent verifies MCP environment affinity before using it when the prompt contains an explicit org URL
- Single-environment sessions (no explicit URL in prompt) are unaffected
- Static checks pass
Contributor guide
Research direction
Start at Hard Rule 0 in dv-overview and review how discovered MCP tools are selected when an org URL is present. Verify the environment-affinity behavior for matching and non-matching MCP tools, confirm prompts without an explicit URL remain unaffected, and run the repository's static checks.
Written by the indexing model from the issue text.
Assessment
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100