Add MCP tool to create a database table - #8633
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8633 +/- ##
=======================================
Coverage 78.35% 78.36%
=======================================
Files 474 474
Lines 25639 25648 +9
Branches 6827 6830 +3
=======================================
+ Hits 20089 20098 +9
Misses 5550 5550
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:
|
|
Checked the tool against The tool is correct. It targets the right route with While verifying the route I found some pre-existing backend bugs. They live in the route and drivers, not in this tool, so they do not block the tool, but they affect what a caller can actually do. Filed for follow-up:
|
|
On schema-qualified table creation (e.g. If we want schema-qualified creation, there are two paths:
|
|
Before this one merges, I'm going to change the description to say all tables are created in the public schema and a custom schema cannot be used from this tool. Instead, the agent would need to use the @flowfuse/nr-tables-nodes package with the tables-query node to create the table in a separate schema. Unless we decide to hold this off, do the following first:
Let me know @cstns and @Steve-Mcl , I feel this can be a pretty small change that leads to a good improvement but I would like your thoughts first. |
|
Following the discussion, we're adding schema support to table creation before this merges:
Once those are merged, I'll update |
The tool takes an optional schema, defaulting to public, validated with the same rules as the create table API.
The input schema now carries the supported types and the schema default, so the tool description no longer repeats them.
The create table route replies to a successful create with an empty body, which failed to parse as the tool result. The tool now returns the table name and schema instead.
|
Tested against a local FlowFuse through MCP
Latest commit
@cstns can you take one last look and approve it if everything checks out for you? The backend for this landed already in main (#8762 and #8763) so we are ready to merge it. |
|
1 thing I would probably think on is the case sensitive regex and the fact there is a bug in the createTable method.
|
|
Thanks @Steve-Mcl, good eyes! Tried both locally:
|
|
@Steve-Mcl fix for the defaults is up in #8794 |
Adds the
platform_create_database_tableaction tool from #7709, on its own. The two other tools in that issue (platform_create_library_entry,platform_update_git_token) are not included here.What it does
platform_create_database_tablebackingPOST /api/v1/teams/:teamId/databases/:databaseId/tables(team:database:create), added to the existingtables.jsalongside the read tools rather than a separate file.annotations:readOnlyHint: false,destructiveHint: false,idempotentHint: false,openWorldHint: false. Not idempotent because the route returns 409 if a table of that name already exists.Input schema
nameand at least onecolumnare both required (.min(1)). The route handler only replies when bothnameandcolumnsare present, so requiring them keeps a bare call from producing no response.typedocuments the supported set (bigint, bigserial, boolean, date, timestamptz, real, double precision, text); the database driver rejects anything else.schemais optional and defaults topublic. A schema that does not exist yet is created. It needs the create table API change from Add an optional schema field to the create table API #8763.Behaviour notes
errorstring ("FlowFuse Tables is not enabled for this team"), and a name clash returns 409table_exists.Tests