d365fo-client
Copilot instructions39 starsChanged 12 months agoMITView on GitHub
Use uv for local commands and dependency management. Cross-platform wrappers exist and mirror the same workflows: CI installs with uv sync --all-extras, runs uv run pytest tests/ --cov=src/ --cov-report=xml, and builds with uv build. This repo has three connected surfaces that share the same core client: Configuration is shared between CLI and MCP:
The file
We split this copilot-instructions.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 5
Use uv for local commands and dependency management.
- Very specific: line 70
Treat FastMCP mixins as the MCP extension point: Add or change tools in src/d365fo_client/mcp/mixins/.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot instructions for d365fo-client
Build, test, and lint commands
Use uv for local commands and dependency management.
# install dependencies
uv sync --dev
# full test suite
uv run pytest
# unit tests only
uv run pytest tests/unit
# integration tests only
uv run pytest tests/integration
# run one test file
uv run pytest tests/unit/test_cli.py
# run one test case
uv run pytest tests/unit/test_cli.py::TestCLIManager::test_config_list_empty
# run one integration file directly
uv run pytest tests/integration/test_sandbox_crud.py
# run sandbox integration suite through the project runner
uv run python tests/integration/test_runner.py sandbox --verbose
# run one sandbox integration file through the runner
uv run python tests/integration/test_runner.py sandbox --test test_sandbox_crud.py
# formatting and linting
uv run black --check .
uv run isort --check-only .
uv run ruff check .
uv run mypy src/
# build
uv buildCross-platform wrappers exist and mirror the same workflows:
- Unix:
make dev,make quality-check,make test-unit,make build - PowerShell:
.\make.ps1 dev,.\make.ps1 quality-check,.\make.ps1 test-unit,.\make.ps1 build
CI installs with uv sync --all-extras, runs uv run pytest tests/ --cov=src/ --cov-report=xml, and builds with uv build.
High-level architecture
This repo has three connected surfaces that share the same core client:
- Python client:
src/d365fo_client/client.pydefinesFOClient, which composes auth, HTTP session management, CRUD helpers, metadata API helpers, and label operations. Metadata is initialized lazily and uses the V2 cache/search/sync stack undersrc/d365fo_client/metadata_v2/. - CLI:
src/d365fo_client/main.pybuilds the argparse tree, andsrc/d365fo_client/cli.pyroutes commands throughCLIManager, which resolves config and then runs the sameFOClient. - MCP server:
src/d365fo_client/mcp/fastmcp_main.pyis the entry point,fastmcp_server.pyassembles the FastMCP server, and tool implementations live in mixins undersrc/d365fo_client/mcp/mixins/.D365FOClientManagerpoolsFOClientinstances per profile for MCP use.
Configuration is shared between CLI and MCP:
FOClientConfiginmodels.pyis the base config model.Profileinprofiles.pyextendsFOClientConfigso CLI/MCP profiles use the same core fields.ConfigManagerandProfileManagerboth read/write~/.d365fo-client/config.yaml.- Environment-backed settings for MCP server startup live in
settings.pyvia Pydantic settings.
Key conventions
- Prefer the V2 metadata stack.
MetadataCacheV2is the active cache implementation; new work should integrate withmetadata_v2/, not older cache/sync modules. - Treat FastMCP mixins as the MCP extension point. Add or change tools in
src/d365fo_client/mcp/mixins/;src/d365fo_client/mcp/tools/is legacy. - Profiles are the shared config contract.
ProfileinheritsFOClientConfig, so new config fields usually belong inFOClientConfigfirst, then flow into profile serialization. - Config precedence matters. The CLI resolves config in this order: command-line args -> environment variables -> saved profile -> defaults.
credential_source=Nonemeans Azure default credentials. Legacyclient_id/client_secret/tenant_idfields are migrated intocredential_source; avoid adding new auth logic around the old fields.- Metadata access is cache-first by default.
FOClientlazily initializes metadata, prefers cache reads when enabled, and can trigger background sync when cache data is stale or missing. - MCP tools return dictionaries, including errors. Shared tool behavior comes from
BaseToolsMixin._create_error_response(), so keep tool outputs structured instead of returning JSON strings. - CLI output goes through
OutputFormatter. Supported formats arejson,table,csv, andyaml; keep command handlers returning plain Python data that the formatter can render. - Example code should use the project defaults. The repo consistently uses
D365FO_BASE_URLwith the One Box URL as the fallback default, and favors default Azure credentials unless explicit credentials are required. - D365 entity/action naming is significant. For OData work, distinguish internal entity names from public entity / collection names, and respect action binding kinds (
Unbound,BoundToEntitySet,BoundToEntityInstance) when constructing calls.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

