Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/developer_mcp_server/src/developer_mcp_server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This module provides different ways to run the MCP server:
- stdio: Standard input/output transport (default for CLI tools)
- http: HTTP/SSE transport using uvicorn (for local development)
- http: StreamableHTTP transport using uvicorn (for local development)
"""

import logging
Expand Down Expand Up @@ -30,25 +30,29 @@ def run_http_with_uvicorn():
"""Run the MCP server over HTTP using uvicorn ASGI server.

This is meant for local development. For production ready setup,
better use gunicorn with uvicorn ASGI workers via ggmcp_http.sse_app:app
better use gunicorn with uvicorn ASGI workers via developer_mcp_server.http_app:http_app
"""
init_sentry()

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

# Use HTTP/SSE transport with uvicorn
# Use StreamableHTTP transport with stateless JSON mode for scalability
import uvicorn

logger.info(f"Starting Developer MCP server on {mcp_host}:{mcp_port}")
uvicorn.run(mcp.sse_app(), host=mcp_host, port=mcp_port)
uvicorn.run(
mcp.http_app(path="/mcp", json_response=True, stateless_http=True),
host=mcp_host,
port=mcp_port,
)


def run_mcp_server():
"""Run the MCP server with transport auto-detection.

If MCP_PORT is set, uses HTTP/SSE transport.
If MCP_PORT is set, uses StreamableHTTP transport.
Otherwise, uses stdio transport (default).
"""
mcp_port = os.environ.get("MCP_PORT")
Expand Down
14 changes: 9 additions & 5 deletions packages/secops_mcp_server/src/secops_mcp_server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This module provides different ways to run the MCP server:
- stdio: Standard input/output transport (default for CLI tools)
- http: HTTP/SSE transport using uvicorn (for local development)
- http: StreamableHTTP transport using uvicorn (for local development)
"""

import logging
Expand Down Expand Up @@ -31,25 +31,29 @@ def run_http_with_uvicorn():
"""Run the MCP server over HTTP using uvicorn ASGI server.

This is meant for local development. For production ready setup,
better use gunicorn with uvicorn ASGI workers via ggmcp_http.sse_app:app
better use gunicorn with uvicorn ASGI workers via secops_mcp_server.http_app:app
"""

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

# Use HTTP/SSE transport with uvicorn
# Use StreamableHTTP transport with stateless JSON mode for scalability
import uvicorn

logger.info(f"Starting SecOps MCP server on {mcp_host}:{mcp_port}")
uvicorn.run(mcp.sse_app(), host=mcp_host, port=mcp_port)
uvicorn.run(
mcp.http_app(path="/mcp", json_response=True, stateless_http=True),
host=mcp_host,
port=mcp_port,
)


def run_mcp_server():
"""Run the MCP server with transport auto-detection.

If MCP_PORT is set, uses HTTP/SSE transport.
If MCP_PORT is set, uses StreamableHTTP transport.
Otherwise, uses stdio transport (default).
"""
mcp_port = os.environ.get("MCP_PORT")
Expand Down
Loading