Skip to content

Commit 63fd18b

Browse files
authored
Merge branch 'main' into mdk/more-docs
2 parents 9048ed7 + ab6d3e1 commit 63fd18b

File tree

118 files changed

+5631
-3603
lines changed

Some content is hidden

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

118 files changed

+5631
-3603
lines changed

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<System9Version>9.0.5</System9Version>
55
<System10Version>10.0.0-preview.4.25258.110</System10Version>
6-
<MicrosoftExtensionsAIVersion>9.8.0</MicrosoftExtensionsAIVersion>
6+
<MicrosoftExtensionsAIVersion>9.9.0</MicrosoftExtensionsAIVersion>
77
</PropertyGroup>
88

99
<!-- Product dependencies netstandard -->
@@ -53,7 +53,7 @@
5353
<PrivateAssets>all</PrivateAssets>
5454
</PackageVersion>
5555
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
56-
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.8.0-preview.1.25412.6" />
56+
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.9.0-preview.1.25458.4" />
5757
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(System9Version)" />
5858
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="$(System9Version)" />
5959
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(System9Version)" />

README.md

Lines changed: 8 additions & 8 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 `IMcpClient`
41-
to a server. Once you have an `IMcpClient`, 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())
@@ -88,7 +88,7 @@ var response = await chatClient.GetResponseAsync(
8888
Here is an example of how to create an MCP server and register all tools from the current application.
8989
It includes a simple echo tool as an example (this is included in the same file here for easy of copy and paste, but it needn't be in the same file...
9090
the employed overload of `WithTools` examines the current assembly for classes with the `McpServerToolType` attribute, and registers all methods with the
91-
`McpTool` attribute as tools.)
91+
`McpServerTool` attribute as tools.)
9292

9393
```
9494
dotnet add package ModelContextProtocol --prerelease
@@ -122,14 +122,14 @@ public static class EchoTool
122122
}
123123
```
124124

125-
Tools can have the `IMcpServer` representing the server injected via a parameter to the method, and can use that for interaction with
125+
Tools can have the `McpServer` representing the server injected via a parameter to the method, and can use that for interaction with
126126
the connected client. Similarly, arguments may be injected via dependency injection. For example, this tool will use the supplied
127-
`IMcpServer` to make sampling requests back to the client in order to summarize content it downloads from the specified url via
127+
`McpServer` to make sampling requests back to the client in order to summarize content it downloads from the specified url via
128128
an `HttpClient` injected via dependency injection.
129129
```csharp
130130
[McpServerTool(Name = "SummarizeContentFromUrl"), Description("Summarizes content downloaded from a specific URI")]
131131
public static async Task<string> SummarizeDownloadedContent(
132-
IMcpServer thisServer,
132+
McpServer thisServer,
133133
HttpClient httpClient,
134134
[Description("The url from which to download the content to summarize")] string url,
135135
CancellationToken cancellationToken)
@@ -224,7 +224,7 @@ McpServerOptions options = new()
224224
},
225225
};
226226

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

docs/concepts/elicitation/samples/client/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
var endpoint = Environment.GetEnvironmentVariable("ENDPOINT") ?? "http://localhost:3001";
66

7-
var clientTransport = new SseClientTransport(new()
7+
var clientTransport = new HttpClientTransport(new()
88
{
99
Endpoint = new Uri(endpoint),
1010
TransportMode = HttpTransportMode.StreamableHttp,
@@ -27,7 +27,7 @@
2727
}
2828
};
2929

30-
await using var mcpClient = await McpClientFactory.CreateAsync(clientTransport, options);
30+
await using var mcpClient = await McpClient.CreateAsync(clientTransport, options);
3131
// </snippet_McpInitialize>
3232

3333
var tools = await mcpClient.ListToolsAsync();

docs/concepts/elicitation/samples/server/Tools/InteractiveTools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed class InteractiveTools
1313
// <snippet_GuessTheNumber>
1414
[McpServerTool, Description("A simple game where the user has to guess a number between 1 and 10.")]
1515
public async Task<string> GuessTheNumber(
16-
IMcpServer server, // Get the McpServer from DI container
16+
McpServer server, // Get the McpServer from DI container
1717
CancellationToken token
1818
)
1919
{

docs/concepts/logging/samples/client/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
var endpoint = Environment.GetEnvironmentVariable("ENDPOINT") ?? "http://localhost:3001";
66

7-
var clientTransport = new SseClientTransport(new()
7+
var clientTransport = new HttpClientTransport(new()
88
{
99
Endpoint = new Uri(endpoint),
1010
TransportMode = HttpTransportMode.StreamableHttp,
1111
});
1212

13-
await using var mcpClient = await McpClientFactory.CreateAsync(clientTransport);
13+
await using var mcpClient = await McpClient.CreateAsync(clientTransport);
1414

1515
// <snippet_LoggingCapabilities>
1616
// Verify that the server supports logging

docs/concepts/progress/samples/client/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
var endpoint = Environment.GetEnvironmentVariable("ENDPOINT") ?? "http://localhost:3001";
77

8-
var clientTransport = new SseClientTransport(new()
8+
var clientTransport = new HttpClientTransport(new()
99
{
1010
Endpoint = new Uri(endpoint),
1111
TransportMode = HttpTransportMode.StreamableHttp,
@@ -20,7 +20,7 @@
2020
}
2121
};
2222

23-
await using var mcpClient = await McpClientFactory.CreateAsync(clientTransport, options);
23+
await using var mcpClient = await McpClient.CreateAsync(clientTransport, options);
2424

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

docs/concepts/progress/samples/server/Tools/LongRunningTools.cs

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

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
{

0 commit comments

Comments
 (0)