37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using ModelContextProtocol.Server;
|
|
|
|
namespace LinkToolAddin.server;
|
|
|
|
public class ArcGISProMcpServer
|
|
{
|
|
public static async void TestMcpServer()
|
|
{
|
|
var builder = WebApplication.CreateBuilder();
|
|
builder.Logging.AddConsole(options =>
|
|
{
|
|
options.LogToStandardErrorThreshold = LogLevel.Trace;
|
|
});;
|
|
builder.Services.AddMcpServer().WithHttpTransport().WithToolsFromAssembly();
|
|
var app = builder.Build();
|
|
app.MapMcp("/sse");
|
|
app.MapGet("/", () => "MCP Server is running!");
|
|
Console.WriteLine("About to start server...");
|
|
await app.RunAsync();
|
|
}
|
|
}
|
|
|
|
[McpServerToolType]
|
|
public static class EchoTool
|
|
{
|
|
[McpServerTool, Description("Echoes the message back to the client.")]
|
|
public static string Echo(string message)
|
|
{
|
|
Console.WriteLine($"received message: {message}");
|
|
return $"hello {message}";
|
|
}
|
|
} |