Skip to content

Commit 1dcbc0b

Browse files
committed
Tweaks
1 parent c822e08 commit 1dcbc0b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/ModelContextProtocol/Client/McpClientTool.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ namespace ModelContextProtocol.Client;
99
public sealed class McpClientTool : AIFunction
1010
{
1111
private readonly IMcpClient _client;
12-
private readonly string? _nameOverride;
13-
private readonly string? _descriptionOverride;
12+
private readonly string? _name;
13+
private readonly string? _description;
1414

15-
internal McpClientTool(IMcpClient client, Tool tool, string? nameOverride = null, string? descriptionOverride = null)
15+
internal McpClientTool(IMcpClient client, Tool tool, string? name = null, string? description = null)
1616
{
1717
_client = client;
1818
ProtocolTool = tool;
19-
_nameOverride = nameOverride;
20-
_descriptionOverride = descriptionOverride;
19+
_name = name ?? tool.Name;
20+
_description = description ?? tool.Description;
2121
}
2222

2323
/// <summary>
2424
/// Creates a new instance of the tool with the specified name.
2525
/// This is useful for optimizing the tool name for specific models or for prefixing the tool name with a (usually server-derived) namespace to avoid conflicts.
2626
/// The server will still be called with the original tool name, so no mapping is required.
2727
/// </summary>
28-
/// <param name="name">The model-facing name to give the tool</param>
29-
/// <returns>Equivalent McpClientTool, but with the provided name</returns>
30-
public McpClientTool WithName(string name)
28+
/// <param name="name">The model-facing name to give the tool. Pass null to clear the name override and to use the MCP Tool name again.</param>
29+
/// <returns>Copy of this McpClientTool with the provided name</returns>
30+
public McpClientTool WithName(string? name)
3131
{
32-
return new McpClientTool(_client, ProtocolTool, name, _descriptionOverride);
32+
return new McpClientTool(_client, ProtocolTool, name, _description);
3333
}
3434

3535
/// <summary>
@@ -38,21 +38,21 @@ public McpClientTool WithName(string name)
3838
/// This will in general require a hard-coded mapping in the client.
3939
/// It is not recommended to use this without running evaluations to ensure the model actually benefits from the custom description.
4040
/// </summary>
41-
/// <param name="description"></param>
42-
/// <returns></returns>
43-
public McpClientTool WithDescription(string description)
41+
/// <param name="description">The description to give the tool. Pass null to clear the description override and to use the MCP Tool description again.</param>
42+
/// <returns>Copy of this McpClientTool with the provided description</returns>
43+
public McpClientTool WithDescription(string? description)
4444
{
45-
return new McpClientTool(_client, ProtocolTool, _nameOverride, description);
45+
return new McpClientTool(_client, ProtocolTool, _name, description);
4646
}
4747

4848
/// <summary>Gets the protocol <see cref="Tool"/> type for this instance.</summary>
4949
public Tool ProtocolTool { get; }
5050

5151
/// <inheritdoc/>
52-
public override string Name => _nameOverride ?? ProtocolTool.Name;
52+
public override string Name => _name ?? ProtocolTool.Name;
5353

5454
/// <inheritdoc/>
55-
public override string Description => _descriptionOverride ?? ProtocolTool.Description ?? string.Empty;
55+
public override string Description => _description ?? ProtocolTool.Description ?? string.Empty;
5656

5757
/// <inheritdoc/>
5858
public override JsonElement JsonSchema => ProtocolTool.InputSchema;

0 commit comments

Comments
 (0)