Skip to content

Commit d29db16

Browse files
authored
Chore/Custom MCP Validation (#4996)
- Updated `validateMCPServerSecurity` to only allow whitelisted commands, removing the extensive list of dangerous commands. - Introduced `validateArgsForLocalFileAccess` to check for potential local file access patterns and null byte injections. - Updated `Supergateway_MCP` to utilize the new argument validation function. - Added a warning in `CustomMCP` regarding upcoming changes to Remote MCP support.
1 parent 28fec16 commit d29db16

File tree

4 files changed

+58
-378
lines changed

4 files changed

+58
-378
lines changed

packages/components/nodes/tools/MCP/CustomMCP/CustomMCP.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ class Custom_MCP implements INode {
7272
label: 'How to use',
7373
value: howToUseCode
7474
},
75-
placeholder: mcpServerConfig
75+
placeholder: mcpServerConfig,
76+
warning:
77+
process.env.CUSTOM_MCP_SECURITY_CHECK === 'true'
78+
? 'In next release, only Remote MCP with url is supported. Read more <a href="https://docs.flowiseai.com/tutorials/tools-and-mcp#streamable-http-recommended" target="_blank">here</a>'
79+
: undefined
7680
},
7781
{
7882
label: 'Available Actions',

packages/components/nodes/tools/MCP/Supergateway/SupergatewayMCP.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tool } from '@langchain/core/tools'
22
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../../src/Interface'
33
import { getNodeModulesPackagePath } from '../../../../src/utils'
4-
import { MCPToolkit, validateMCPServerSecurity } from '../core'
4+
import { MCPToolkit, validateArgsForLocalFileAccess } from '../core'
55

66
class Supergateway_MCP implements INode {
77
label: string
@@ -108,7 +108,7 @@ class Supergateway_MCP implements INode {
108108

109109
if (process.env.CUSTOM_MCP_SECURITY_CHECK === 'true') {
110110
try {
111-
validateMCPServerSecurity(serverParams)
111+
validateArgsForLocalFileAccess(processedArgs)
112112
} catch (error) {
113113
throw new Error(`Security validation failed: ${error.message}`)
114114
}

0 commit comments

Comments
 (0)