Skip to content

Commit 9ccc25a

Browse files
author
andypalmi
committed
refactor(mcp): pass inject response through for team-data 404 handling
1 parent 3322135 commit 9ccc25a

1 file changed

Lines changed: 0 additions & 67 deletions

File tree

forge/ee/lib/mcp/tools/teamData.js

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,6 @@ function appendPaginationQuery (url, args) {
1515
return params.length > 0 ? `${url}?${params.join('&')}` : url
1616
}
1717

18-
// The FF Tables feature-gate preHandler returns this exact message when the
19-
// team's plan does not include tables, independent of the PAT's permissions.
20-
const TABLES_NOT_ENABLED_MESSAGE = 'Not Found - not available on team'
21-
22-
function tablesFeatureGateError (response) {
23-
if (response.statusCode === 404) {
24-
const body = response.json()
25-
if (body && body.error === TABLES_NOT_ENABLED_MESSAGE) {
26-
return {
27-
statusCode: 404,
28-
json: () => ({
29-
code: 'feature_not_enabled',
30-
error: 'FlowFuse Tables is not enabled for this team. This is a plan-level feature and is unrelated to the PAT permissions used to call this tool.'
31-
})
32-
}
33-
}
34-
}
35-
return null
36-
}
37-
3818
// Strips the credentials object (which includes a required password field)
3919
// from a DatabaseCredentials view before it is returned to the tool caller.
4020
function redactDatabaseCredentials (database) {
@@ -59,10 +39,6 @@ module.exports = [
5939
},
6040
handler: async (args, { inject }) => {
6141
const response = await inject({ method: 'GET', url: `/api/v1/teams/${args.teamId}/databases` })
62-
const gateError = tablesFeatureGateError(response)
63-
if (gateError) {
64-
return gateError
65-
}
6642
if (response.statusCode >= 400) {
6743
return response
6844
}
@@ -87,10 +63,6 @@ module.exports = [
8763
},
8864
handler: async (args, { inject }) => {
8965
const response = await inject({ method: 'GET', url: `/api/v1/teams/${args.teamId}/databases/${args.databaseId}` })
90-
const gateError = tablesFeatureGateError(response)
91-
if (gateError) {
92-
return gateError
93-
}
9466
if (response.statusCode >= 400) {
9567
return response
9668
}
@@ -117,10 +89,6 @@ module.exports = [
11789
handler: async (args, { inject }) => {
11890
const url = appendPaginationQuery(`/api/v1/teams/${args.teamId}/databases/${args.databaseId}/tables`, args)
11991
const response = await inject({ method: 'GET', url })
120-
const gateError = tablesFeatureGateError(response)
121-
if (gateError) {
122-
return gateError
123-
}
12492
return response
12593
}
12694
},
@@ -139,10 +107,6 @@ module.exports = [
139107
},
140108
handler: async (args, { inject }) => {
141109
const response = await inject({ method: 'GET', url: `/api/v1/teams/${args.teamId}/databases/${args.databaseId}/tables/${args.tableName}` })
142-
const gateError = tablesFeatureGateError(response)
143-
if (gateError) {
144-
return gateError
145-
}
146110
return response
147111
}
148112
},
@@ -163,10 +127,6 @@ module.exports = [
163127
handler: async (args, { inject }) => {
164128
const url = appendPaginationQuery(`/api/v1/teams/${args.teamId}/databases/${args.databaseId}/tables/${args.tableName}/data`, args)
165129
const response = await inject({ method: 'GET', url })
166-
const gateError = tablesFeatureGateError(response)
167-
if (gateError) {
168-
return gateError
169-
}
170130
return response
171131
}
172132
},
@@ -182,15 +142,6 @@ module.exports = [
182142
},
183143
handler: async (args, { inject }) => {
184144
const response = await inject({ method: 'GET', url: `/api/v1/teams/${args.teamId}/npm/packages` })
185-
if (response.statusCode === 404) {
186-
return {
187-
statusCode: 404,
188-
json: () => ({
189-
code: 'feature_not_enabled',
190-
error: 'NPM packages are not available for this team. Either the npm packages feature is not enabled for the team\'s plan, or the team does not exist.'
191-
})
192-
}
193-
}
194145
return response
195146
}
196147
},
@@ -206,15 +157,6 @@ module.exports = [
206157
},
207158
handler: async (args, { inject }) => {
208159
const response = await inject({ method: 'GET', url: `/api/v1/teams/${args.teamId}/git/tokens` })
209-
if (response.statusCode === 404) {
210-
return {
211-
statusCode: 404,
212-
json: () => ({
213-
code: 'feature_not_enabled',
214-
error: 'Git integration is not available for this team. Either the git integration feature is not enabled for the team\'s plan, or the team does not exist.'
215-
})
216-
}
217-
}
218160
return response
219161
}
220162
},
@@ -237,15 +179,6 @@ module.exports = [
237179
url += `?type=${args.type}`
238180
}
239181
const response = await inject({ method: 'GET', url })
240-
if (response.statusCode === 404) {
241-
return {
242-
statusCode: 404,
243-
json: () => ({
244-
code: 'feature_not_enabled',
245-
error: 'The shared library is not available for this team. Either the shared library feature is disabled for the team\'s plan, the team does not exist, or you are not a member of the team.'
246-
})
247-
}
248-
}
249182
return response
250183
}
251184
}

0 commit comments

Comments
 (0)