MCPServersConfigLoader

org.llm4s.config.MCPServersConfigLoader

Reads the MCP servers an application declares under llm4s.mcp.servers, one section per server, named by its key:

llm4s.mcp.servers {
 playwright { transport = "stdio", command = ["npx", "@playwright/mcp@0.0.86"], timeout = 60s }
 search {
   transport  = "streamable-http"
   url        = "https://mcp.example.com/mcp"
   apiKeyFile = "/run/secrets/search-mcp-key"
 }
}

Each section becomes the org.llm4s.mcp.MCPServerConfig that MCPServerConfig.stdio, .streamableHTTP or .sse builds from the same values. transport is stdio, streamable-http or sse. A stdio section reads command (a list, required), env, workingDirectory and inheritEnvironment; an HTTP one reads url (required), headers, and apiKey or apiKeyFile, sent as Authorization: Bearer. Every section reads timeout (a positive duration, 30 seconds by default), trustAnnotations, onToolChange (report or refuse) and toolPrefix.

Each section is checked on its own and refused with a ConfigurationError naming the section and each field at fault: a key the section does not read, a key of another transport, a missing or empty required field, a value of the wrong type. apiKeyFile is read at load, so a missing file fails here rather than at the first request, and again whenever the file changes. No value of apiKey, headers or env is put in an error, and a loaded config's toString shows none of them. llm4s-mcp's reference.conf declares the block empty.

The Config is loaded as Llm4sConfig.from loads it, as Typesafe Config's load(config) does: system properties override it, every reference.conf sits under it, and its ${?VAR} substitutions are resolved against the process environment. Pass the application's own, as Typesafe Config loads it or a framework hands it over, or one just parsed; one that cannot be resolved fails with a ConfigurationError.

Attributes

Source
MCPServersConfigLoader.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def load(config: Config): Result[Seq[MCPServerConfig]]

Every server under llm4s.mcp.servers, in name order: the order an MCPToolRegistry looks a tool name up in.

Every server under llm4s.mcp.servers, in name order: the order an MCPToolRegistry looks a tool name up in.

Attributes

Returns

the servers (none when the block is absent or empty), or one ConfigurationError naming each invalid section and its fields

Source
MCPServersConfigLoader.scala
def load(config: Config, name: String): Result[MCPServerConfig]

The server in section name of llm4s.mcp.servers, checked on its own: another section's fault does not stop it.

The server in section name of llm4s.mcp.servers, checked on its own: another section's fault does not stop it.

Attributes

Returns

the server, or a ConfigurationError naming its fields at fault, or the configured names when there is no such section

Source
MCPServersConfigLoader.scala

Concrete fields

val Path: String

Where the server sections live.

Where the server sections live.

Attributes

Source
MCPServersConfigLoader.scala