Skip to content

Commit 93981b9

Browse files
committed
feat(hosting): Offer classic stateless HTTP mode
Issue: APPAI-150
1 parent e45264c commit 93981b9

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""ASGI application for MCP server over StreamableHTTP.
2+
3+
This module exports the ASGI application for use with ASGI servers like gunicorn + uvicorn.
4+
It imports the configured MCP server and exposes its StreamableHTTP application.
5+
"""
6+
7+
from fastmcp.server.http import create_streamable_http_app
8+
9+
from developer_mcp_server.server import mcp
10+
11+
# Note: We use StreamableHTTP with json_response=True and stateless_http=True to enable
12+
# fully stateless operation. This allows horizontal scaling without sticky sessions
13+
# since no session state is maintained between requests.
14+
http_app = create_streamable_http_app(
15+
server=mcp,
16+
streamable_http_path="/mcp",
17+
json_response=True,
18+
stateless_http=True,
19+
)

packages/developer_mcp_server/src/developer_mcp_server/sse_app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""ASGI application for MCP server over HTTP/SSE.
2+
3+
Note: This SSE transport requires sticky sessions for horizontal scaling since
4+
session state is maintained in-memory per worker. For stateless operation,
5+
use http_app.py instead which uses StreamableHTTP with JSON responses.
6+
"""
7+
18
from fastmcp.server.http import create_sse_app
29

310
from developer_mcp_server.server import mcp
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""ASGI application for MCP server over StreamableHTTP.
2+
3+
This module exports the ASGI application for use with ASGI servers like gunicorn + uvicorn.
4+
It imports the configured MCP server and exposes its StreamableHTTP application.
5+
6+
This module is specifically for production deployment with gunicorn.
7+
For local development, use the run_http_with_uvicorn() function instead.
8+
9+
10+
"""
11+
12+
import logging
13+
14+
from fastmcp.server.http import create_streamable_http_app
15+
from gg_api_core.sentry_integration import init_sentry
16+
17+
from secops_mcp_server.server import mcp
18+
19+
logger = logging.getLogger(__name__)
20+
21+
# Initialize Sentry for production deployment
22+
init_sentry()
23+
24+
# Note: We use StreamableHTTP with json_response=True and stateless_http=True to enable
25+
# fully stateless operation. This allows horizontal scaling without sticky sessions
26+
# since no session state is maintained between requests.
27+
app = create_streamable_http_app(
28+
server=mcp,
29+
streamable_http_path="/mcp",
30+
json_response=True,
31+
stateless_http=True,
32+
)
33+
34+
logger.info("MCP application initialized for StreamableHTTP transport (stateless JSON mode)")

packages/secops_mcp_server/src/secops_mcp_server/sse_app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
66
This module is specifically for production deployment with gunicorn.
77
For local development, use the run_http_with_uvicorn() function instead.
8+
9+
Note: This SSE transport requires sticky sessions for horizontal scaling since
10+
session state is maintained in-memory per worker. For stateless operation,
11+
use http_app.py instead which uses StreamableHTTP with JSON responses.
812
"""
913

1014
import logging

0 commit comments

Comments
 (0)