Skip to content

Commit a2027b5

Browse files
Copilothalter73
andcommitted
Rename @params to parameters and add MCP9003 diagnostic for obsolete constructor
- Rename the `@params` constructor parameter to `parameters` in the 3-arg RequestContext<TParams> constructor. - Add MCP9003 diagnostic ID to Obsoletions.cs for the obsolete 2-arg constructor, following the established pattern (Message, DiagnosticId, UrlFormat). - Update the [Obsolete] attribute to use the centralized constants with DiagnosticId and UrlFormat. - Document MCP9003 in docs/list-of-diagnostics.md. Co-authored-by: halter73 <54385+halter73@users.noreply.github.com> Agent-Logs-Url: https://github.com/modelcontextprotocol/csharp-sdk/sessions/6e17cd63-6cb0-4d77-ba6c-1f2a616fa03f
1 parent c0f7088 commit a2027b5

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

docs/list-of-diagnostics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ When APIs are marked as obsolete, a diagnostic is emitted to warn users that the
3636
| :------------ | :----- | :---------- |
3737
| `MCP9001` | In place | The `EnumSchema` and `LegacyTitledEnumSchema` APIs are deprecated as of specification version 2025-11-25. Use the current schema APIs instead. |
3838
| `MCP9002` | Removed | The `AddXxxFilter` extension methods on `IMcpServerBuilder` (e.g., `AddListToolsFilter`, `AddCallToolFilter`, `AddIncomingMessageFilter`) were superseded by `WithRequestFilters()` and `WithMessageFilters()`. |
39+
| `MCP9003` | In place | The `RequestContext<TParams>(McpServer, JsonRpcRequest)` constructor is obsolete. Use the overload that accepts a `parameters` argument: `RequestContext<TParams>(McpServer, JsonRpcRequest, TParams)`. |

src/Common/Obsoletions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ internal static class Obsoletions
2525

2626
// MCP9002 was used for the AddXxxFilter extension methods on IMcpServerBuilder that were superseded by
2727
// WithMessageFilters() and WithRequestFilters(). The APIs were removed; do not reuse this diagnostic ID.
28+
29+
public const string RequestContextParamsConstructor_DiagnosticId = "MCP9003";
30+
public const string RequestContextParamsConstructor_Message = "Use the constructor overload that accepts a parameters argument.";
31+
public const string RequestContextParamsConstructor_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcp9003";
2832
}

src/ModelContextProtocol.Core/Server/RequestContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public sealed class RequestContext<TParams> : MessageContext
1818
/// </summary>
1919
/// <param name="server">The server with which this instance is associated.</param>
2020
/// <param name="jsonRpcRequest">The JSON-RPC request associated with this context.</param>
21-
/// <param name="params">The parameters associated with this request.</param>
21+
/// <param name="parameters">The parameters associated with this request.</param>
2222
/// <exception cref="ArgumentNullException"><paramref name="server"/> or <paramref name="jsonRpcRequest"/> is <see langword="null"/>.</exception>
23-
public RequestContext(McpServer server, JsonRpcRequest jsonRpcRequest, TParams @params)
23+
public RequestContext(McpServer server, JsonRpcRequest jsonRpcRequest, TParams parameters)
2424
: base(server, jsonRpcRequest)
2525
{
26-
Params = @params;
26+
Params = parameters;
2727
}
2828

2929
/// <summary>
@@ -32,7 +32,7 @@ public RequestContext(McpServer server, JsonRpcRequest jsonRpcRequest, TParams @
3232
/// <param name="server">The server with which this instance is associated.</param>
3333
/// <param name="jsonRpcRequest">The JSON-RPC request associated with this context.</param>
3434
/// <exception cref="ArgumentNullException"><paramref name="server"/> or <paramref name="jsonRpcRequest"/> is <see langword="null"/>.</exception>
35-
[Obsolete("Use the constructor that accepts a params argument.")]
35+
[Obsolete(Obsoletions.RequestContextParamsConstructor_Message, DiagnosticId = Obsoletions.RequestContextParamsConstructor_DiagnosticId, UrlFormat = Obsoletions.RequestContextParamsConstructor_Url)]
3636
public RequestContext(McpServer server, JsonRpcRequest jsonRpcRequest)
3737
: base(server, jsonRpcRequest)
3838
{

0 commit comments

Comments
 (0)