Skip to content

Commit 81bcae0

Browse files
committed
Revise naming, add abstract classes
1 parent 2ef8821 commit 81bcae0

File tree

84 files changed

+586
-609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+586
-609
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ dotnet add package ModelContextProtocol --prerelease
3737

3838
## Getting Started (Client)
3939

40-
To get started writing a client, the `McpClientFactory.CreateAsync` method is used to instantiate and connect an `McpClientSession`
41-
to a server. Once you have an `McpClientSession`, you can interact with it, such as to enumerate all available tools and invoke tools.
40+
To get started writing a client, the `McpClient.CreateAsync` method is used to instantiate and connect an `McpClient`
41+
to a server. Once you have an `McpClient`, you can interact with it, such as to enumerate all available tools and invoke tools.
4242

4343
```csharp
4444
var clientTransport = new StdioClientTransport(new StdioClientTransportOptions
@@ -48,7 +48,7 @@ var clientTransport = new StdioClientTransport(new StdioClientTransportOptions
4848
Arguments = ["-y", "@modelcontextprotocol/server-everything"],
4949
});
5050

51-
var client = await McpClientFactory.CreateAsync(clientTransport);
51+
var client = await McpClient.CreateAsync(clientTransport);
5252

5353
// Print the list of tools available from the server.
5454
foreach (var tool in await client.ListToolsAsync())
@@ -224,7 +224,7 @@ McpServerOptions options = new()
224224
},
225225
};
226226

227-
await using IMcpServer server = McpServerFactory.Create(new StdioServerTransport("MyServer"), options);
227+
await using IMcpServer server = McpServer.Create(new StdioServerTransport("MyServer"), options);
228228
await server.RunAsync();
229229
```
230230

samples/AspNetCoreMcpServer/Tools/SampleLlmTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public sealed class SampleLlmTool
1212
{
1313
[McpServerTool(Name = "sampleLLM"), Description("Samples from an LLM using MCP's sampling feature")]
1414
public static async Task<string> SampleLLM(
15-
IMcpServer thisServer,
15+
McpServer thisServer,
1616
[Description("The prompt to send to the LLM")] string prompt,
1717
[Description("Maximum number of tokens to generate")] int maxTokens,
1818
CancellationToken cancellationToken)

samples/ChatWithTools/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
.UseOpenTelemetry(loggerFactory: loggerFactory, configure: o => o.EnableSensitiveData = true)
3333
.Build();
3434

35-
var mcpClient = await McpClientFactory.CreateAsync(
35+
var mcpClient = await McpClient.CreateAsync(
3636
new StdioClientTransport(new()
3737
{
3838
Command = "npx",

samples/EverythingServer/LoggingUpdateMessageSender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace EverythingServer;
77

8-
public class LoggingUpdateMessageSender(IMcpServer server, Func<LoggingLevel> getMinLevel) : BackgroundService
8+
public class LoggingUpdateMessageSender(McpServer server, Func<LoggingLevel> getMinLevel) : BackgroundService
99
{
1010
readonly Dictionary<LoggingLevel, string> _loggingLevelMap = new()
1111
{

samples/EverythingServer/SubscriptionMessageSender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using ModelContextProtocol;
33
using ModelContextProtocol.Server;
44

5-
internal class SubscriptionMessageSender(IMcpServer server, HashSet<string> subscriptions) : BackgroundService
5+
internal class SubscriptionMessageSender(McpServer server, HashSet<string> subscriptions) : BackgroundService
66
{
77
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
88
{

samples/EverythingServer/Tools/LongRunningTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class LongRunningTool
1010
{
1111
[McpServerTool(Name = "longRunningOperation"), Description("Demonstrates a long running operation with progress updates")]
1212
public static async Task<string> LongRunningOperation(
13-
IMcpServer server,
13+
McpServer server,
1414
RequestContext<CallToolRequestParams> context,
1515
int duration = 10,
1616
int steps = 5)

samples/EverythingServer/Tools/SampleLlmTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class SampleLlmTool
99
{
1010
[McpServerTool(Name = "sampleLLM"), Description("Samples from an LLM using MCP's sampling feature")]
1111
public static async Task<string> SampleLLM(
12-
IMcpServer server,
12+
McpServer server,
1313
[Description("The prompt to send to the LLM")] string prompt,
1414
[Description("Maximum number of tokens to generate")] int maxTokens,
1515
CancellationToken cancellationToken)

samples/InMemoryTransport/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Pipe clientToServerPipe = new(), serverToClientPipe = new();
77

88
// Create a server using a stream-based transport over an in-memory pipe.
9-
await using IMcpServer server = McpServerFactory.Create(
9+
await using McpServer server = McpServer.Create(
1010
new StreamServerTransport(clientToServerPipe.Reader.AsStream(), serverToClientPipe.Writer.AsStream()),
1111
new McpServerOptions()
1212
{
@@ -21,7 +21,7 @@
2121
_ = server.RunAsync();
2222

2323
// Connect a client using a stream-based transport over the same in-memory pipe.
24-
await using McpClientSession client = await McpClientFactory.CreateAsync(
24+
await using McpClient client = await McpClient.CreateAsync(
2525
new StreamClientTransport(clientToServerPipe.Writer.AsStream(), serverToClientPipe.Reader.AsStream()));
2626

2727
// List all tools.

samples/ProtectedMcpClient/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
}, httpClient, consoleLoggerFactory);
3939

40-
var client = await McpClientFactory.CreateAsync(transport, loggerFactory: consoleLoggerFactory);
40+
var client = await McpClient.CreateAsync(transport, loggerFactory: consoleLoggerFactory);
4141

4242
var tools = await client.ListToolsAsync();
4343
if (tools.Count == 0)

samples/QuickstartClient/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Arguments = arguments,
2222
});
2323

24-
await using var mcpClient = await McpClientFactory.CreateAsync(clientTransport);
24+
await using var mcpClient = await McpClient.CreateAsync(clientTransport);
2525

2626
var tools = await mcpClient.ListToolsAsync();
2727
foreach (var tool in tools)

0 commit comments

Comments
 (0)