Mead.MCP.Server (mead v0.1.1)

Copy Markdown View Source

The server side of MCP: an HTTP listener that lets a client with the configured token drive sessions as tools (see Mead.MCP.Server.Tools). The last child of the root supervisor.

Configured by config :mead, :mcp_server (see Mead.MCP.Server.Configuration). Without a :token it starts nothing and logs one info line, so a runtime that was never set up for it opens no port. An invalid setting stops the application at boot with a message that names the setting and never contains the token.

The listener is a Bandit instance running Mead.Gateway, which serves Mead.MCP.Server.Plug when :mcp_server has a token and Mead.Deck.Plug when :deck has one (the deck reuses the :allowed_origins of :mcp_server), and starts when either does. It is supervised :one_for_one, so a listener that dies is started again without touching the hub or the sessions. A port that is already taken stops the start, loudly, as any other boot error.

Tests start their own server with :settings, :deck_settings (replacing the application environment) and :deck_options (extra options for Mead.Deck.Plug, such as the session handler).

Summary

Functions

Returns a specification to start this module under a supervisor.

The port the listener is bound to, which is what a test that asked for port 0 needs to know. :error when the server has no listener or is not running.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

port(server \\ __MODULE__)

@spec port(Supervisor.supervisor()) :: {:ok, :inet.port_number()} | :error

The port the listener is bound to, which is what a test that asked for port 0 needs to know. :error when the server has no listener or is not running.

start_link(options \\ [])

@spec start_link(keyword()) :: Supervisor.on_start()