mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 22:21:09 +08:00
Compare commits
3 Commits
codex/crea
...
codex/crea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57e08bdd6f | ||
|
|
393afeda95 | ||
|
|
f72d5e7ba9 |
@@ -221,14 +221,12 @@ services:
|
||||
env_file:
|
||||
- ${ENV_FILE:-../.env}
|
||||
environment:
|
||||
FASTMCP_HOST: 0.0.0.0
|
||||
FASTMCP_PORT: ${MCP_PORT:-8765}
|
||||
OPENISLE_BACKEND_URL: ${OPENISLE_BACKEND_URL:-http://springboot:8080}
|
||||
OPENISLE_BACKEND_TIMEOUT: ${OPENISLE_BACKEND_TIMEOUT:-10}
|
||||
OPENISLE_MCP_TRANSPORT: ${OPENISLE_MCP_TRANSPORT:-sse}
|
||||
OPENISLE_MCP_SSE_MOUNT_PATH: ${OPENISLE_MCP_SSE_MOUNT_PATH:-/mcp}
|
||||
ports:
|
||||
- "${MCP_PORT:-8765}:${MCP_PORT:-8765}"
|
||||
- "${MCP_PORT:-8765}:8000"
|
||||
depends_on:
|
||||
springboot:
|
||||
condition: service_healthy
|
||||
|
||||
@@ -29,8 +29,6 @@ Environment variables:
|
||||
| `OPENISLE_PUBLIC_BASE_URL` | Optional base URL used to build deep links in search results | *(unset)* |
|
||||
| `OPENISLE_MCP_TRANSPORT` | MCP transport (`stdio`, `sse`, `streamable-http`) | `stdio` |
|
||||
| `OPENISLE_MCP_SSE_MOUNT_PATH` | Mount path when using SSE transport | `/mcp` |
|
||||
| `FASTMCP_HOST` | Host for SSE / HTTP transports | `127.0.0.1` |
|
||||
| `FASTMCP_PORT` | Port for SSE / HTTP transports | `8000` |
|
||||
|
||||
## Docker
|
||||
|
||||
|
||||
@@ -150,6 +150,17 @@ def main() -> None:
|
||||
default=_env("OPENISLE_MCP_SSE_MOUNT_PATH", "/mcp"),
|
||||
help="Mount path when using the SSE transport",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--host",
|
||||
default=_env("OPENISLE_MCP_HOST", "0.0.0.0"),
|
||||
help="Host to bind when using SSE or Streamable HTTP",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--port",
|
||||
type=int,
|
||||
default=int(_env("OPENISLE_MCP_PORT", "8000")),
|
||||
help="Port to bind when using SSE or Streamable HTTP",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=os.getenv("OPENISLE_MCP_LOG_LEVEL", "INFO"))
|
||||
@@ -157,8 +168,21 @@ def main() -> None:
|
||||
"Starting OpenIsle MCP server", extra={"transport": args.transport, "backend": _BACKEND_CLIENT.base_url}
|
||||
)
|
||||
|
||||
server.run(transport=args.transport, mount_path=args.mount_path)
|
||||
if args.transport == "stdio":
|
||||
# stdio 模式照旧
|
||||
server.run(transport="stdio")
|
||||
return
|
||||
|
||||
# SSE / Streamable HTTP:手动跑 uvicorn,显式控制 host/port
|
||||
import uvicorn
|
||||
if args.transport == "sse":
|
||||
app = server.sse_app(args.mount_path)
|
||||
elif args.transport == "streamable-http":
|
||||
app = server.streamable_http_app()
|
||||
else:
|
||||
raise RuntimeError(f"Unsupported transport: {args.transport}")
|
||||
|
||||
uvicorn.run(app, host=args.host, port=args.port)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user