Build initial MCP SSH server

This commit is contained in:
Vibe Myass
2026-05-24 20:45:12 +00:00
commit a8f7e8f483
28 changed files with 2116 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using System.Text;
namespace McpSsh.Server.Ssh;
public static class RemoteShellCommand
{
public static string Build(string command, string? cwd)
{
if (string.IsNullOrWhiteSpace(cwd))
{
return command;
}
return $"cd {Quote(cwd)} && {command}";
}
public static string Quote(string value)
{
var builder = new StringBuilder(value.Length + 2);
builder.Append('\'');
foreach (var character in value)
{
if (character == '\'')
{
builder.Append("'\\''");
}
else
{
builder.Append(character);
}
}
builder.Append('\'');
return builder.ToString();
}
}