MCP Server
Summary of the new feature / enhancement
dsc.exe will be a MCP server started as dsc mcp. It will support STDIO transport. This is to support future AI scenarios where the user wants to use MCP clients like CoPilot to make changes ot the system which results in invoking a DSC resource.
Proposed technical implementation details (optional)
As LLMs are still evolving and we want to support SLM use cases as well, we should be thoughtful about the number of tokens returned as to not exceed limits. Additionally, we should assume in the future that a system may have thousands of DSC resources (locally or perhaps through remote discovery from a repository), so need a strategy for this to work effectively.
Proposed tools in implementation order:
list_dsc_resources([adapter])
This will provide a small list of resources found on the current system. Should include the typeName, description and kind. Only 1 version should be returned.
show_dsc_resource(<typeName>)
This retrieves all the information for one specific DSC resource. Only latest version is returned. Includes schema.
validate_dsc_resource_schema(<typeName>, <input>)
Used to validate potential input JSON against the resource JSONSchema.
invoke_dsc_resource(<operation>, <typeName>, [input])
Invoke get, set, test, or export against a specific resource.
list_configuration_examples()
Returns a list of embedded example configurations (YAML) returning name and description. This is intended to give the LLM some example of what a proper configuration doc should look like.
show_configuration_example(<name>)
Returns one example configuration (YAML)
validate_configuration(<input>)
Perform static analysis of the configuration.
invoke_dsc_configuration(<operation>, <input>)
Invoke get, set, test, or export against the configuration.
I think that some of these tools might be better served as MCP resources (or resource templates), in particular the examples but also potentially the list.
show_dsc_resource "retrieves all the information" suggests no need for show_dsc_resource_schema, and I would agree that it is generally good to keep the tool count low.
Regarding limitations on output, my thoughts on a find_dsc_resource tool with the goal of sifting through a large number of DSC resources without requiring that their data all fits within the context window.
The general flow of the tool would be:
- Takes in a string
user_querythat is intended to be a distillation of the user request. - Server uses sampling to request a list of keywords to use when searching.
- Server filters resources based on given keywords. This likely requires more nuance so that you don't end up returning 99% of the resources because you were given
resourceas a keyword. - Server uses sampling to have model choose the best resource from the results of 3.
- Server responds with resource information, but at
listlevel and requiresshow_dsc_resource(_schema)to get the data required to callinvoke_dsc_resource. The goal is that the user should know precisely which DSC resource is involved when they approve it (potentially) being invoked.
Are there any thoughts around "find_dsc_resource" that has the ability to search configured sources like PSGallery, Microsoft Artifact Repository, Azure Container Registry, or "in the future" WinGet packages with the upcoming DSC Resource metadata, or is this only for handling local resources.
Assume I had the desire to build a "WinGet Configuration" file, and I didn't know what resources I had on my system, or which ones were available. Prompts could be something like:
- I want a configuration for building a game
- What settings should I use when giving a presentation
- I want delayed meeting start times default in Outlook
- I need to focus. Disable interruptions from apps
- How can I share my PC setup with my friend
@denelon, I think searching online will come after we conclude our repository strategy for DSC.
@JohnMcPMS based on this article about tools vs resources, it seems that tools are intended to be automatically used by LLMs while resources are intended to be used by users/application. As such, the current intent is to have tools to be used solely by the LLM.
I wanted to separate out the resource definition from the schema as the schema itself could be large, but also not needed if the LLM determines based on the definition it's not appropriate for the intended task. Searching for the right resource is a difficult problem hence I broke out so many tools. The current tool search is based off of exactly matching the name, tag, or description. However, if the user says "network address", but the resource only uses "ipaddress", then there would never be a match. But a LLM would understand the synonym and my expectation is it could narrow it down via the list and use show to validate.
After some thought, I think I'll combine list_adapted_resources() into list_dsc_resources(). Basically, change it to list_dsc_resources([adapter]) where if no adapter is specified, it returns non-adapted resources, otherwise it's used to return adapted resources.
Then I'm ok with including the schema with show_dsc_resource() instead of having a separate tool.
Hey @SteveL-MSFT, you asked me to check out the MCP functionality, and I had some time today. I was actually quite surprised by what was returned by asking the two following questions:
- List out the DSC resources
- What capabilities does OhMyPosh/Config have?
That got me thinking about the ongoing discussion we're already having. This question might be too far thought, but wouldn't it be amazing to ask a question like: Can you give me a rough PowerShell class-based DSC resource called Foo, following the schemantics and possible capabilities to be included? I recognize that it should have a form of reference (RDK?). Still, looking even further ahead, it will be extremely helpful for the community to transition from script-based to class-based resources when such an implementation is made. Just a thought dropping in here.
MCP for resource authoring is currently out-of-scope, but agree it'll be more interesting once we have the RDK to base it upon.
Some additional functions may be helpful for the LLM.
- list_dsc_functions
- list_dsc_extensions
- show_dsc_function