-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add MCP server as .NET global tool with STDIO and HTTP transports #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
|
@copilot Add actions to get list of cmdlets with a summary of what they do (from help) and another to return the full help content for a cmdlet. The default connection should be set as part of the MCP startup referencing a named connection that Get-DataverseConnection has saved. If no name is provided startup should fail with good instructions on how to save the required connection. |
- Add GetCmdletList tool to list all cmdlets with synopsis - Add GetCmdletHelp tool to get detailed help for specific cmdlets - Add connection name parameter (CLI arg or env var DATAVERSE_CONNECTION_NAME) - Validate connection on startup with helpful error messages - Pre-load $connection variable in script sessions - Update README with setup instructions and new tool documentation Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Implemented in commit 2d55d70: New MCP Tools:
Default Connection:
Example usage: dotnet run --project McpServer.csproj MyConnectionOr with environment variable: export DATAVERSE_CONNECTION_NAME=MyConnection
dotnet run --project McpServer.csproj |
|
@copilot default to PowerShell restricted language mode, but provide a cmd line option to disable it. Also allow the filesystem provider and other restrictions to be turned off. Also, it would be good to allow a session to be started and then for multiple scripts to be run in the same session one after the other if needed. An end session would be good too. So run script will need to track if the supplied script has exited, not the whole runspace. |
|
@copilot set up CI so that the MCP provider is packaged and pushed as .net global tool. It should bundle the module with it. |
…strictions - Add System.CommandLine for proper command-line parsing - Implement persistent sessions with CreateSession/RunScriptInSession/EndSession - Add --unrestricted-mode flag to disable restricted language mode (default: restricted) - Add --enable-providers flag to enable FileSystem/Registry providers (default: disabled) - Track individual script executions, not whole runspace completion - Scripts in same session share variables and state - Update README with new session model and security options - Maintain backward compatibility with session-based execution Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Implemented in commit 16ba421: PowerShell Restricted Language Mode
Provider Control
Persistent Sessions
Command-Line Library
Example usage: # Restricted mode (default)
dotnet run -- -c MyConnection
# Full access
dotnet run -- -c MyConnection --unrestricted-mode --enable-providers |
- Configure project as .NET global tool (command: dataverse-mcp) - Bundle Dataverse PowerShell module in package at tools/net8.0/any/module/ - Update module path resolution to check packaged location first - Add CI workflow steps to build, package and publish to NuGet.org - Publish on stable releases and CI builds from main branch - Update README with installation and usage instructions for global tool - Update Claude Desktop configuration examples Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Implemented in commit ee0d35d: . NET Global Tool Configuration
CI/CD Workflow
Usage # Install
dotnet tool install --global Rnwood.Dataverse.Data.PowerShell.McpServer
# Run
dataverse-mcp --connection MyConnection
# Update
dotnet tool update --global Rnwood.Dataverse.Data.PowerShell.McpServerModule is automatically included in the tool package - no separate installation needed. |
|
@copilot prefix the dotnet tool name with rnwood- |
Change tool command from 'dataverse-mcp' to 'rnwood-dataverse-mcp' for better namespacing and to avoid potential conflicts with other tools. Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Updated in commit 3d27407: Tool command name changed from Installation: dotnet tool install --global Rnwood.Dataverse.Data.PowerShell.McpServerUsage: rnwood-dataverse-mcp --connection MyConnectionUpdated README and Claude Desktop configuration examples. |
|
@copilot in the MCP session, the named connection should be -setasdefault add an e2e test for the MCP server as part of the existing e2e tests. It should create and save a connectioj, launch the mcp server and test that it can run and monitor a script that uses the connection |
- Add -SetAsDefault flag when loading named connection in MCP sessions - Add comprehensive e2e test for MCP server that: - Creates and saves a test connection - Launches the MCP server process - Tests MCP protocol initialization - Creates a session - Runs a script (Get-DataverseWhoAmI) - Monitors script execution and retrieves output - Ends the session and cleans up - Test validates full MCP server workflow with real connection Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Implemented in commit 9c36b68: Connection SetAsDefault:
E2E Test:
|
|
@copilot please split the test into another file and make sure the tests run all in parallel like the main non e2e tests |
- Create new McpServer.Tests.ps1 in e2e-tests directory - Move MCP server test from Module.Tests.ps1 to McpServer.Tests.ps1 - Each test file has its own BeforeAll setup for isolation - Tests can now run in parallel like other test files - No functional changes to test logic Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Implemented in commit b7839c1: Test File Split:
Parallel Execution:
|
|
@copilot Add HTTP mode triggered by a switch. It should use the standard ASPNET env vars and CMD line args for the bindings. Add another e2e test for this. |
- Add --http flag to run server in HTTP mode instead of STDIO - HTTP mode uses ASP.NET Core with JSON-RPC endpoints at /mcp - Supports standard ASP.NET environment variables (ASPNETCORE_URLS, etc.) - Add Microsoft.AspNetCore.App package reference - Implement JSON-RPC request handler for HTTP mode - Update README with HTTP mode documentation and examples - Add comprehensive e2e test for HTTP mode (McpServer-Http.Tests.ps1) - Test validates full HTTP workflow including initialize, session creation, script execution, and cleanup Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Implemented in commit a94b7b7: HTTP Mode:
E2E Test:
Usage Examples: # Default HTTP mode
rnwood-dataverse-mcp --connection MyConnection --http
# Custom port
rnwood-dataverse-mcp --connection MyConnection --http --urls "http://localhost:8080"
# Environment variable
ASPNETCORE_URLS="http://0.0.0.0:5000" rnwood-dataverse-mcp --connection MyConnection --httpDocumentation updated in README with HTTP mode section. |
|
@copilot Try again after reading this: |
- Add ModelContextProtocol.AspNetCore package (v0.4.0-preview.3) - Remove Microsoft.AspNetCore.App reference (provided by AspNetCore package) - Simplify HTTP mode to use AddMcpServer().WithHttpTransport() and MapMcp() - Remove manual JSON-RPC request handling code - Update README to mention official ASP.NET Core package - HTTP endpoints now managed by ModelContextProtocol framework Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Refactored in commit 8acc736: HTTP Mode Now Uses Official Package:
Implementation: builder.Services.AddMcpServer()
.WithHttpTransport()
.WithTools<PowerShellTools>();
var app = builder.Build();
app.MapMcp();The ModelContextProtocol.AspNetCore package handles all protocol details, endpoint routing, and JSON-RPC communication automatically. |
Description
Implements a Model Context Protocol (MCP) server that exposes PowerShell with the Dataverse module pre-loaded, enabling AI assistants to execute PowerShell scripts against Dataverse environments with configurable security controls and persistent session support. Packaged as a .NET global tool and published to NuGet.org via CI/CD.
Supports both STDIO (default) and HTTP transports for flexible deployment scenarios. HTTP mode uses the official ModelContextProtocol.AspNetCore package for proper MCP protocol implementation.
Changes Made
New Project:
Rnwood.Dataverse.Data.PowerShell.McpServer(.NET 8.0)ModelContextProtocolSDK v0.4.0-preview.3 for MCP protocol implementationModelContextProtocol.AspNetCorev0.4.0-preview.3 for HTTP transportMicrosoft.PowerShell.SDKv7.4.6 in persistent runspaces--unrestricted-mode)--enable-providers-SetAsDefaultflag for seamless cmdlet usageSystem.CommandLinefor proper command-line argument parsingMCP Tools
GetCmdletList: Returns all available Dataverse cmdlets with their synopsis for discoveryGetCmdletHelp: Returns detailed help content (description, parameters, examples) for specific cmdletsCreateSession: Creates a new persistent PowerShell session with pre-loaded module and connectionRunScriptInSession: Executes PowerShell scripts in an existing session (variables and state persist)GetScriptOutput: Retrieves output from script execution with optional incremental modeEndSession: Closes and cleans up a persistent sessionPowerShellExecutor Service
ConcurrentDictionaryDATAVERSE_CONNECTION_NAMEenv var)$connectionvariable in all sessions with-SetAsDefaultflagDATAVERSE_MODULE_PATHenv varSecurity Configuration
--unrestricted-mode/-u: Disable language restrictions--enable-providers/-p: Enable all PowerShell providersCommand-Line Interface
--connection/-c: Specify saved connection name--http: Enable HTTP mode (default: STDIO)--urls: Specify HTTP binding URLs (supports ASPNETCORE_URLS env var)--unrestricted-mode/-u: Disable restricted language mode--enable-providers/-p: Enable PowerShell providers--help: Display usage information.NET Global Tool Configuration
Rnwood.Dataverse.Data.PowerShell.McpServerrnwood-dataverse-mcptools/net8.0/any/module/in packagedotnet tool install --global Rnwood.Dataverse.Data.PowerShell.McpServerdotnet tool update --global Rnwood.Dataverse.Data.PowerShell.McpServerCI/CD Pipeline
.github/workflows/publish.ymlE2E Testing
McpServer.Tests.ps1- STDIO mode testMcpServer-Http.Tests.ps1- HTTP mode testGet-DataverseWhoAmI)Setup Requirements
Usage Examples
Install as global tool (recommended):
STDIO Mode (default):
Configure in Claude Desktop
claude_desktop_config.jsonfor STDIO mode:{ "mcpServers": { "dataverse-powershell": { "command": "rnwood-dataverse-mcp", "args": ["--connection", "MyConnection"] } } }HTTP Mode:
HTTP mode uses the official ModelContextProtocol.AspNetCore package and is suitable for:
Persistent Session Workflow:
Testing
Checklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.