Skip to content

Passing arguments to my console application #166

Answered by anuraj
martinmoose asked this question in Q&A
Discussion options

You must be logged in to vote

I think better option is env element than arguments. So, in the client code, you can do something like this

var client = await McpClientFactory.CreateAsync(new()
{
    Id = "everything",
    Name = "Everything",
    TransportType = TransportTypes.StdIo,
    TransportOptions = new()
    {
        ["command"] = "dotnet",
        ["arguments"] = @"EveryThingServer.dll",
        ["env:TOKEN"] = "THIS IS THE TOKEN FROM CLIENT"
    }
}, new()
{
    ClientInfo = new()
    {
        Name = "Everything Client",
        Version = "1.0.0",
    }
});

And in Server you will be able to access it via Environment methods, like this.

var token = Environment.GetEnvironmentVariable("TOKEN");

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PederHP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #87 on March 31, 2025 19:06.