Snail.Sdk.Mcp.Hosting

The public API, generated by Snail.Sdk.Docs from the built assembly and its XML documentation. Do not edit: build with -p:SnailReference=true.

Snail.Sdk.Mcp.Hosting

static class EnvironmentSettings

Maps PREFIX_SECTION__FIELD_NAME variables onto configuration keys Section:FieldName.

Member Summary
IEnumerable<KeyValuePair<string, string?>> Read(string prefix, IDictionary variables) The variables under the prefix as configuration keys; a blank one, and one whose name is only the prefix or leaves a section empty, left out.
string ToConfigurationKey(string variable) A variable's name after the prefix as a configuration key: double underscores nest, single ones vanish.

static class Invocation

The name of the running program that outlives an update of it, for what it writes about itself.

Member Summary
string Stable(string path) A file of this program named the way that outlives an update: through current when it runs from the publication current points at, through the tool's command when it runs from a dotnet tool's store.

static class McpHost

The host a stdio MCP server runs in.

Member Summary
HostApplicationBuilder CreateBuilder(string[] args) An empty host builder that logs from information up to stderr and trims the heap when the server is idle.
ILoggingBuilder UseStderr(this ILoggingBuilder logging) Clears every logger and writes a line to stderr from information up.
IServiceCollection AddIdleTrim(this IServiceCollection services) Compacts the heap once the server has heard no MCP message for five minutes; both hosts call it already.

static class ServerFolders

The folders a server keeps in the user's home under its s3l name: its data and its settings.

Member Summary
string ConfigDirectory(string name) ~/.config/s3l-mcp-<name>, where the server's settings file lives.
string DataDirectory(string name) ~/.s3l-mcp-<name>, where the server keeps its data; name is its short name, such as figma.
void MoveFromSnailNames(string name) The compatibility move from the snail names: renames the server's folders from the snail name to the s3l name and leaves a link at the snail name, when the program is an installed one. It goes in the next major version.

static class ServerIdentity

The name and version a server announces in initialize, read from its assembly so they are written once.

Member Summary
Implementation Of(Assembly server) The name and version of the server built into this assembly.
string NameOf(Assembly server) The server's command, s3l-mcp-<name>; the assembly's name for a server built otherwise.
string VersionOf(Assembly server) The version of the build that is running, without the commit a build may append.

static class ServerSettings

A server's settings: its settings file, then its SNAIL_MCP_<NAME>_ variables, which win.

Member Summary
IConfigurationBuilder AddServerSettings(this IConfigurationBuilder configuration, string name) Adds the server's settings file, when it has one, and then its variables, which win over the file.
IConfigurationBuilder AddServerSettings(this IConfigurationBuilder configuration, string name, string? file, IDictionary variables) Adds the given settings file, when there is one, and then the server's variables among variables.
IConfigurationRoot Read(string name) The server's settings as they stand now: its settings file, then its variables.
IReadOnlyList<string> Candidates(string name) The files looked for, in order; the first that exists is the server's settings file, and a file the variable names is the only one.
string FileVariableOf(string name) The variable that names the settings file outright: SNAIL_MCP_<NAME>_CONFIG.
string PrefixOf(string name) The prefix of the server's variables: SNAIL_MCP_<NAME>_.
string? FileOf(string name) The settings file the server reads, or null when it has none.
string? NameOf(Assembly? server) The server's short name, from the command Snail.Sdk.Mcp writes into its assembly; null for a program built otherwise.

static class ToolJson

The JSON options a server's tools are registered with: the MCP SDK's own, with the server's types put first.

Member Summary
JsonSerializerOptions Options(IJsonTypeInfoResolver context) The SDK's options with this resolver — a server's generated context — consulted first.