Repository navigation
Replies: 1 comment
|
Yes. You can hook the client and server together in-process with pipes. There's a sample here: https://github.com/modelcontextprotocol/csharp-sdk/tree/main/samples/InMemoryTransport Pipe clientToServerPipe = new(), serverToClientPipe = new();
await using McpServer server = McpServer.Create(
new StreamServerTransport(clientToServerPipe.Reader.AsStream(), serverToClientPipe.Writer.AsStream()),
new McpServerOptions
{
ToolCollection = [McpServerTool.Create((string arg) => $"Echo: {arg}", new() { Name = "Echo" })]
});
_ = server.RunAsync();
await using McpClient client = await McpClient.CreateAsync(
new StreamClientTransport(clientToServerPipe.Writer.AsStream(), serverToClientPipe.Reader.AsStream()));Don't await |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Pre-submission Checklist
Question Category
Your Question
Hello!
I want to combine MCP server and client in one application. For a regular server, the server is a different process, and we use
StdioClientTransportetc and have no problem.But I want to make "invocations" from MCP client -> MCP server inside one process.
I can't figure out how to implement this.
Any tips?
Thank you!
All reactions