Learn how to connect CrewAI to remote MCP servers using Server-Sent Events (SSE) for real-time communication.
MCPServerAdapter
Configuration: For SSE, you’ll provide the server’s URL and specify the transport type.with
statement) is the recommended approach. It automatically handles establishing and closing the connection to the SSE MCP server.
"http://localhost:8000/sse"
with the actual URL of your SSE MCP server.MCPServerAdapter
connection lifecycle manually.
mcp_server_adapter.stop()
to ensure the connection is closed and resources are released. Using a try...finally
block is highly recommended.Origin
headers on incoming SSE connections.localhost
(127.0.0.1
) rather than all network interfaces (0.0.0.0
).