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
- Self type
