diff --git a/README.MD b/README.MD
index e25970b..d5b26a4 100644
--- a/README.MD
+++ b/README.MD
@@ -22,7 +22,7 @@ This library aims to provide a clean, specification-compliant implementation of
- Support for stdio and SSE transports
- Support for all MCP capabilities: Tool, Resource, Prompt, Sampling, Roots
- Support for the Completion utility capability
-- Support for pagination and notifications
+- Support for server instructions, pagination and notifications
- Async/await pattern throughout
- Comprehensive logging support
- Compatible with .NET 8.0 and later
diff --git a/samples/anthropic/tools/ToolsConsole/Program.cs b/samples/anthropic/tools/ToolsConsole/Program.cs
index 11f540e..fa18fb0 100644
--- a/samples/anthropic/tools/ToolsConsole/Program.cs
+++ b/samples/anthropic/tools/ToolsConsole/Program.cs
@@ -69,8 +69,16 @@ internal class Program
Model = AnthropicModels.Claude35Haiku,
Stream = false,
Temperature = 1.0m,
- Tools = anthropicTools
+ Tools = anthropicTools,
+ System = [new SystemMessage("You will be helping the user test MCP server tool call functionality.")]
};
+
+ // If the server provides instructions, add them as the system prompt
+ if (!string.IsNullOrEmpty(client.ServerInstructions))
+ {
+ parameters.System.Add(new SystemMessage(client.ServerInstructions));
+ }
+
var res = await antClient.Messages.GetClaudeMessageAsync(parameters);
messages.Add(res.Message);
diff --git a/samples/microsoft.extensions.ai/tools/ToolsConsole/MEAIToolsConsole.csproj b/samples/microsoft.extensions.ai/tools/ToolsConsole/MEAIToolsConsole.csproj
index fa62786..39076cf 100644
--- a/samples/microsoft.extensions.ai/tools/ToolsConsole/MEAIToolsConsole.csproj
+++ b/samples/microsoft.extensions.ai/tools/ToolsConsole/MEAIToolsConsole.csproj
@@ -8,9 +8,12 @@
-
+
+
+
+
diff --git a/samples/microsoft.extensions.ai/tools/ToolsConsole/Program.cs b/samples/microsoft.extensions.ai/tools/ToolsConsole/Program.cs
index 333aec6..3c0d20c 100644
--- a/samples/microsoft.extensions.ai/tools/ToolsConsole/Program.cs
+++ b/samples/microsoft.extensions.ai/tools/ToolsConsole/Program.cs
@@ -3,6 +3,7 @@ using McpDotNet.Configuration;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Logging.Abstractions;
using OpenAI;
+using OpenAI.Chat;
using SimpleToolsConsole;
internal class Program
@@ -63,10 +64,23 @@ internal class Program
IChatClient chatClient = new ChatClientBuilder(openaiClient)
.UseFunctionInvocation()
.Build();
-
+
+ // Create message list
+ IList messages = new List();
+ // Add a system message
+ messages.Add(new(ChatRole.System, "You are a helpful assistant, helping us test MCP server functionality."));
+ // If MCP server provides instructions, add them as an additional system message (you could also add it as a content part)
+ if (!string.IsNullOrEmpty(client.ServerInstructions))
+ {
+ messages.Add(new(ChatRole.System, client.ServerInstructions));
+ }
+ // Add a user message
+ messages.Add(new(ChatRole.User, "Please call the echo tool with the string 'Hello MCP!' and give me the response as-is."));
+
+ // Call the chat client
Console.WriteLine("Asking GPT-4o-mini to call the Echo Tool...");
var response = chatClient.CompleteStreamingAsync(
- "Please call the echo tool with the string 'Hello MCP!' and give me the response as-is.",
+ messages,
new() { Tools = mappedTools });
await foreach (var update in response)
diff --git a/src/mcpdotnet/Client/IMcpClient.cs b/src/mcpdotnet/Client/IMcpClient.cs
index ed6e5d5..4cdfc5b 100644
--- a/src/mcpdotnet/Client/IMcpClient.cs
+++ b/src/mcpdotnet/Client/IMcpClient.cs
@@ -25,6 +25,13 @@ public interface IMcpClient : IAsyncDisposable
///
Implementation? ServerInfo { get; }
+ ///
+ /// Instructions describing how to use the server and its features.
+ /// This can be used by clients to improve the LLM's understanding of available tools, resources, etc.
+ /// It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
+ ///
+ string? ServerInstructions { get; }
+
///
/// Gets or sets the handler for server sampling requests.
///
diff --git a/src/mcpdotnet/Client/McpClient.cs b/src/mcpdotnet/Client/McpClient.cs
index 0339bd7..2337ff4 100644
--- a/src/mcpdotnet/Client/McpClient.cs
+++ b/src/mcpdotnet/Client/McpClient.cs
@@ -37,6 +37,9 @@ internal class McpClient : IMcpClient
///
public Implementation? ServerInfo { get; private set; }
+ ///
+ public string? ServerInstructions { get; private set; }
+
///
/// Initializes a new instance of the class.
///
@@ -154,6 +157,7 @@ internal class McpClient : IMcpClient
_logger.ServerCapabilitiesReceived(_serverConfig.Id, _serverConfig.Name, JsonSerializer.Serialize(initializeResponse.Capabilities), JsonSerializer.Serialize(initializeResponse.ServerInfo));
ServerCapabilities = initializeResponse.Capabilities;
ServerInfo = initializeResponse.ServerInfo;
+ ServerInstructions = initializeResponse.Instructions;
// Validate protocol version
if (initializeResponse.ProtocolVersion != _options.ProtocolVersion)
diff --git a/src/mcpdotnet/mcpdotnet.csproj b/src/mcpdotnet/mcpdotnet.csproj
index 7d5f86a..819c647 100644
--- a/src/mcpdotnet/mcpdotnet.csproj
+++ b/src/mcpdotnet/mcpdotnet.csproj
@@ -9,7 +9,7 @@
mcpdotnet
- 0.8.0.1
+ 0.9.0.1
PederHP
.NET client library for the Model Context Protocol (MCP)
https://github.com/PederHP/mcpdotnet
diff --git a/tests/mcpdotnet.Tests/IntegrationTests.cs b/tests/mcpdotnet.Tests/IntegrationTests.cs
index a3f651b..69dd543 100644
--- a/tests/mcpdotnet.Tests/IntegrationTests.cs
+++ b/tests/mcpdotnet.Tests/IntegrationTests.cs
@@ -27,6 +27,22 @@ public class IntegrationTests : IClassFixture
Assert.NotNull(client);
}
+ [Fact]
+ public async Task Connect_EverythingServer_ShouldProvideServerFields()
+ {
+ // Arrange
+
+ // Act
+ var client = await _fixture.Factory.GetClientAsync("everything");
+
+ // Assert
+ Assert.NotNull(client.ServerCapabilities);
+ Assert.NotNull(client.ServerInfo);
+
+ // Note: Comment the below assertion back when the everything server is updated to provide instructions
+ // Assert.NotNull(client.ServerInstructions);
+ }
+
[Fact]
public async Task ListTools_Stdio_EverythingServer()
{