Skip to content

fix(mcp): resolve stacks per instance type and expose an instance's specification#7908

Open
andypalmi wants to merge 3 commits into
mainfrom
fix/expert-mcp-latest-stack-and-spec
Open

fix(mcp): resolve stacks per instance type and expose an instance's specification#7908
andypalmi wants to merge 3 commits into
mainfrom
fix/expert-mcp-latest-stack-and-spec

Conversation

@andypalmi

Copy link
Copy Markdown
Contributor

Summary

  • Scope platform_list_stacks to a given instance type, and surface a defaultStack (the latest recommended stack) on both platform_list_hosted_instance_types and platform_list_stacks, so the agent has a way to resolve "the latest available stack" instead of picking from an undifferentiated, cross-type list.
  • Point 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

  • Live-validated against a running instance: asked the agent to create 4 more instances "of the same specification" as an existing one — it called platform_get_hosted_instance first, read the real projectType/stack/template ids, and reused them exactly rather than guessing

Closes FlowFuse/engineering#163
Closes FlowFuse/engineering#194
Closes FlowFuse/engineering#180

andypalmi added 3 commits July 22, 2026 00:21
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

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@43ef287). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
forge/ee/lib/mcp/tools/platform.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7908   +/-   ##
=======================================
  Coverage        ?   75.65%           
=======================================
  Files           ?      432           
  Lines           ?    23087           
  Branches        ?     6126           
=======================================
  Hits            ?    17466           
  Misses          ?     5621           
  Partials        ?        0           
Flag Coverage Δ
backend 75.65% <50.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants