Replies: 1 comment 1 reply
-
I am not sure but you may check launchSettings.json Also you may take a look samples folder if not. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Pre-submission Checklist
Question Category
Your Question
I made a test project for SDK version 0.1.0-preview.9 based on the asp.net core sample found in the repository. I think I made everything the same way, but there is no any MCP endpoint present.
If I check the OpenAPI spec the endpoints are missing and also the 'MCP Inspector v0.9.0' tool cant connect.
Is it an SDK bug, or did I made a mistake?
Thanks
Attila
Program.cs:
`using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using OpenTelemetry;
using McpServerProof;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMcpServer()
.WithHttpTransport()
.WithTools();
builder.Services.AddOpenApi();
builder.Services.AddOpenTelemetry()
.WithTracing(b => b.AddSource("")
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation())
.WithMetrics(b => b.AddMeter("")
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation())
.WithLogging()
.UseOtlpExporter();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.MapMcp();
app.MapGet("/hello", () => "Hello World!");
app.Run();`
ToolClass.cs:
`using ModelContextProtocol.Server;
using System.ComponentModel;
namespace McpServerProof;
[McpServerToolType]
public sealed class ToolClass
{
[McpServerTool,Description("Returns the current date and time.")]
public static string GetDateTime(
IMcpServer thisServer,
[Description("True if the date and time should be UTC, otherwise it will be local time zone.")] bool isUtc,
CancellationToken cancellationToken)
{
return isUtc
? DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ")
: DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
}
}`
Project file:
net9.0 enable enable`
`
Beta Was this translation helpful? Give feedback.
All reactions