-
Notifications
You must be signed in to change notification settings - Fork 359
Remove McpServerConfig
and have McpClientFactory
accept IClientTransport
instances directly.
#230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eiriktsarpalis
merged 5 commits into
modelcontextprotocol:main
from
eiriktsarpalis:rework-client
Apr 8, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
14b184e
Remove McpServerConfig and have McpClientFactory accept IClientTransp…
eiriktsarpalis b2e290f
Address feedback and use lists when representing stdio arguments.
eiriktsarpalis 7a1279e
Use "Name" for transport descriptors and "EndpointName" for MCP clien…
eiriktsarpalis 9a9ba5b
Update code samples.
eiriktsarpalis cbd9216
Fix source file naming
eiriktsarpalis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// Copied from: | ||
// https://github.com/dotnet/runtime/blob/d2650b6ae7023a2d9d2c74c56116f1f18472ab04/src/libraries/System.Private.CoreLib/src/System/PasteArguments.cs | ||
// and changed from using ValueStringBuilder to StringBuilder. | ||
|
||
using System.Text; | ||
|
||
namespace System; | ||
|
||
internal static partial class PasteArguments | ||
{ | ||
internal static void AppendArgument(StringBuilder stringBuilder, string argument) | ||
{ | ||
if (stringBuilder.Length != 0) | ||
{ | ||
stringBuilder.Append(' '); | ||
} | ||
|
||
// Parsing rules for non-argv[0] arguments: | ||
// - Backslash is a normal character except followed by a quote. | ||
// - 2N backslashes followed by a quote ==> N literal backslashes followed by unescaped quote | ||
// - 2N+1 backslashes followed by a quote ==> N literal backslashes followed by a literal quote | ||
// - Parsing stops at first whitespace outside of quoted region. | ||
// - (post 2008 rule): A closing quote followed by another quote ==> literal quote, and parsing remains in quoting mode. | ||
if (argument.Length != 0 && ContainsNoWhitespaceOrQuotes(argument)) | ||
{ | ||
// Simple case - no quoting or changes needed. | ||
stringBuilder.Append(argument); | ||
} | ||
else | ||
{ | ||
stringBuilder.Append(Quote); | ||
int idx = 0; | ||
while (idx < argument.Length) | ||
{ | ||
char c = argument[idx++]; | ||
if (c == Backslash) | ||
{ | ||
int numBackSlash = 1; | ||
while (idx < argument.Length && argument[idx] == Backslash) | ||
{ | ||
idx++; | ||
numBackSlash++; | ||
} | ||
|
||
if (idx == argument.Length) | ||
{ | ||
// We'll emit an end quote after this so must double the number of backslashes. | ||
stringBuilder.Append(Backslash, numBackSlash * 2); | ||
} | ||
else if (argument[idx] == Quote) | ||
{ | ||
// Backslashes will be followed by a quote. Must double the number of backslashes. | ||
stringBuilder.Append(Backslash, numBackSlash * 2 + 1); | ||
stringBuilder.Append(Quote); | ||
idx++; | ||
} | ||
else | ||
{ | ||
// Backslash will not be followed by a quote, so emit as normal characters. | ||
stringBuilder.Append(Backslash, numBackSlash); | ||
} | ||
|
||
continue; | ||
} | ||
|
||
if (c == Quote) | ||
{ | ||
// Escape the quote so it appears as a literal. This also guarantees that we won't end up generating a closing quote followed | ||
// by another quote (which parses differently pre-2008 vs. post-2008.) | ||
stringBuilder.Append(Backslash); | ||
stringBuilder.Append(Quote); | ||
continue; | ||
} | ||
|
||
stringBuilder.Append(c); | ||
} | ||
|
||
stringBuilder.Append(Quote); | ||
} | ||
} | ||
|
||
private static bool ContainsNoWhitespaceOrQuotes(string s) | ||
{ | ||
for (int i = 0; i < s.Length; i++) | ||
{ | ||
char c = s[i]; | ||
if (char.IsWhiteSpace(c) || c == Quote) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private const char Quote = '\"'; | ||
private const char Backslash = '\\'; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.