Skip to content

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

Merged
merged 5 commits into from
Mar 22, 2025

Conversation

tcx4c70
Copy link
Contributor

@tcx4c70 tcx4c70 commented Mar 17, 2025

Some mcp servers are implemented using compiled language (such as go), and can't run via npx or uvx. This PR supports to custom allow list for the commands to run mcp servers.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. backend Pertains to the Python backend. enhancement New feature or request labels Mar 17, 2025
@tcx4c70 tcx4c70 force-pushed the feat/mcp-allow-list branch from d3df12a to a23e340 Compare March 18, 2025 01:58
Copy link
Collaborator

@willydouhard willydouhard left a 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

@@ -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
Copy link
Collaborator

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

@@ -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 [
Copy link
Collaborator

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

@dataclass
class MCPFeature(DataClassJsonMixin):
enabled: bool = False
stdio_executable_allow_list: Optional[list[str]] = None
Copy link
Collaborator

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

Copy link
Collaborator

@willydouhard willydouhard left a 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:
Copy link
Collaborator

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

tcx4c70 added 2 commits March 21, 2025 08:37
* 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)
Copy link
Collaborator

@willydouhard willydouhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@willydouhard willydouhard added this pull request to the merge queue Mar 22, 2025
Merged via the queue into Chainlit:main with commit 78a4a3f Mar 22, 2025
8 checks passed
notlaedri pushed a commit to notlaedri/chainlit that referenced this pull request May 5, 2025
* 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]>
hazemHany09 pushed a commit to InfomineoGithub/chainlit that referenced this pull request May 7, 2025
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Pertains to the Python backend. enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants