Model Control Protocol (MCP) allows you to integrate external tool providers with your Chainlit application. This enables your AI models to use tools through standardized interfaces.
Connect to an MCP server
⚠️ Security Warning: The stdio connection type spawns actual subprocesses on the Chainlit server. Only use this with trusted commands in controlled environments. Ensure proper validation of user inputs to prevent command injection vulnerabilities.
npx
or uvx
, these commands must be available on the Chainlit server where the application is running. The subprocess is executed on the server, not on the client machine.config.toml
)config.toml
file (usually located at the root of your project or .chainlit/config.toml
).
Under the [features.mcp]
section, you can configure SSE and stdio separately:
on_mcp_connect
handler. The on_mcp_disconnect
handler is optional but recommended for proper cleanup.
sse
or stdio
)npx your-tool-package
or uvx your-tool-package
)Adding an MCP