#!/usr/bin/env julia # --------------------------------------------------------------------------- # JuliaMSI MCP server entry point. # # julia --project=/path/to/JuliaMSI_MCP --threads=auto bin/run_server.jl # julia --project=/path/to/JuliaMSI_MCP --threads=auto bin/run_server.jl --http --port 3000 # --------------------------------------------------------------------------- using JuliaMSI_MCP function usage() println(stderr, """ JuliaMSI MCP server $(JuliaMSI_MCP.SERVER_VERSION) Usage: julia --project= --threads=auto bin/run_server.jl [options] Options: --http Serve MCP over Streamable HTTP instead of stdio --host Bind address for --http (default 127.0.0.1) --port Port for --http (default 3000) --token Require `Authorization: Bearer ` (HTTP only; also JULIA_MSI_MCP_TOKEN) --version Print the version and exit -h, --help Show this help """) end function main(args) http = false host = "127.0.0.1" port = 3000 token = nothing i = 1 while i <= length(args) a = args[i] if a == "--http" http = true elseif a == "--host" i += 1 i <= length(args) || (usage(); return 2) host = args[i] elseif a == "--port" i += 1 i <= length(args) || (usage(); return 2) port = try parse(Int, args[i]) catch println(stderr, "Invalid --port value: $(args[i])") return 2 end elseif a == "--token" i += 1 i <= length(args) || (usage(); return 2) token = args[i] elseif a == "--version" println(JuliaMSI_MCP.SERVER_VERSION) return 0 elseif a in ("-h", "--help") usage() return 0 else println(stderr, "Unknown argument: $(a)") usage() return 2 end i += 1 end if http run_http(host=host, port=port, token=token) else run_stdio() end return 0 end exit(main(ARGS))