DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Classes / MCPServerSSE
Class mcp

MCPServerSSE: Reference Guide

By DevShelfHub

Connect to a remote MCP server over Server-Sent Events.

See the CrewAI API reference index, CrewAI introduction, and core concepts for surrounding context.

What is MCPServerSSE?

MCPServerSSE targets MCP deployments that expose the older Server-Sent Events surface instead of the newer streamable HTTP transport. The client opens an HTTP connection, reads a long-lived text/event-stream, and multiplexes MCP messages over that channel. SSE fits environments where intermediaries understand one-way streaming better than full-duplex WebSockets but still need remote access beyond localhost stdio.

Compared with MCPServerHTTP, SSE often incurs higher baseline latency for bidirectional tool chatter because replies may need complementary HTTP posts depending on server implementation. Proxies may buffer events unless you explicitly disable caching and set appropriate Accept headers — always verify timeouts align with long-running agent sessions.

Prefer MCPServerHTTP when the vendor supports it; keep MCPServerSSE for compatibility with existing gateways or air-gapped stacks where operations standardized on SSE first.

When to Use

Remote MCP servers without HTTP-streaming support.

Use Cases

  • • Legacy remote servers
  • • SSE-only partner gateways
  • • HTTP streaming blocked by policy
  • • EventSource-friendly stacks

Key Features

  • ✓ SSE transport
  • ✓ Auth via headers
  • ✓ Compatible with reverse proxies
  • ✓ Works when HTTP streaming is unavailable

When NOT to Use

When the server supports streamable HTTP — prefer MCPServerHTTP.

Notes

Proxy buffering

Some HTTP proxies buffer SSE until a threshold flushes. If tools appear minutes late, test with curl --no-buffer and adjust proxy rules or move to MCPServerHTTP.

Idle timeouts

Load balancers often default to 60s idle cuts. Coordinate keep-alive settings with whoever owns the ingress or wrap the remote server with a local stdio shim.

Security headers

Treat MCP endpoints like admin APIs: TLS only, short-lived tokens, and explicit tool filters on MCPServerAdapter before exposing agents to production data.

Import

python
from crewai.mcp import MCPServerSSE

Key Parameters

Parameter Type Default Purpose
url str — SSE endpoint URL.

Code Examples

Basic remote URL

python
from crewai.mcp import MCPServerSSE

server = MCPServerSSE(url='https://mcp.internal.example/sse')

Auth headers for private gateways

python
server = MCPServerSSE(
    url='https://mcp.internal.example/sse',
    headers={'Authorization': 'Bearer ' + os.environ['MCP_TOKEN']},
)

Behind corporate proxies

python
# Ensure HTTP_PROXY/HTTPS_PROXY env vars are set for the Python process,
# or route through an MCP sidecar that speaks stdio locally.
server = MCPServerSSE(url='https://mcp.partner.example/events')

Common Mistakes

❌ Pointing SSE at a plain REST JSON URL

✅ Confirm the upstream actually implements MCP over SSE; mismatched content types fail with opaque parser errors.

MCPServerSSE FAQ

What is MCPServerSSE in CrewAI?

Connect to a remote MCP server over Server-Sent Events. MCPServerSSE targets MCP deployments that expose the older Server-Sent Events surface instead of the newer streamable HTTP transport. The client opens an HTTP connection, reads a long-lived text/event-stream, and multiplexes MCP messages over that channel. SSE fits environments where intermediaries understand one-way streaming better than full-duplex WebSockets but still need remote access beyond localhost stdio. Compared with MCPServerHTTP, SSE often incurs higher baseline …

Which package defines the CrewAI class MCPServerSSE?

DevShelfHub maps MCPServerSSE to Python module crewai.mcp (package path crewai.mcp in this reference). Pin your installed crewai version and match imports to the snippet on this page.

When should I use MCPServerSSE?

Remote MCP servers without HTTP-streaming support.

When should I avoid using MCPServerSSE?

When the server supports streamable HTTP — prefer MCPServerHTTP.

How do I import MCPServerSSE in Python?

from crewai.mcp import MCPServerSSE

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.