microsoft-copilot-studio-metadata-mcp
<!-- mcp-name: io.github.tdries/microsoft-copilot-studio-metadata-mcp -->
<p align="center">
<img src="docs/images/banner.png" alt="microsoft-copilot-studio-metadata-mcp" width="880">
</p>
<h1 align="center">microsoft-copilot-studio-metadata-mcp</h1>
<p align="center"><em>Ask any question about your Microsoft Copilot Studio agents, in any MCP client.</em></p>
<p align="center">
<a href="https://github.com/tdries/microsoft-copilot-studio-metadata-mcp/actions/workflows/ci.yml"><img src="https://github.com/tdries/microsoft-copilot-studio-metadata-mcp/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
<a href="https://github.com/tdries/microsoft-copilot-studio-metadata-mcp/actions/workflows/codeql.yml"><img src="https://github.com/tdries/microsoft-copilot-studio-metadata-mcp/actions/workflows/codeql.yml/badge.svg" alt="CodeQL"></a>
<a href="https://github.com/tdries/microsoft-copilot-studio-metadata-mcp/actions/workflows/fuzz.yml"><img src="https://github.com/tdries/microsoft-copilot-studio-metadata-mcp/actions/workflows/fuzz.yml/badge.svg" alt="Fuzz"></a>
<a href="https://securityscorecards.dev/viewer/?uri=github.com/tdries/microsoft-copilot-studio-metadata-mcp"><img src="https://api.securityscorecards.dev/projects/github.com/tdries/microsoft-copilot-studio-metadata-mcp/badge" alt="OpenSSF Scorecard"></a>
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff"></a>
<img src="https://img.shields.io/badge/python-3.10%20to%203.13-3776AB.svg" alt="Python 3.10 to 3.13">
<img src="https://img.shields.io/badge/MCP-compatible-8A2BE2.svg" alt="MCP compatible">
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-00696E.svg" alt="MIT License"></a>
<img src="https://img.shields.io/badge/Dataverse-read%20only-006EFF.svg" alt="Dataverse read only">
<img src="https://img.shields.io/badge/deps-mcp%20%2B%20pyyaml-64FA8C.svg" alt="Minimal dependencies">
<img src="https://img.shields.io/badge/status-alpha-FF8C42.svg" alt="Alpha">
</p>
<p align="center">
<img src="docs/images/demo-governance.gif" alt="Asking which agents need no sign in and reach SharePoint" width="760">
</p>
---
Everything you build in Copilot Studio is stored as rows in Dataverse: one row per agent in `bot`, one row
per topic, action, knowledge source and instruction set in `botcomponent`, with the definition as YAML in a
`data` column. **microsoft-copilot-studio-metadata-mcp** turns those tables into MCP tools, so an AI
assistant (Claude, Cursor, VS Code and others) can answer questions in plain language:
- _"Which agents can be used without signing in, and which of those reach SharePoint?"_
- _"Which actions run on the maker's own credentials for every user?"_
- _"What breaks if we retire the Office 365 Outlook connection?"_
- _"Which agents were never published, and who owns them?"_
- _"Show me the instructions of the HR assistant and how it differs from the Finance one."_
- _"What changed in our agents since last Monday?"_
It ships **fifteen tools**: a description of the data model, a check of that model against your
environment, a safe query and count surface over the agent tables, a decoded inventory of every agent,
impact analysis, nineteen governance rules, a side by side comparison and snapshots for change over time.
Together they let the model answer any question about your agents, not a fixed menu.
### Why it is different
- **It knows the model.** Which tables hold agent data, how they relate and what every coded column means.
The assistant reads it through `describe_model` before it writes a query.
- **It reads the YAML.** Topics, actions, knowledge sources, instructions and agent settings are decoded,
so the answer says "sends mail on the maker's credentials", not "componenttype 9 with a YAML blob".
- **Impact analysis across agents.** `find_agents_using` joins agents to connectors, connections, flows,
SharePoint sites, models, MCP servers and topic steps.
- **Governance built in.** `inventory_health` runs nineteen rules for security, lifecycle, hygiene and
quality, and returns the findings most serious first.
- **Change over time.** `save_snapshot` and `diff_snapshot` show which agents were added, removed or
changed, down to the setting and the topic.
- **Honest about gaps.** A decoder never guesses. An unknown shape is returned raw and flagged, and
`describe_model` lists what these tables cannot answer.
- **Small and safe.** Read only, stdio only, secrets from the environment, and two dependencies: the MCP
SDK and PyYAML. HTTP runs on the Python standard library.
## Why not the generic Dataverse MCP server?
Microsoft's own Dataverse MCP server can run a query against any table, these included. It hands the
assistant raw rows: a `componenttype` number and a YAML blob. This server adds what is missing between
those rows and an answer:
| | Generic Dataverse MCP | This server |
|---|---|---|
| Knows which tables hold agent data and how they relate | no | yes, and shares it through `describe_model` |
| Reads the YAML (topics, actions, knowledge, instructions) | no | yes, with a decoder per kind |
| Joins agents to connections, flows, sites and models | you write the joins | `find_agents_using` |
| Governance rules | no | `inventory_health`, nineteen rules |
| Change over time | no | `save_snapshot` and `diff_snapshot` |
| Can read your business data | yes | no: a fixed allow list of agent tables |
| Can write | yes | no: GET requests only |
| Labels | caller's language | stable English meaning next to the local label |
## Quickstart
You need Python 3.10 or later, [`uv`](https://docs.astral.sh/uv/) (`curl -LsSf https://astral.sh/uv/install.sh | sh`)
and, for the default way of signing in, the [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli).
The package is not on PyPI yet, so you run it from a clone:
```bash
git clone https://github.com/tdries/microsoft-copilot-studio-metadata-mcp
cd microsoft-copilot-studio-metadata-mcp
uv sync
az login
```
Find your environment's address in Power Apps under **Settings**, then **Session details**, then
**Instance url**.
**Claude Code, one line:**
```bash
claude mcp add copilot-studio-metadata \
-e DATAVERSE_URL=https://yourorg.crm4.dynamics.com \
-- uv run --directory /path/to/microsoft-copilot-studio-metadata-mcp microsoft-copilot-studio-metadata-mcp
```
Then start with: _"Call server_info, then describe_model, then tell me what stands out in inventory_health."_
<details>
<summary><b>Claude Desktop</b></summary>
Edit `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/`, Windows: `%APPDATA%\Claude\`):
```json
{
"mcpServers": {
"copilot-studio-metadata": {
"command": "uv",
"args": ["run", "--directory", "/path/to/microsoft-copilot-studio-metadata-mcp", "microsoft-copilot-studio-metadata-mcp"],
"env": { "DATAVERSE_URL": "https://yourorg.crm4.dynamics.com" }
}
}
}
```
Fully quit and reopen Claude Desktop, then check the tools menu.
</details>
<details>
<summary><b>Cursor</b> · <b>Cline</b> · <b>Windsurf</b> · <b>VS Code</b></summary>
These clients use the same `mcpServers` block shown above. Add it to:
- **Cursor**: `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project).
- **Cline**: the MCP Servers panel, then *Configure*, into `cline_mcp_settings.json`.
- **Windsurf**: `~/.codeium/windsurf/mcp_config.json`.
- **VS Code**: `.vscode/mcp.json`, where the top level key is `servers` instead of `mcpServers`.
On Windows, if `uv` is not found by the app, use its absolute path (for example `%USERPROFILE%\.local\bin\uv.exe`).
</details>
## Configuration
All configuration is through environment variables. Set them in your client's `env` block, never on the
command line. [.env.example](.env.example) holds the same list.
| Env var | Required | Default | Description |
|---|:---:|---|---|
| `DATAVERSE_URL` | yes¹ | n/a | Your environment, for example `https://yourorg.crm4.dynamics.com`. Must be https on a Dataverse domain. |
| `DATAVERSE_AUTH` | no | auto | `azcli`, `client_secret` or `token`. Left empty, it follows from the variables you set. |
| `AZURE_TENANT_ID` | no² | n/a | Tenant of the app registration. With the Azure CLI: only for a guest tenant. |
| `AZURE_CLIENT_ID` | no² | n/a | Client id of the app registration. |
| `AZURE_CLIENT_SECRET` | no² | n/a | Client secret of the app registration. |
| `DATAVERSE_ACCESS_TOKEN` | no | n/a | A token you already have. For short tests. |
| `AGENT_SNAPSHOT_FILE` | no¹ | n/a | Answer from this export file instead of a live environment. No network, no credentials. |
| `AGENT_SNAPSHOT_DIR` | no | `~/.microsoft-copilot-studio-metadata/snapshots` | Where `save_snapshot` writes and `diff_snapshot` reads. |
| `AGENT_INCLUDE_TRANSCRIPTS` | no | `0` | `1` makes `conversationtranscript` readable. Personal data: decide on purpose. |
| `AGENT_CACHE_SECONDS` | no | `300` | How long the decoded inventory is reused. |
| `DATAVERSE_TIMEOUT` | no | `60` | Timeout per request, in seconds. |
| `AGENT_LOG_LEVEL` | no | `INFO` | `DEBUG` logs each HTTP call (method and path only) to stderr. |
| `DATAVERSE_ALLOW_ANY_HOST` | no | `0` | `1` allows a host outside the known Dataverse domains. |
¹ Set `DATAVERSE_URL` for live mode or `AGENT_SNAPSHOT_FILE` for snapshot mode.
² All three are needed when you sign in with an app registration.
### Signing in: three ways
| Way | Set | Best for |
|---|---|---|
| Azure CLI (default) | nothing more: run `az login` once | A consultant or maker on a laptop. You see what your own account may see |
| App registration | `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET` | A view across all makers. Add the app to the environment as an application user with a read only role on the agent tables |
| Ready token | `DATAVERSE_ACCESS_TOKEN` | Short tests |
### Snapshot mode: no credentials at all
Point the server at an export file and it answers every question from that file, with no network:
```json
"env": { "AGENT_SNAPSHOT_FILE": "/path/to/agents-20261127T090000Z.json" }
```
A snapshot is what `save_snapshot` writes: `{"exportedAt", "instance", "tables": {"bot": [...], "botcomponent": [...], ...}}`.
This is how you review a customer's agents offline, and how the history for `diff_snapshot` is built.
## Tools
| Tool | What it does | Key args |
|---|---|---|
| `server_info` | Confirms the connection: environment, mode, identity, agent and component counts. | `refresh` |
| `describe_model` | The whole model: tables, relationships, coded values, YAML kinds, a recipe per question type. | `section` |
| `describe_table` | Every readable column of one table, live from the environment, with meaning where known. | `table` |
| `verify_model` | Differences between the curated model and this environment. | none |
| `query` | Read only OData style query on any agent related table. | `table`, `select`, `filter`, `orderby`, `top` |
| `aggregate` | Counts grouped by one or two columns. | `table`, `by`, `filter`, `top` |
| `list_agents` | One decoded line per agent, with filters. | `name_contains`, `owner_contains`, `published`, `authentication`, `uses` |
| `get_agent` | One agent in full: settings, instructions, actions, knowledge, topics, dependencies. | `agent`, `detail` |
| `get_component` | One part in full: decoded reading plus the raw YAML. | `component_id`, `include_raw` |
| `search` | A word or phrase anywhere in names, descriptions, instructions and definitions. | `text`, `limit` |
| `find_agents_using` | Impact analysis by connector, connection, flow, site, model, step kind and more. | `what`, `kind` |
| `inventory_health` | Governance findings, most serious first. | `category`, `severity`, `agent`, `stale_days` |
| `compare_agents` | Two agents side by side. | `a`, `b` |
| `save_snapshot` | Saves the current definitions to a local file. | `label` |
| `diff_snapshot` | What changed since a snapshot, or between two. | `older`, `newer` |
The first fourteen never change anything. `save_snapshot` writes one file on the machine where the server
runs and nothing else. Nothing is ever written to Dataverse.
## Example questions
Ask in your own words. The assistant picks the tool. [docs/QUESTIONS.md](docs/QUESTIONS.md) lists some
seventy questions with the tool that answers each one, and says plainly which questions these tables
cannot answer.
### Security and governance
| Ask | Answered by |
|---|---|
| _"Which agents require no sign in, and which of those can reach knowledge or actions?"_ | `inventory_health` (`no_authentication`) |
| _"Which agents are open to any user?"_ | `inventory_health` (`open_to_any_user`) |
| _"Which actions run on the maker's own credentials for every user?"_ | `find_agents_using("Maker", kind="credential_mode")` |
| _"Which topics call HTTP endpoints directly, and which ones?"_ | `find_agents_using("", kind="http_url")` |
| _"Which agents have web browsing switched on or run with low content moderation?"_ | `inventory_health(category="security")` |
| _"Give me the five most urgent findings."_ | `inventory_health(severity="high")` |
### Dependencies and impact
| Ask | Answered by |
|---|---|
| _"What breaks if we retire the Office 365 Outlook connection?"_ | `find_agents_using("office365", kind="connector")` |
| _"What breaks when this flow is changed?"_ | `find_agents_using("<flow>", kind="flow")` |
| _"Which SharePoint sites feed which agents?"_ | `find_agents_using("", kind="knowledge_site")` |
| _"Which agents use MCP servers, and which ones?"_ | `find_agents_using("MCP", kind="action_kind")` |
| _"Which agents can send mail or post in Teams?"_ | `find_agents_using("SendEmail", kind="operation")` |
| _"Which agents point at a flow or connection that is gone?"_ | `inventory_health` (`unresolved_dependency`) |
<p align="center">
<img src="docs/images/demo-impact.gif" alt="Asking what breaks when a connection is retired" width="760">
</p>
### Inventory and ownership
| Ask | Answered by |
|---|---|
| _"How many agents do we have, and who built what?"_ | `server_info`, `list_agents` |
| _"Which agents were never published, and who owns them?"_ | `list_agents(published=false)` |
| _"Which agents does a leaver own?"_ | `list_agents(owner_contains=...)` |
| _"Which agents have not been touched for six months?"_ | `inventory_health` (`stale`, `stale_days`) |
| _"How many agents per owner, language or template?"_ | `aggregate(table="bot", by=...)` |
| _"Which agents were created this quarter?"_ | `query(table="bot", filter="createdon gt ...")` |
### Change over time
| Ask | Answered by |
|---|---|
| _"Keep a record of today's state."_ | `save_snapshot` |
| _"What changed in our agents since last Monday?"_ | `diff_snapshot(older=...)` |
| _"Did anyone switch off authentication?"_ | `diff_snapshot` (settings) |
| _"Which topics of this agent were edited?"_ | `diff_snapshot` (components_changed) |
<p align="center">
<img src="docs/images/demo-changes.gif" alt="Asking what changed since the last snapshot" width="760">
</p>
### Content and logic
| Ask | Answered by |
|---|---|
| _"Show me the instructions of the HR assistant."_ | `get_agent` |
| _"How does the HR assistant differ from the Finance one?"_ | `compare_agents` |
| _"Which agents mention the travel policy?"_ | `search` |
| _"Which topics are custom, and which came with the template?"_ | `get_agent(detail="full")` |
| _"What triggers this topic, and what steps does it take?"_ | `get_component` |
| _"Which agents are copies of each other?"_ | `inventory_health` (`duplicate_instructions`) |
## Architecture
<p align="center"><img src="docs/images/architecture.svg" alt="Architecture" width="900"></p>
The server speaks MCP over **stdio** to the client and HTTPS to Dataverse. It gets a token from the Azure
CLI, an app registration or the environment, loads the agent tables with GET requests, decodes them into
one inventory and answers from that. The inventory is reused for five minutes. In snapshot mode it reads
one file and opens no connection at all.
### How it knows the model
Three layers, checked against each other:
1. **A curated model** in [`model.py`](src/microsoft_copilot_studio_metadata_mcp/model.py): five core tables,
eleven link tables, the referenced tables, every relationship, the meaning of each coded column and the
YAML kinds. The assistant reads it through `describe_model`.
2. **Live verification.** `verify_model` asks the environment which tables, option values and YAML kinds
really exist and reports every difference. Environments differ: one of ours held a table Microsoft's
reference pages do not mention.
3. **Defensive decoders** in [`decode.py`](src/microsoft_copilot_studio_metadata_mcp/decode.py). The YAML in
`botcomponent.data` is not documented by Microsoft and it changes. A decoder never guesses: an unknown
kind is returned raw and flagged, and shows up in `verify_model` and `inventory_health`.
## Security
- **Read only by construction.** The Dataverse client can only issue GET requests. A test asserts it.
- **Declared read only.** Every tool carries MCP annotations, so a client can tell reads from the one tool
that writes a local file without reading the code.
- **Fixed allow list.** `query` and `aggregate` reach agent related tables only. Your accounts, contacts
and other business data are out of reach, whatever the assistant asks.
- **Names only from referenced tables.** For flows, connections and users the server reads the name and
state columns, never the definition.
- **Transcripts are off.** `conversationtranscript` holds personal data and stays unreadable unless an
administrator sets `AGENT_INCLUDE_TRANSCRIPTS=1`.
- **Tokens go to Dataverse hosts only.** `DATAVERSE_URL` must be https on a Dataverse domain. The client
refuses to follow a link out of that environment and follows no redirects.
- **Local, over stdio.** No inbound port. Logs go to stderr and never contain tokens or row contents.
- **Agent content is data.** Instructions and topic texts were written by makers. The server tells the
assistant to treat them as data, never as instructions.
- **Snapshots are sensitive.** They contain agent definitions. Files are written with owner only
permissions. Keep them out of version control.
See [SECURITY.md](SECURITY.md) for how to report a problem.
## Status and what is verified
This is version 0.1.0, alpha.
- Verified offline: all fifteen tools against a real export of 21 agents and 322 components, the unit tests
on a synthetic environment, the live client against a local stand in for the Dataverse Web API, and a
full MCP session over stdio.
- Verified against a real environment, read only: every request the server issues (some seventy GET
requests: agents, components, eleven link tables, referenced tables, table and option set metadata) was
sent to a live Dataverse environment from a signed in browser session. All answered as the client
expects. The one refusal (`botcontentpack`, 403 for a maker role) is the documented case and is reported
as a warning. All 21 component type values and all option sets matched the curated model.
- That run changed the design: link tables are now read from the intersect entity set, because an `$expand`
silently drops links to flows the caller cannot read. It surfaced one such link in the test environment.
- **Not yet verified: the Python client itself signing in to a real environment** (Azure CLI or app
registration). `tests/test_live.py` does that check on your machine in one command.
- One environment per server instance. Run one instance per environment for now.
## What it cannot tell you
Usage, sessions, cost, credits and licences are not in these tables: they live in Agent 365 and the Power
Platform admin center. Neither are the documents behind a knowledge source, the Entra identity of an agent,
or agents built outside Copilot Studio. `describe_model` gives the assistant the same list, so it says so
instead of guessing.
## Troubleshooting
| Symptom | Fix |
|---|---|
| Server does not appear | Fully quit and relaunch the client. Check the config path and that the JSON is valid. |
| `spawn uv ENOENT` | Install `uv`, or use the absolute path to `uv`. |
| "Set DATAVERSE_URL ..." | Set `DATAVERSE_URL` for live mode or `AGENT_SNAPSHOT_FILE` for snapshot mode. |
| "The Azure CLI ('az') is not installed" | Install it and run `az login`, or sign in with an app registration. |
| The token was rejected (401) | Run `az login` again. For a guest tenant add `--tenant <id>` and set `AZURE_TENANT_ID`. |
| A table is refused (403) | Your role cannot read it. A maker sees own agents only. Transcripts and content packs usually need an admin or a dedicated read role. |
| An agent count looks low | You see what the signed in identity may read. Use an app registration for a view across all makers. |
| A table or column does not exist (404) | Environments differ. Run `verify_model`. |
| "... is not a Dataverse host" | Check the address. For a host outside the known Dataverse domains set `DATAVERSE_ALLOW_ANY_HOST=1`. |
Inspect the server directly with the MCP Inspector:
```bash
npx @modelcontextprotocol/inspector uv run --directory /path/to/microsoft-copilot-studio-metadata-mcp microsoft-copilot-studio-metadata-mcp
```
## Development
```bash
git clone https://github.com/tdries/microsoft-copilot-studio-metadata-mcp && cd microsoft-copilot-studio-metadata-mcp
uv sync --all-extras
uv run microsoft-copilot-studio-metadata-mcp # run from source
uv run pytest --cov # tests and coverage, offline, no Dataverse needed
uv run ruff check . # lint
uv run ruff format --check . # format
uv run mypy # strict types
```
The same gates run in CI on Linux, macOS and Windows with Python 3.10 to 3.13: `ruff check`,
`ruff format --check`, `mypy --strict` and `pytest` with a coverage floor. The package ships a PEP 561
`py.typed` marker. CodeQL scans every push, and a fuzzing job (`fuzz/`) attacks the parsers that meet
untrusted input.
The test fixture is invented. Never add a real export to the repository. The demo GIFs are rendered by
[`docs/images/render_demo_gifs.py`](docs/images/render_demo_gifs.py) from invented data as well.
Contributions welcome: see [CONTRIBUTING.md](CONTRIBUTING.md) and the [Code of Conduct](CODE_OF_CONDUCT.md).
## Roadmap
- [ ] Publish on PyPI, for a one line install with `uvx`
- [ ] Several environments in one server, with the default environment found for you
- [ ] Sharing per agent from `principalobjectaccess`
- [ ] Usage and cost from the Power Platform and Agent 365 APIs, where the licence allows
- [ ] Foundry agents through the Foundry Agent Service API
- [ ] A Power BI template on top of the snapshot files
## License
[MIT](LICENSE) © Tim Dries.
Not affiliated with or endorsed by Microsoft. Microsoft, Copilot Studio, Dataverse and Power Platform are
trademarks of the Microsoft group of companies.
TDQS
Scored across 15 tools
Each tool has a clearly distinct role: model documentation, live schema inspection, row querying, aggregation, agent listing, agent detail, component detail, search, dependency impact, governance, comparison, and snapshot operations. Overlaps such as query vs. aggregate and search vs. find_agents_using are resolved by explicit scope differences in the descriptions.
All names use snake_case and are readable, but the set mixes verb_noun names (verify_model, get_agent, save_snapshot) with bare verbs (query, aggregate, search) and noun phrases (server_info, inventory_health). The pattern is mostly consistent with minor deviations rather than fully uniform.
Fifteen tools is within the well-scoped range and matches the breadth of the domain: model discovery, querying, agent inspection, search, impact analysis, governance, comparison, and snapshots. Each tool appears to earn its place without redundant surface area.
For a read-only metadata and governance server, the surface is comprehensive: it covers model documentation, live schema checks, table querying and aggregation, agent and component inspection, search, dependency analysis, health rules, agent comparison, and snapshot/diff workflows. There are no obvious dead ends for the stated read-only purpose.