-
-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Hello,
First off, I'd like to thank you for such a cool MCP library. I figured out how to dynamically instantiate MCP clients, but having some trouble with the server part.
Maybe I misunderstand something in the docs but I can't get an MCP server working as expected. Regardless of the transport, the subprocess just exits and the main process too. Here's my code:
defmodule Exai.RefServer.App do
use Application
def main(args \\ []) do
configpath =
case args do
[fname] -> fname
_ -> Path.join(File.cwd!(), "config.yaml")
end
{:ok, config} = YamlElixir.read_from_file(configpath)
IO.puts("Starting the EXAI reference MCP server...")
tr_obj =
case config["mcp_server"] do
%{"transport" => "stdio"} ->
{Exai.RefServer, transport: :stdio}
%{"transport" => "sse", "port" => port} ->
{Exai.RefServer,
transport: :sse, sse: [port: port, sse_path: "/sse", post_path: "/messages"]}
%{"transport" => "http", "port" => port} ->
{Exai.RefServer, transport: :streamable_http, streamable_http: [port: port]}
_ ->
nil
end
children = [Anubis.Server.Registry, tr_obj]
{:ok, _pid} =
Supervisor.start_link(children, strategy: :one_for_one, name: Exai.RefServer.Supervisor)
end
def start(_type, args) do
main(args)
end
end
where the Exai.RefServer
contains the init and tool definition according to the docs. However, after starting it as a normal application with mix run
, I'm observing the following behavior:
Starting the EXAI reference MCP server...
21:54:57.883 [debug] MCP server event: starting
21:54:57.883 [debug] MCP event details: %{module: Exai.RefServer, capabilities: %{"tools" => %{}}, server_info: %{"name" => "exai-mcp-server", "version" => "1.0.0"}}
21:54:57.883 [debug] MCP transport event: starting
21:54:57.883 [debug] MCP transport details: %{server: Exai.RefServer, transport: :streamable_http}
And then the process just exits with no errors or warnings whatsoever.
Could you please provide a complete example of a server started as an application or point out what I'm missing in terms of starting it?