Skip to content

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

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

Fix incorrect MapMcp default-path guidance in mcp-csharp-create#937
leslierichardson95 wants to merge 1 commit into
dotnet:mainfrom
leslierichardson95: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.

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 dotnet#889.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6a8ce111-58e5-48a7-9f7f-8de972bdc693
Copilot AI review requested due to automatic review settings July 23, 2026 23:24

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 MCP endpoint path matches the actual behavior of MapMcp’s default route mapping, avoiding clients being pointed at a non-existent /mcp endpoint.

Changes:

  • Update the HTTP Program.cs example to explicitly map MCP at /mcp via app.MapMcp("/mcp").
  • Rewrite the “Key HTTP details” section to explain how MapMcp(pattern) determines the served path and to align client URL guidance accordingly.

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

```

**Key HTTP details:** `MapMcp()` defaults to `/mcp` path. 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.
**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.
@leslierichardson95

Copy link
Copy Markdown
Contributor Author

Superseded by #941, which moves this change to a branch on the primary dotnet/skills repo. Closing this fork PR.

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