Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/test/mcp/http/server_sse.py
3434 views
1
from typing import Any, Dict
2
import time
3
from fastmcp import FastMCP
4
5
mcp = FastMCP("EchoSSEServer")
6
7
@mcp.tool
8
def echo(payload: Dict[str, Any]) -> Dict[str, Any]:
9
# Slow it down a bit so it feels “streamy” even if it’s a single SSE event
10
time.sleep(0.25)
11
return {
12
"content": [
13
{"type": "text", "text": f"payload={payload!r}"}
14
]
15
}
16
17
if __name__ == "__main__":
18
# Exposes http://127.0.0.1:8000/mcp
19
mcp.run(transport="http", host="127.0.0.1", port=8000)
20
21