You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Not at all :)
Describe the solution you'd like
I realize this repo is nascent to the extreme and l genuinely appreciate all the work everyone is putting in to make this available to the .NET community. The samples are great and it's awesome you can bootstrap it so quickly from the console but it might be helpful to provide a sample that demonstrates how to best wire up clients for dependency injection. I'm more than happy to submit one if you would like a PR just let me know.
Additional context
I was thinking due to the ephemeral nature of the MCP docker containers something like this...
publicabstractclassDockerMcpServiceBase{privatereadonlyTask<IMcpClient>_clientTask;protectedDockerMcpServiceBase(stringcontainer,string[]?flags=null,Dictionary<string,string>?environmentVariables=null,IReadOnlyDictionary<string,string>?parameters=null){// Build the arguments arrayvarargs=newList<string>();if(flagsis{Length:>0})args.AddRange(flags);if(environmentVariablesis{Count:>0})foreach(var(key, _)inenvironmentVariables){args.Add("-e");args.Add(key);}args.Add(container);if(parametersis{Count:>0})foreach(var(key,value)inparameters)args.Add($"--{key}={value}");_clientTask=McpClientFactory.CreateAsync(newStdioClientTransport(new(){Name=container.Split('/')[1],Command="docker",Arguments=["run","-i","--rm", .. args],EnvironmentVariables=environmentVariables??[]}));}publicasyncTask<IEnumerable<McpClientTool>>GetToolsAsync(string[]?toolsToInclude=null,CancellationTokencancellationToken=default){varclient=await_clientTask;vartools=awaitclient.ListToolsAsync(cancellationToken:cancellationToken);returntoolsToIncludeis{Length:>0}?tools.Where(t =>toolsToInclude.Contains(t.Name)):tools;}}publicclassAtlassianMcpService(IConfigurationconfiguration):DockerMcpServiceBase("mcp/atlassian",parameters:newDictionary<string,string>{["confluence-url"]=$"{configuration[Secrets.AtlassianServer]??thrownewInvalidOperationException($"{Secrets.AtlassianServer} is not set")}wiki",["confluence-username"]=configuration[Secrets.AtlassianEmail]??thrownewInvalidOperationException($"{Secrets.AtlassianEmail} is not set"),["confluence-token"]=configuration[Secrets.AtlassianToken]??thrownewInvalidOperationException($"{Secrets.AtlassianToken} is not set"),["jira-url"]=configuration[Secrets.AtlassianServer]??thrownewInvalidOperationException($"{Secrets.AtlassianServer} is not set"),["jira-username"]=configuration[Secrets.AtlassianEmail]??thrownewInvalidOperationException($"{Secrets.AtlassianEmail} is not set"),["jira-token"]=configuration[Secrets.AtlassianToken]??thrownewInvalidOperationException($"{Secrets.AtlassianToken} is not set")});
public class BraveSearchMcpService(IConfigurationconfiguration):DockerMcpServiceBase("mcp/brave-search",environmentVariables:newDictionary<string,string>{["BRAVE_API_KEY"]=configuration[Secrets.BraveSearchToken]??thrownewInvalidOperationException($"{Secrets.BraveSearchToken} is not set")});
public class FetchMcpService():DockerMcpServiceBase("mcp/fetch");
public class GitHubMcpService(IConfigurationconfiguration):DockerMcpServiceBase("mcp/github",environmentVariables:newDictionary<string,string>{["GITHUB_PERSONAL_ACCESS_TOKEN"]=configuration[Secrets.GitHubToken]??thrownewInvalidOperationException($"{Secrets.GitHubToken} is not set")});
public class GoogleMapsMcpService(IConfigurationconfiguration):DockerMcpServiceBase("mcp/google-maps",environmentVariables:newDictionary<string,string>{["GOOGLE_MAPS_API_KEY"]=configuration[Secrets.GoogleMapsToken]??thrownewInvalidOperationException($"{Secrets.GoogleMapsToken} is not set")});
public class MemoryMcpService():DockerMcpServiceBase("mcp/memory");
public class PuppeteerMcpService():DockerMcpServiceBase("mcp/puppeteer",["--init"],newDictionary<string,string>{["DOCKER_CONTAINER"]="true"});
public class SequentialThinkingMcpService():DockerMcpServiceBase("mcp/sequentialthinking");
public class TimeMcpService():DockerMcpServiceBase("mcp/time");
Then it's simply wire up a singleton to the service collection and off you go.
The text was updated successfully, but these errors were encountered:
A good sample for how to configure a client to use docker-based servers would indeed be good. It's an overlooked aspect of the MCP ecosystem in general (not just for this SDK).
Is your feature request related to a problem? Please describe.
Not at all :)
Describe the solution you'd like
I realize this repo is nascent to the extreme and l genuinely appreciate all the work everyone is putting in to make this available to the .NET community. The samples are great and it's awesome you can bootstrap it so quickly from the console but it might be helpful to provide a sample that demonstrates how to best wire up clients for dependency injection. I'm more than happy to submit one if you would like a PR just let me know.
Additional context
I was thinking due to the ephemeral nature of the MCP docker containers something like this...
Then it's simply wire up a singleton to the service collection and off you go.
The text was updated successfully, but these errors were encountered: