Skip to content

feat(mcp): add FlowFuse Tables platform automation tools - #7990

Merged
Steve-Mcl merged 9 commits into
mainfrom
extract/tables-mcp-tools-from-7722
Jul 28, 2026
Merged

feat(mcp): add FlowFuse Tables platform automation tools#7990
Steve-Mcl merged 9 commits into
mainfrom
extract/tables-mcp-tools-from-7722

Conversation

@andypalmi

@andypalmi andypalmi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds platform_list_team_databases, platform_get_team_database, platform_list_database_tables, platform_get_database_table, and platform_query_database_table_data to the MCP platform automation tool set, covering FlowFuse Tables databases, tables, and row data.
  • Database responses have their credentials object stripped via a shared helper (forge/ee/lib/mcp/utils.js) before being returned, since the underlying API includes a password in that object.
  • Adds team:database:list to the expert-mcp token's implicit scope allow-list.

Closes #7989
Closes FlowFuse/engineering#213

Test plan

  • Unit tests added for all 5 tools covering URL construction, credential redaction on success, error passthrough, and the limit query param

Adds platform_list_team_databases, platform_get_team_database,
platform_list_database_tables, platform_get_database_table and
platform_query_database_table_data tools so the MCP platform automation
surface can list databases and tables and read row data for FlowFuse
Tables. Database responses have their credentials stripped via a shared
helper before being returned. Adds the team:database:list scope to the
expert-mcp token's implicit scope list and unit tests covering the new
handlers.
platform_get_database_table and platform_query_database_table_data now
take a required schemaName, matching the schema disambiguation being
added to the underlying table routes. The caller gets the schema from
platform_list_database_tables, which already returns it per table.
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
Comment thread forge/ee/lib/mcp/tools/teams.js Outdated
@andypalmi andypalmi mentioned this pull request Jul 28, 2026
3 tasks
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.89%. Comparing base (ca3c665) to head (e78db22).

Files with missing lines Patch % Lines
forge/ee/lib/mcp/toolLoader.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7990      +/-   ##
==========================================
+ Coverage   75.86%   75.89%   +0.02%     
==========================================
  Files         434      437       +3     
  Lines       23340    23392      +52     
  Branches     6209     6217       +8     
==========================================
+ Hits        17708    17753      +45     
- Misses       5632     5639       +7     
Flag Coverage Δ
backend 75.89% <96.22%> (+0.02%) ⬆️

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.

teams_spec.js only tested the ported Tables tools; the pre-existing
list/get team tools and the redactDatabaseCredentials null-guard had
no coverage.
andypalmi added 2 commits July 28, 2026 13:55
…ion wording

platform_list_team_databases and platform_get_database_table now wrap
their results in an object instead of a bare array, and all five
Tables tools declare a zod outputSchema describing their response
shape. Also removed the descriptions' explicit mention of stripping
credentials, since it doesn't affect how the tool is called.
…ols-from-7722

# Conflicts:
#	forge/comms/platformAutomation.js
…emas

Move the 5 FlowFuse Tables tools out of teams.js into tools/tables.js,
and extract their repeated input/output field schemas (teamId,
databaseId, tableName, schemaName, database shape, count/meta records)
into a new tool-schemas/tables.js module, since the same fields are
reused across both the input and output schemas.

Also drops the plan-gated-feature caveat from tool descriptions and
switches remaining .passthrough() calls to the non-deprecated .loose().
@andypalmi
andypalmi requested a review from Steve-Mcl July 28, 2026 12:33
andypalmi added a commit that referenced this pull request Jul 28, 2026
## Summary
When FlowFuse Tables isn't enabled for a team's plan, every route under `/api/v1/teams/:teamId/databases` returns a plain 404: `{ code: 'not_found', error: 'Not Found - not available on team' }`. This is indistinguishable from a genuine "that database/table doesn't exist" response.

This came up while adding FlowFuse Tables as an MCP tool for Expert (see #7990): an LLM agent calling these tools has no signal that the feature simply isn't enabled versus the resource not existing, so it can't usefully tell the user "enable Tables for your team" instead of "that doesn't exist".

We discussed two options: augmenting the response with a new `reason`/`reasonCode` field (backward compatible, but introduces a new convention with no precedent in the codebase), versus just making the existing message explicit. Went with the latter since it's a plain string with no established contract around its exact wording, matches the clearest existing precedent (`forge/routes/api/assistant.js:185`), and needs no new convention.

Status code and `code` field are unchanged, only the `error` message now names the feature.

## Test plan
- [x] Lint passes
- No existing test asserts the old message text

Co-authored-by: andypalmi <andrea@flowfuse.com>
Comment thread forge/ee/lib/mcp/tool-schemas/tables.js Outdated
Comment thread forge/ee/lib/mcp/tools/tables.js Outdated
Comment thread forge/ee/lib/mcp/tools/tables.js Outdated
andypalmi and others added 2 commits July 28, 2026 17:47
schemaName was already encoded in these two handlers; tableName wasn't,
even though it's an unconstrained string that can contain characters
that break URL path segments.
Co-authored-by: Stephen McLaughlin <44235289+Steve-Mcl@users.noreply.github.com>
@Steve-Mcl

Copy link
Copy Markdown
Contributor

Tested locally - worked perfectly when combined with a skill in the expert.

@Steve-Mcl
Steve-Mcl enabled auto-merge (squash) July 28, 2026 15:49
@Steve-Mcl
Steve-Mcl disabled auto-merge July 28, 2026 15:50
@Steve-Mcl
Steve-Mcl enabled auto-merge (squash) July 28, 2026 15:50
@Steve-Mcl
Steve-Mcl merged commit 1685d95 into main Jul 28, 2026
29 checks passed
@Steve-Mcl
Steve-Mcl deleted the extract/tables-mcp-tools-from-7722 branch July 28, 2026 16:12
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.

5.4-a.2 FlowFuse Tables tools

2 participants