Compare commits
2 Commits
main
...
e290e7e500
| Author | SHA1 | Date | |
|---|---|---|---|
| e290e7e500 | |||
| fbe46072b2 |
@@ -1,5 +0,0 @@
|
|||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8-bom
|
|
||||||
26
.vscode/launch.json
vendored
26
.vscode/launch.json
vendored
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
|
||||||
// Use hover for the description of the existing attributes
|
|
||||||
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
|
|
||||||
"name": ".NET Core Launch (console)",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "build",
|
|
||||||
// If you have changed target frameworks, make sure to update the program path.
|
|
||||||
"program": "${workspaceFolder}/bin/Debug/net9.0/csmcp.dll",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
|
||||||
"console": "internalConsole",
|
|
||||||
"stopAtEntry": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ".NET Core Attach",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "attach"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
41
.vscode/tasks.json
vendored
41
.vscode/tasks.json
vendored
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "build",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
|
||||||
"build",
|
|
||||||
"${workspaceFolder}/csmcp.csproj",
|
|
||||||
"/property:GenerateFullPaths=true",
|
|
||||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
|
||||||
],
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "publish",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
|
||||||
"publish",
|
|
||||||
"${workspaceFolder}/csmcp.csproj",
|
|
||||||
"/property:GenerateFullPaths=true",
|
|
||||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
|
||||||
],
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "watch",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
|
||||||
"watch",
|
|
||||||
"run",
|
|
||||||
"--project",
|
|
||||||
"${workspaceFolder}/csmcp.csproj"
|
|
||||||
],
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
42
Program.cs
42
Program.cs
@@ -1,40 +1,2 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
// See https://aka.ms/new-console-template for more information
|
||||||
using Microsoft.Extensions.Hosting;
|
Console.WriteLine("Hello, World!");
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ModelContextProtocol.Server;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
internal class Program
|
|
||||||
{
|
|
||||||
private static async Task Main(string[] args)
|
|
||||||
{
|
|
||||||
var builder = Host.CreateApplicationBuilder(args);
|
|
||||||
builder.Logging.AddConsole(consoleLoggerOptions =>
|
|
||||||
{
|
|
||||||
consoleLoggerOptions.LogToStandardErrorThreshold = LogLevel.Trace;
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Services.
|
|
||||||
AddMcpServer().
|
|
||||||
WithStdioServerTransport().
|
|
||||||
WithToolsFromAssembly();
|
|
||||||
|
|
||||||
await builder.Build().RunAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[McpServerToolType]
|
|
||||||
public static class EchoTool
|
|
||||||
{
|
|
||||||
[McpServerTool, Description("Echoes the message back to the client.")]
|
|
||||||
public static string Echo(string message) => $"Hello from C#: {message}";
|
|
||||||
|
|
||||||
[McpServerTool, Description("Echoes in reverse the message sent by the client.")]
|
|
||||||
public static string ReverseEcho(string message)
|
|
||||||
{
|
|
||||||
char[] charArray = message.ToCharArray();
|
|
||||||
Array.Reverse(charArray);
|
|
||||||
var reversed = new string(charArray);
|
|
||||||
return reversed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user