Skip to content

Client connected to the server does not support sampling. #307

@ame0410

Description

@ame0410

Describe the bug
I am using GitHub Copilot Business in VS Code.
When i run the example csharp-sdk\samples\AspNetCoreSseServer and try call SampleLlmTool.SampleLLM via. GitHub Copilot Business in VS Code in agent mode. I get the following exception in the MCP server:

Exception has occurred: CLR/System.ArgumentException
An exception of type 'System.ArgumentException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Client connected to the server does not support sampling.'
   at ModelContextProtocol.Server.McpServerExtensions.AsSamplingChatClient(IMcpServer server) in C:\Projects\csharp-sdk\src\ModelContextProtocol\Server\McpServerExtensions.cs:line 169
   at TestServerWithHosting.Tools.SampleLlmTool.<SampleLLM>d__0.MoveNext() in C:\Projects\csharp-sdk\samples\AspNetCoreSseServer\Tools\SampleLlmTool.cs:line 32
   at Microsoft.Extensions.AI.AIFunctionFactory.ReflectionAIFunctionDescriptor.<>c__DisplayClass32_1.<<GetReturnParameterMarshaller>b__10>d.MoveNext()
   at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
   at Microsoft.Extensions.AI.AIFunctionFactory.ReflectionAIFunction.<InvokeCoreAsync>d__26.MoveNext()

How do i ensure that my client, in this case GitHub Copilot Business in VS Code, can support sampling?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions