Skip to content

Expected usage for concurrent calls #88

@goelhardik

Description

@goelhardik

I am trying to make multiple parallel calls to an MCP server over stdio transport. But that seems to throw an error sometimes. Should I instantiate a new client (and therefore server) for each request?

This is the error when reusing the same client object returned by McpClientFactory.CreateAsync() for multiple calls:

System.InvalidOperationException
The stream is currently in use by a previous operation on the stream.
   at System.IO.StreamWriter.ThrowAsyncIOInProgress()
   at System.IO.StreamWriter.WriteLineAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
   at ModelContextProtocol.Protocol.Transport.StdioClientTransport.SendMessageAsync(IJsonRpcMessage message, CancellationToken cancellationToken)

Metadata

Metadata

Assignees

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