|
| 1 | +const { z } = require('zod') |
| 2 | + |
| 3 | +const { basePagination, basePaginationKeys, searchQuery, appendQuery } = require('../schemas') |
| 4 | + |
1 | 5 | module.exports = [ |
2 | 6 | { |
3 | 7 | name: 'platform_list_hosted_instance_types', |
4 | 8 | title: 'List Hosted Instance Types', |
5 | | - description: 'FlowFuse platform automation tool: List all available hosted instance types. Use this to find valid projectType values when creating a hosted instance.', |
| 9 | + description: 'FlowFuse platform automation tool: List all available hosted instance types. Use this to find valid projectType values when creating a hosted instance. Supports name search, active-state filtering and pagination.', |
6 | 10 | annotations: { readOnlyHint: true, destructiveHint: false }, |
7 | | - inputSchema: {}, |
| 11 | + inputSchema: { |
| 12 | + ...basePagination, |
| 13 | + ...searchQuery, |
| 14 | + filter: z.enum(['all', 'active', 'inactive']).optional().describe('Which types to include by active state (default active only)') |
| 15 | + }, |
8 | 16 | handler: async (args, { inject }) => { |
9 | | - const response = await inject({ method: 'GET', url: '/api/v1/project-types' }) |
| 17 | + const url = appendQuery('/api/v1/project-types', args, [...basePaginationKeys, 'query', 'filter']) |
| 18 | + const response = await inject({ method: 'GET', url }) |
10 | 19 | return response |
11 | 20 | } |
12 | 21 | }, |
13 | 22 | { |
14 | 23 | name: 'platform_list_stacks', |
15 | 24 | title: 'List Stacks', |
16 | | - description: 'FlowFuse platform automation tool: List all available stacks (Node-RED versions). Use this to find valid stack values when creating a hosted instance.', |
| 25 | + description: 'FlowFuse platform automation tool: List all available stacks (Node-RED versions). Use this to find valid stack values when creating a hosted instance. Supports name search, filtering and pagination.', |
17 | 26 | annotations: { readOnlyHint: true, destructiveHint: false }, |
18 | | - inputSchema: {}, |
| 27 | + inputSchema: { |
| 28 | + ...basePagination, |
| 29 | + ...searchQuery, |
| 30 | + filter: z.string().optional().describe('Filter by active state ("all", "active", "inactive") or by replacement ("replacedBy:<stackId>")'), |
| 31 | + projectType: z.string().optional().describe('Only return stacks for this hosted instance type (project-type hashid)') |
| 32 | + }, |
19 | 33 | handler: async (args, { inject }) => { |
20 | | - const response = await inject({ method: 'GET', url: '/api/v1/stacks' }) |
| 34 | + const url = appendQuery('/api/v1/stacks', args, [...basePaginationKeys, 'query', 'filter', 'projectType']) |
| 35 | + const response = await inject({ method: 'GET', url }) |
21 | 36 | return response |
22 | 37 | } |
23 | 38 | }, |
24 | 39 | { |
25 | 40 | name: 'platform_list_templates', |
26 | 41 | title: 'List Templates', |
27 | | - description: 'FlowFuse platform automation tool: List all available templates. When creating a hosted instance, if only one template exists, use it automatically. If multiple templates exist, ask the user which one to use.', |
| 42 | + description: 'FlowFuse platform automation tool: List all available templates. When creating a hosted instance, if only one template exists, use it automatically. If multiple templates exist, ask the user which one to use. Supports name search and pagination.', |
28 | 43 | annotations: { readOnlyHint: true, destructiveHint: false }, |
29 | | - inputSchema: {}, |
| 44 | + inputSchema: { |
| 45 | + ...basePagination, |
| 46 | + ...searchQuery |
| 47 | + }, |
30 | 48 | handler: async (args, { inject }) => { |
31 | | - const response = await inject({ method: 'GET', url: '/api/v1/templates' }) |
| 49 | + const url = appendQuery('/api/v1/templates', args, [...basePaginationKeys, 'query']) |
| 50 | + const response = await inject({ method: 'GET', url }) |
32 | 51 | return response |
33 | 52 | } |
34 | 53 | }, |
35 | 54 | { |
36 | 55 | name: 'platform_list_blueprints', |
37 | 56 | title: 'List Blueprints', |
38 | | - description: 'FlowFuse platform automation tool: List all available flow blueprints. Blueprints provide starter flows that can be used when creating a new hosted instance.', |
| 57 | + description: 'FlowFuse platform automation tool: List all available flow blueprints. Blueprints provide starter flows that can be used when creating a new hosted instance. Supports name search, active-state filtering and pagination.', |
39 | 58 | annotations: { readOnlyHint: true, destructiveHint: false }, |
40 | | - inputSchema: {}, |
| 59 | + inputSchema: { |
| 60 | + ...basePagination, |
| 61 | + ...searchQuery, |
| 62 | + filter: z.enum(['all', 'active', 'inactive']).optional().describe('Which blueprints to include by active state (default active only)'), |
| 63 | + team: z.string().optional().describe('Team hashid to also include blueprints specific to that team') |
| 64 | + }, |
41 | 65 | handler: async (args, { inject }) => { |
42 | | - const response = await inject({ method: 'GET', url: '/api/v1/flow-blueprints' }) |
| 66 | + const url = appendQuery('/api/v1/flow-blueprints', args, [...basePaginationKeys, 'query', 'filter', 'team']) |
| 67 | + const response = await inject({ method: 'GET', url }) |
| 68 | + return response |
| 69 | + } |
| 70 | + }, |
| 71 | + { |
| 72 | + name: 'platform_get_hosted_instance_type', |
| 73 | + title: 'Get Hosted Instance Type', |
| 74 | + description: 'Get a single hosted instance type (project type) by id.', |
| 75 | + annotations: { readOnlyHint: true, destructiveHint: false }, |
| 76 | + inputSchema: { |
| 77 | + instanceTypeId: z.string().describe('Project-type hashid identifying the hosted instance type') |
| 78 | + }, |
| 79 | + handler: async (args, { inject }) => { |
| 80 | + const response = await inject({ method: 'GET', url: `/api/v1/project-types/${args.instanceTypeId}` }) |
| 81 | + return response |
| 82 | + } |
| 83 | + }, |
| 84 | + { |
| 85 | + name: 'platform_get_stack', |
| 86 | + title: 'Get Stack', |
| 87 | + description: 'Get a single stack by id.', |
| 88 | + annotations: { readOnlyHint: true, destructiveHint: false }, |
| 89 | + inputSchema: { |
| 90 | + stackId: z.string().describe('Stack hashid') |
| 91 | + }, |
| 92 | + handler: async (args, { inject }) => { |
| 93 | + const response = await inject({ method: 'GET', url: `/api/v1/stacks/${args.stackId}` }) |
| 94 | + return response |
| 95 | + } |
| 96 | + }, |
| 97 | + { |
| 98 | + name: 'platform_get_template', |
| 99 | + title: 'Get Template', |
| 100 | + description: 'Get a single template by id. Env values are blanked in the response.', |
| 101 | + annotations: { readOnlyHint: true, destructiveHint: false }, |
| 102 | + inputSchema: { |
| 103 | + templateId: z.string().describe('Template hashid') |
| 104 | + }, |
| 105 | + handler: async (args, { inject }) => { |
| 106 | + const response = await inject({ method: 'GET', url: `/api/v1/templates/${args.templateId}` }) |
| 107 | + return response |
| 108 | + } |
| 109 | + }, |
| 110 | + { |
| 111 | + name: 'platform_get_blueprint', |
| 112 | + title: 'Get Blueprint', |
| 113 | + description: 'Get a single flow blueprint by id.', |
| 114 | + annotations: { readOnlyHint: true, destructiveHint: false }, |
| 115 | + inputSchema: { |
| 116 | + flowBlueprintId: z.string().describe('Flow blueprint hashid') |
| 117 | + }, |
| 118 | + handler: async (args, { inject }) => { |
| 119 | + const response = await inject({ method: 'GET', url: `/api/v1/flow-blueprints/${args.flowBlueprintId}` }) |
43 | 120 | return response |
44 | 121 | } |
45 | 122 | } |
|
0 commit comments