Skip to content

Fix incorrect MapMcp default-path guidance in mcp-csharp-create#941

Closed
leslierichardson95 wants to merge 1 commit into
mainfrom
leslierichardson95/fix-mcp-csharp-create-mapmcp
Closed

Fix incorrect MapMcp default-path guidance in mcp-csharp-create#941
leslierichardson95 wants to merge 1 commit into
mainfrom
leslierichardson95/fix-mcp-csharp-create-mapmcp

Conversation

@leslierichardson95

Copy link
Copy Markdown
Contributor

Summary

Fixes factually incorrect HTTP-endpoint path guidance in mcp-csharp-create that could cause frontier models to emit /mcp client URLs against a root-mapped server (404s). Part of the dotnet-ai skills-eval follow-up (#889); this is the "protect + surgical fix" action for mcp-csharp-create, which is otherwise an efficient win on Sonnet/Haiku.

What was wrong

The HTTP transport example and Key HTTP details claimed plain app.MapMcp() "defaults to /mcp". Verified against the C# MCP SDK source (McpEndpointRouteBuilderExtensions.MapMcp):

public static IEndpointConventionBuilder MapMcp(
    this IEndpointRouteBuilder endpoints,
    [StringSyntax("Route")] string pattern = "")

The default pattern = "" maps the server at the root route (/), not /mcp. A client told to connect to /mcp against a default-mapped server gets a 404.

Change

  • app.MapMcp();app.MapMcp("/mcp"); in the HTTP Program.cs example (matches the inline comment's stated intent).
  • Rewrote Key HTTP details to describe the pattern argument accurately and tell clients to use a matching URL.

Consistent with references/transport-config.md, which already documents MapMcp("/custom-mcp-path") as a custom path prefix. Surgical, 2-line change — no expansion of an already-winning skill.

Refs #889.


Moved from fork branch to the primary dotnet/skills repo; supersedes #937.

The HTTP transport example and "Key HTTP details" claimed plain
`app.MapMcp()` "defaults to /mcp". The C# MCP SDK signature is
`MapMcp(this IEndpointRouteBuilder endpoints, string pattern = "")`,
which maps at the root route ("/"), not "/mcp". This mismatch can
anchor models to generate `/mcp` client URLs against a root-mapped
server, producing 404s.

Map the endpoint explicitly with `app.MapMcp("/mcp")` and correct the
"Key HTTP details" text to describe the pattern argument accurately and
point clients at a matching URL. Aligns with references/transport-config.md,
which already documents the pattern as a custom path prefix.

Refs #889.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6a8ce111-58e5-48a7-9f7f-8de972bdc693
@github-actions

Copy link
Copy Markdown
Contributor

Skill Coverage Report

Plugin Skill Covered Coverage
dotnet-ai mcp-csharp-create 0/25 0%
Uncovered: dotnet-ai/mcp-csharp-create
  • [Validation] Project builds with no errors (dotnet build) (line 232)
  • [Validation] All tool classes have [McpServerToolType] attribute (line 233)
  • [Validation] All tool methods have [McpServerTool] and [Description] attributes (line 234)
  • [Validation] All parameters have [Description] attributes (line 235)
  • [Validation] stdio: logging directed to stderr, not stdout (line 236)
  • [Validation] HTTP: app.MapMcp() is called in Program.cs (line 237)
  • [Validation] Server starts successfully with dotnet run (line 238)
  • [Pitfall] stdio server outputs garbage or hangs (line 244)
  • [Pitfall] Tool not discovered by LLM clients (line 245)
  • [Pitfall] LLM doesn't understand when to use a tool (line 246)
  • [Pitfall] WithToolsFromAssembly() fails in AOT (line 247)
  • [Pitfall] Parameters not appearing in tool schema (line 248)
  • [Pitfall] HTTP server returns 404 (line 249)
  • [WorkflowStep] Step 1: Verify prerequisites (line 47)
  • [WorkflowStep] Step 2: Choose transport (line 57)
  • [WorkflowStep] Step 3: Scaffold the project (line 68)
  • [WorkflowStep] Step 4: Implement tools (line 86)
  • [WorkflowStep] Step 5: Add prompts and resources (optional) (line 151)
  • [WorkflowStep] Step 6: Configure Program.cs (line 176)
  • [WorkflowStep] Step 7: Verify the server starts (line 219)
  • [CodePattern] [McpServerToolType] (line 90)
  • [CodePattern] [McpServerResourceType] (line 166)
  • [CodePattern] [McpServerPromptType] (line 154)
  • [CodePattern] CancellationToken (line 90)
  • [CodePattern] [Description] (line 90)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects the mcp-csharp-create skill’s HTTP transport guidance so the documented MapMcp route pattern matches the client URL, avoiding 404s caused by incorrectly assuming MapMcp() defaults to /mcp.

Changes:

  • Updates the HTTP Program.cs example to explicitly map the MCP endpoint at /mcp via app.MapMcp("/mcp").
  • Rewrites the “Key HTTP details” section to accurately describe MapMcp(pattern) behavior and instruct clients to use a matching URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +215 to 217
**Key HTTP details:** `MapMcp(pattern)` maps the endpoint at `pattern` — `MapMcp("/mcp")` serves at `/mcp`, while plain `MapMcp()` defaults to the root route (`/`). Pass the pattern explicitly and point clients at a matching URL (e.g. `http://localhost:<port>/mcp`). For containers, set `ASPNETCORE_URLS=http://+:8080` and `EXPOSE 8080`. The MCP HTTP protocol uses Streamable HTTP — no special client config needed beyond the URL.

**For transport configuration details** (stateless mode, auth, path prefix, `HttpContextAccessor`), see [references/transport-config.md](references/transport-config.md).
@leslierichardson95

Copy link
Copy Markdown
Contributor Author

Superseded by #943, which retires this skill (and the rest of the mcp-csharp-* family) per the #889 eval + telemetry review. Closing as obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants