Files
nexus/wiki/concepts/SSE-Server-Sent-Events.md
2026-04-22 16:03:25 +08:00

44 lines
1.5 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: "SSEServer-Sent Events"
type: concept
tags: [web, realtime, mcp, protocol]
sources: []
last_updated: 2026-04-22
---
## Overview
SSEServer-Sent Events服务器推送事件是一种服务器向客户端推送实时事件的技术标准。在 MCP 协议中SSE 作为一种接入方式,用于建立 MCP Client 与 MCP Server 之间的实时通信通道。
## Aliases
- Server-Sent Events
- 服务端推送事件
- HTML5 Server-Sent Events
## Key Characteristics
- **单向通信**:服务器主动向客户端推送数据,客户端无需轮询
- **基于 HTTP**:使用标准 HTTP 协议,兼容性好
- **自动重连**:浏览器端自动处理连接断开和重连
- **MCP 接入方式**:作为 MCP Server 的一种连接方式(另一种是 Command 命令行)
## SSE vs WebSocket
| 特性 | SSE | WebSocket |
|------|-----|-----------|
| 通信方向 | 单向Server→Client | 双向 |
| 协议 | HTTP | ws/wss |
| 自动重连 | 原生支持 | 需手动实现 |
| 二进制数据 | 不支持 | 支持 |
| HTTP/2 多路复用 | 支持 | 支持 |
| 复杂度 | 简单 | 较复杂 |
## Usage in MCP Context
- **适用场景**:在线 MCP 服务的远程连接
- **配置方式**:在 Cursor MCP 设置中填写 SSE 服务 URL
- **替代方案**:本地 Command 命令行方式(适合本地 MCP 服务)
## Connections
- [[MCPModel Context Protocol]] — SSE 作为 MCP 的一种接入传输层
- [[Cursor]] — Cursor MCP 设置中支持 SSE 方式配置
## Sources
- [[mcp在cursor中的集成与应用详解]]