A standard MCP (Model Context Protocol) CLI execution server built on ModelContextProtocol SDK + CliWrap.
Executes one or more CLI commands via CliWrap's native pipe API. Supports single commands, command pipelines (using |), and batch sequential execution.
⚠️ Does NOT support interactive processes (ssh, REPL, vim, less, top, etc.). Those require a PTY.
# Clone the repository
git clone https://github.com/Axvser/SharpCliMcp.git
cd SharpCliMcp
# Restore dependencies
dotnet restore
# Publish to a custom MCP installation path (for VeloxDev McpScope)
dotnet publish -c Release -o /path/to/your/.evn/mcp/dotnet/sharp-cli-mcpPublished layout:
/path/to/your/.evn/mcp/dotnet/sharp-cli-mcp/
├── SharpCliMcp.dll
├── SharpCliMcp.runtimeconfig.json
├── CliWrap.dll
├── ModelContextProtocol.dll
└── ...
Execute one or more CLI commands. Supports pipes (|) for native command chaining.
| Parameter | Type | Required | Description |
|---|---|---|---|
commands |
string[] |
✅ | Commands to execute |
workingDirectory |
string? |
❌ | Working directory for all commands |
timeoutMs |
int? |
❌ | Timeout in milliseconds |
Locate an executable on the system PATH.
| Parameter | Type | Required | Description |
|---|---|---|---|
command |
string |
✅ | Executable name (e.g. "dotnet", "git") |
using ModelContextProtocol.Client;
using ModelContextProtocol.Transport;
await using var client = await McpClient.CreateAsync(
new StdioClientTransport(new()
{
Command = "dotnet",
Arguments = ["run", "--project", @"E:\Projects\SharpCliMcp", "--no-build"],
}),
new McpClientOptions { ClientInfo = new() { Name = "MyApp", Version = "1.0.0" } }
);
// Single command
await client.CallToolAsync("execute_command", new()
{
["commands"] = new[] { "dotnet --version" }
});
// Pipeline: chain commands with |
await client.CallToolAsync("execute_command", new()
{
["commands"] = new[] { "dir | findstr .cs | sort" }
});
// Batch: sequential execution
await client.CallToolAsync("execute_command", new()
{
["commands"] = new[]
{
"git status",
"git log --oneline -3"
}
});
// Check if a tool exists
await client.CallToolAsync("which", new()
{
["command"] = "python"
});Prerequisite: Publish to the McpScope installation directory:
dotnet publish -c Release -o .evn/mcp/dotnet/sharp-cli-mcpConfiguration & invocation:
using Microsoft.Extensions.AI;
using VeloxDev.AI.MCP;
var scope = new McpScope();
var tools = await scope.LoadAsync([
new McpServerConfiguration
{
Name = "CLI Tools",
RunMode = McpServerRunMode.Dotnet,
Package = "sharp-cli-mcp/SharpCliMcp.dll",
}
]);
var execute = (AIFunction)tools.First(t => t.Name == "execute_command");
// Run a single command
var result = await execute.InvokeAsync(new AIFunctionArguments
{
["commands"] = new[] { "dotnet --version" },
});
Console.WriteLine(result);SharpCliMcp/
├── SharpCliMcp.csproj ← Dependencies: CliWrap + ModelContextProtocol
├── Program.cs ← Entry point with MCP server setup
├── Tools/
│ └── CliTool.cs ← [McpServerToolType] execute_command + which
└── README.md