Dataverse MCP Server - Advanced MCP Features Showcase
This repository demonstrates a sophisticated Model Context Protocol (MCP) Server that integrates with Microsoft Dataverse and showcases advanced MCP capabilities.
Key MCP Features Implemented
๐ MCP Elicitation
When FetchXML queries return large result sets (>20 records), the server prompts users to choose between receiving raw JSON or saving results as formatted resources.
๐ง MCP Sampling
Data transformation by internal calls to the LLM - sampling - to convert raw Dataverse JSON responses into user-friendly markdown tables with proper formatting and structure.
๐ MCP Resources
Dynamic resource creation that stores transformed data as accessible resources available from the MCP Server.
๐ MCP Progress
Real-time progress notifications during bulk operations (e.g., creating multiple contact records) with status updates and completion tracking.
How It Works
- Query Execution: Execute FetchXML queries against Dataverse using the
ExecuteFetchtool - Smart Result Handling:
- โค20 records: Return JSON directly
-
20 records: Trigger MCP Elicitation workflow
- User Choice: Interactive prompt asking whether to save large results as resources
- Data Transformation: If user chooses resource storage, MCP Sampling transforms JSON to markdown
- Resource Creation: Formatted data saved as MCP Resource with descriptive metadata
Available MCP Tools
- ExecuteFetch: FetchXML query execution with smart result handling
- CreateTextResource: Basic resource creation for any text content
- WhoAmI: Dataverse identity verification
- BulkCreateRandomContacts: Bulk data creation with progress tracking
Demo
This video demonstrates VS Code using this MCP Server to:
- Retrieve Dataverse data through FetchXML queries
- Transform large result sets into
Markdownformatted resources - Optional adding of resources to the AI context window.
Technical Implementation
Built with:
- ASP.NET Core and .NET 9.0
- C# MCP SDK for protocol implementation
- Microsoft.PowerPlatform.Dataverse.Client for Dataverse integration
- ModelContextProtocol.AspNetCore v0.3.0-preview.3
Getting Started
- Clone the repository
- Copy
appsettings.jsontoappsettings.local.jsonand configure Dataverse credentials - Run:
dotnet run --project MyDataverseMcpServer --environment Development - Server runs on
http://localhost:3001
The server demonstrates how MCP can create sophisticated, interactive experiences that go far beyond simple request-response patterns.