-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(mcp): Support custom cmd allow list for mcp server #2014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Adam Tao <[email protected]>
d3df12a
to
a23e340
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is cool stuff, few change to make it more coherent and complete
backend/chainlit/server.py
Outdated
@@ -762,7 +762,7 @@ async def project_settings( | |||
config.features.audio.enabled = True | |||
|
|||
if config.code.on_mcp_connect: | |||
config.features.mcp = True | |||
config.features.mcp.enabled = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could rely on the config value instead of the decorator presence
backend/chainlit/mcp.py
Outdated
@@ -47,22 +50,24 @@ def validate_mcp_command(command_string: str): | |||
# Look for the actual executable in the command | |||
executable = None | |||
executable_index = None | |||
allowed_executables = config.features.mcp.stdio_executable_allow_list or [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make those the default config values (in the config generation) and not hardcode them
backend/chainlit/config.py
Outdated
@dataclass | ||
class MCPFeature(DataClassJsonMixin): | ||
enabled: bool = False | ||
stdio_executable_allow_list: Optional[list[str]] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would love to add transport config here. default would be ["stdio", "sse"], that way developers could refuse to use stdio servers for security reasons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, last detail
@@ -1109,12 +1106,24 @@ async def connect_mcp( | |||
exit_stack = AsyncExitStack() | |||
|
|||
if payload.clientType == "sse": | |||
if not config.features.mcp.sse.enabled: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are missing a check on config.features.mcp.enabled
. It seems like it is never checked and it could be false and sse could be enabled. in that case we should have failed earlier
Signed-off-by: Adam Tao <[email protected]>
* origin/main: feat: rework sidebar to support canvas (Chainlit#2034) Willy/starter command (Chainlit#2027) Added tags tracing on LangChain tracer (Chainlit#2026) chore: prepare release (Chainlit#2025)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* feat(mcp): Support custom cmd allow list for mcp server Signed-off-by: Adam Tao <[email protected]> * feat(mcp): Support enable/disable sse/stdio mcp * fix: Check config.features.mcp.enabled Signed-off-by: Adam Tao <[email protected]> --------- Signed-off-by: Adam Tao <[email protected]>
* feat(mcp): Support custom cmd allow list for mcp server Signed-off-by: Adam Tao <[email protected]> * feat(mcp): Support enable/disable sse/stdio mcp * fix: Check config.features.mcp.enabled Signed-off-by: Adam Tao <[email protected]> --------- Signed-off-by: Adam Tao <[email protected]>
Some mcp servers are implemented using compiled language (such as go), and can't run via
npx
oruvx
. This PR supports to custom allow list for the commands to run mcp servers.