Skip to content

Commit c9be6f8

Browse files
committed
feat(http): Make the usual commands use HTTP instead of SSE when used with MCP_PORT
Issue: APPAI-150
1 parent 3ab597f commit c9be6f8

File tree

2 files changed

+18
-10
lines changed
  • packages
    • developer_mcp_server/src/developer_mcp_server
    • secops_mcp_server/src/secops_mcp_server

2 files changed

+18
-10
lines changed

packages/developer_mcp_server/src/developer_mcp_server/run.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
This module provides different ways to run the MCP server:
44
- stdio: Standard input/output transport (default for CLI tools)
5-
- http: HTTP/SSE transport using uvicorn (for local development)
5+
- http: StreamableHTTP transport using uvicorn (for local development)
66
"""
77

88
import logging
@@ -30,25 +30,29 @@ def run_http_with_uvicorn():
3030
"""Run the MCP server over HTTP using uvicorn ASGI server.
3131
3232
This is meant for local development. For production ready setup,
33-
better use gunicorn with uvicorn ASGI workers via ggmcp_http.sse_app:app
33+
better use gunicorn with uvicorn ASGI workers via developer_mcp_server.http_app:http_app
3434
"""
3535
init_sentry()
3636

3737
# Get host and port from environment variables
3838
mcp_port = int(os.environ.get("MCP_PORT", "8000"))
3939
mcp_host = os.environ.get("MCP_HOST", "127.0.0.1")
4040

41-
# Use HTTP/SSE transport with uvicorn
41+
# Use StreamableHTTP transport with stateless JSON mode for scalability
4242
import uvicorn
4343

4444
logger.info(f"Starting Developer MCP server on {mcp_host}:{mcp_port}")
45-
uvicorn.run(mcp.sse_app(), host=mcp_host, port=mcp_port)
45+
uvicorn.run(
46+
mcp.http_app(path="/mcp", json_response=True, stateless_http=True),
47+
host=mcp_host,
48+
port=mcp_port,
49+
)
4650

4751

4852
def run_mcp_server():
4953
"""Run the MCP server with transport auto-detection.
5054
51-
If MCP_PORT is set, uses HTTP/SSE transport.
55+
If MCP_PORT is set, uses StreamableHTTP transport.
5256
Otherwise, uses stdio transport (default).
5357
"""
5458
mcp_port = os.environ.get("MCP_PORT")

packages/secops_mcp_server/src/secops_mcp_server/run.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
This module provides different ways to run the MCP server:
44
- stdio: Standard input/output transport (default for CLI tools)
5-
- http: HTTP/SSE transport using uvicorn (for local development)
5+
- http: StreamableHTTP transport using uvicorn (for local development)
66
"""
77

88
import logging
@@ -31,25 +31,29 @@ def run_http_with_uvicorn():
3131
"""Run the MCP server over HTTP using uvicorn ASGI server.
3232
3333
This is meant for local development. For production ready setup,
34-
better use gunicorn with uvicorn ASGI workers via ggmcp_http.sse_app:app
34+
better use gunicorn with uvicorn ASGI workers via secops_mcp_server.http_app:app
3535
"""
3636

3737
init_sentry()
3838
# Get host and port from environment variables
3939
mcp_port = int(os.environ.get("MCP_PORT", "8000"))
4040
mcp_host = os.environ.get("MCP_HOST", "127.0.0.1")
4141

42-
# Use HTTP/SSE transport with uvicorn
42+
# Use StreamableHTTP transport with stateless JSON mode for scalability
4343
import uvicorn
4444

4545
logger.info(f"Starting SecOps MCP server on {mcp_host}:{mcp_port}")
46-
uvicorn.run(mcp.sse_app(), host=mcp_host, port=mcp_port)
46+
uvicorn.run(
47+
mcp.http_app(path="/mcp", json_response=True, stateless_http=True),
48+
host=mcp_host,
49+
port=mcp_port,
50+
)
4751

4852

4953
def run_mcp_server():
5054
"""Run the MCP server with transport auto-detection.
5155
52-
If MCP_PORT is set, uses HTTP/SSE transport.
56+
If MCP_PORT is set, uses StreamableHTTP transport.
5357
Otherwise, uses stdio transport (default).
5458
"""
5559
mcp_port = os.environ.get("MCP_PORT")

0 commit comments

Comments
 (0)