mcp-dataverse

mcp-dataverse

7

This project allows for SQL querying of Dataverse environments using the MCP server. It supports integration with AI tools like GitHub Copilot and Claude Desktop and requires specific setup configurations with Azure CLI, Docker, and dotnet. The MCP server is configurable via Docker and dotnet tool, facilitating easy access to Dataverse data.

Overview

The objective of this repo is to enable querying of Dataverse environment using SQL. You can use popular AI tools such as GitHub Copilot or Claude Desktop to query Dataverse, provided you add this MCP Server in the configuration.

A big thank you to Mark Carrington for creating Sql4Cds, without whom this project would not exist. 🙏

Prerequisites 🔍

  1. VSCode March (minimum March 2025 version) or Claude Desktop
  2. Azure CLI installed and authenticated on your local machine, if you are not using the DevContainer option. While interactive browser authentication is possible using Azure Identity framework, using Azure CLI to manage the authentication is little easier.
  3. Docker, if you want to run Dev Containers or the MCP Server inside DevContainer.
  4. dotnet 9.0 SDK if you want to install the dotnet tool.

Model Context Protocol (MCP) 📋

This is how Anthropic, the creators of MCP specification, defines Model Context Protocol

MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.

Installation 🚀

Install as dotnet

If the button above does not work, paste the below URL to the address bar.

vscode:mcp/install?%7B%0A%20%20%20%20%22name%22%3A%20%22dataverse-mcp-dotnet-tool%22%2C%0A%20%20%20%20%22type%22%3A%20%22stdio%22%2C%0A%20%20%20%20%22command%22%3A%20%22mcp-dataverse%22%2C%0A%20%20%20%20%22env%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22DATAVERSE_ENVIRONMENT_URL%22%3A%20%22https%3A%2F%2Fxyz.crm.dynamics.com%22%0A%20%20%20%20%7D%0A%7D

Install with Docker in VS Code

If the button above does not work, paste the below URL to the address bar.

vscode:mcp/install?%7B%0A%20%20%20%20%22name%22%3A%20%22dataverse-mcp-docker%22%2C%0A%20%20%20%20%22type%22%3A%20%22stdio%22%2C%0A%20%20%20%20%22command%22%3A%20%22docker%22%2C%0A%20%20%20%20%22args%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%22run%22%2C%0A%20%20%20%20%20%20%20%20%22--env-file%22%2C%0A%20%20%20%20%20%20%20%20%22%24%7BworkspaceFolder%7D%2F.env%22%2C%0A%20%20%20%20%20%20%20%20%22-i%22%2C%0A%20%20%20%20%20%20%20%20%22--rm%22%2C%0A%20%20%20%20%20%20%20%20%22rajyraman%2Fmcp-stdio-dataverse%22%0A%20%20%20%20%5D%0A%7D

You can click the buttons above to get the MCP Server config settings. You have two options to use this MCP Server:

  1. Docker Container
  2. dotnet tool

Below is the recommendation based on the where you plan to use this MCP

InClientRecommendation
WindowsGitHub Copilotdotnet tool. Use Docker/Podman as fallback, if you have auth issues.
WindowsClaude Desktopdotnet tool
MacOSClaude Desktop, GitHub Copilotdotnet tool
LinuxClaude Desktop, GitHub Copilotdotnet tool
GitHub CodespacesGitHub Copilotdotnet tool

Since this MCP server is built with MCP C# SDK, it is distributed via nuget as a dotnet tool. dotnet 9.0 SDK can be installed in all major OSes.

You can install the Dataverse MCP Server as a global dotnet tool using the command below.

dotnet tool install -g Mcp.Dataverse.Stdio

Configuration

Below is a sample .env file that you can use if you choose to run the MCP Server inside a container. Create the .env on the workspace folder (same level as the README.md).

AZURE_CLIENT_ID=aba9829f-6288-44d7-9168-53eca9a1f4a5
AZURE_CLIENT_SECRET=abcd
AZURE_TENANT_ID=2caa17e6-884b-473b-80c5-c05d8859a2fa
DATAVERSE_ENVIRONMENT_URL=https://abc.crm6.dynamics.com
DOCKER_CONTAINER=true

If you are using this MCP Server on a new folder (not in the cloned repo), make sure that you are have setup. If you already have a different copilot-instructions.md file, you can also create this as a custom prompt under .github/prompts folder e.g. and use it in the chat.

Sample MCP Config

{
    "servers": {
        "dataverse-mcp-dotnet-tool": {
            "type": "stdio",
            "command": "mcp-dataverse",
            "env": {
                "DATAVERSE_ENVIRONMENT_URL": "https://abc.crm6.dynamics.com"
            }
        }
    }
}

Configuration for GitHub Codespaces

When you create you Codespace make sure you select the inside the folder. You should also change the so that the DATAVERSE_ENVIRONMENT_URL environment variable is pointing to the right environment URL.

codespace-step-1

codespace-step-2

Prompts

If you are using GitHub Copilot, file should automatically be used.

On Claude Desktop, you can clicking the "Attach from MCP" button.

Select Prompt

Examples

Example 1 - Get Unmanaged Solutions 📦

Unmanaged Solutions

Example 2 - Show Solutions by Publisher 🏢

Solutions by Publisher

Example 3 - Solutions Imported last week 📅

Solutions imported last week

Example 4 - Plugins registered on contact and account 🔌

Plugin Steps

Example 5 - Running SQL directly with #ExecuteSQL tool

Direct SQL

Example 6 - Only SELECT statements are allowed

This also means that Common Table Expressions are not allowed. This will change if and when GitHub Copilot supports Sampling in MCP spec.

Only SELECT statements allowed