Files
nexus/wiki/entities/SSE.md
2026-04-27 08:02:55 +08:00

46 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "SSE (Server-Sent Events)"
type: entity
tags: [web, real-time, http, mcp]
sources: [mcp在cursor中的集成与应用详解]
last_updated: 2026-04-26
---
## Definition
SSEServer-Sent Events服务器推送事件是一种基于 HTTP 的**服务器向客户端推送实时事件**的技术,允许服务器主动向浏览器或客户端应用发送数据更新。
## In MCP Context
在 MCPModal Context Protocol集成中SSE 是两种接入方式之一:
- **SSE 方式**:通过 HTTP SSE 连接远程 MCP Server
- **Command 方式**:通过本地执行命令连接 MCP Server
SSE 方式适用于:
- 部署在远程服务器上的 MCP Server
- 需要集中管理多个 MCP Server 的场景
- 服务端支持 SSE 协议输出的 MCP Server
## Key Characteristics
- **单向通信**:仅服务器向客户端推送,客户端不能反向通信(需用 HTTP 请求)
- **基于 HTTP**:使用标准 HTTP 协议,易于穿过防火墙
- **自动重连**:浏览器端 SSE API 自动处理连接断开重连
- **文本协议**:使用文本格式传输数据(通常为 JSON
## Comparison
| 特性 | SSE | WebSocket |
|------|-----|----------|
| 通信方向 | 单向(服务端→客户端) | 双向 |
| 协议 | HTTP | 独立协议 |
| 复杂度 | 简单 | 较复杂 |
| HTTP/2 多路复用 | 支持 | 支持 |
| 防火墙穿透 | 易 | 需特殊配置 |
## Connections
- [[McpServer]] ← SSE 协议是 MCP Server 的一种接入方式
- [[ModalContextProtocol]] ← 所属协议生态
- [[Mcp在Cursor中的集成与应用详解]] ← 使用场景
## See Also
- [[ModalContextProtocol]]
- [[McpServer]]