fix(mcp): resolve stacks per instance type and expose an instance's specification#7908
fix(mcp): resolve stacks per instance type and expose an instance's specification#7908andypalmi wants to merge 3 commits into
Conversation
platform_list_stacks returned every stack across every instance type with no way to tell which one was current, so "use the latest" was ambiguous and a superseded Node-RED version could be selected. Scope the tool to a chosen instance type, using the same projectType filter as the real stacks endpoint, and surface that type's defaultStack as the recommended latest version, both in the tool description and in platform_create_hosted_instance's guidance.
The application-instances list carries no instance type, stack, or template, and no tool description said so, so a request to read or match an existing instance's specification had no reliable source and could be answered with a guess reported as fact. Note on the list tool that it omits the specification, and point both it and the create-instance guidance at platform_get_hosted_instance, which already returns the full specification.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7908 +/- ##
=======================================
Coverage ? 75.65%
=======================================
Files ? 432
Lines ? 23087
Branches ? 6126
=======================================
Hits ? 17466
Misses ? 5621
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| Use this when you already have a hosted instance ID and need to know everything about it: | ||
| its name, URL, settings, what application and team it belongs to, and its current state. | ||
| its name, URL, settings, what application and team it belongs to, its current state, and its specification (the instance type, stack, and template it uses). | ||
| Read the specification from this tool whenever you need to know or compare what an existing instance is running, for example to answer a question about it or to create another instance matching it. |
There was a problem hiding this comment.
it would be more concise to use duplicate instead of ...question about it or to create another instance matching it
| Before calling this tool, gather the required parameters: | ||
| 1. Call platform_list_hosted_instance_types first to see what instance types are available on this platform, then ask the user which one they want. | ||
| 2. If they want a specific Node-RED version or stack, or just the latest. Call platform_list_stacks to get the options. If the user has no preference, use the latest available stack. | ||
| 2. If they want a specific Node-RED version or stack, or just the latest. Call platform_list_stacks for the chosen instance type to get the options. If the user has no preference, use the instance type's defaultStack, which is the latest recommended version. |
There was a problem hiding this comment.
I think this should work together with a step-by-step flow where the agent asks for details one at a time. I had this problem several times: I asked the expert to create an instance, and it correctly showed me a multi-option selection. The problem is that the instance types and stack versions in the options did not match each other. So when I selected a combination that was not compatible, the instance creation failed on the first try. After that, the agent called the tool again with different parameters that I never approved.
In my opinion, the solution is to make the agent understand that every instance type has a fixed set of stacks that work with it. So when a user asks to create an instance, the agent should first ask which instance type the user wants. Only after getting that answer, it should ask which stack version the user wants, showing only the stacks that work with that instance type.
| name: 'platform_list_hosted_instance_types', | ||
| title: 'List Hosted Instance Types', | ||
| description: 'FlowFuse platform automation tool: List all available hosted instance types. Use this to find valid projectType values when creating a hosted instance.', | ||
| description: `FlowFuse platform automation tool: |
There was a problem hiding this comment.
Maybe a better option is to combine these two tools into one tool. It would return each instance type together with the stacks that are available for it.
Summary
platform_list_stacksto a given instance type, and surface adefaultStack(the latest recommended stack) on bothplatform_list_hosted_instance_typesandplatform_list_stacks, so the agent has a way to resolve "the latest available stack" instead of picking from an undifferentiated, cross-type list.platform_get_hosted_instance/platform_get_application_hosted_instances' descriptions at reading an instance's specification (instance type, stack, template) before creating another instance matching it, instead of guessing.Test plan
platform_get_hosted_instancefirst, read the realprojectType/stack/templateids, and reused them exactly rather than guessingCloses FlowFuse/engineering#163
Closes FlowFuse/engineering#194
Closes FlowFuse/engineering#180