Test-MCP-Server
3.3
This is a simple Model Context Protocol (MCP) server built using .NET and C#.
The MCP server is designed to facilitate communication between different components of a system using the Model Context Protocol. Built with .NET and C#, this server provides a robust framework for managing data exchange and ensuring seamless integration across various platforms. The server is lightweight, making it suitable for small to medium-sized applications that require efficient data handling and communication. The accompanying YouTube video provides a step-by-step guide on how to create and test this MCP server, making it accessible even to those with limited experience in .NET and C# development.
Features
- Lightweight and efficient: Designed to handle small to medium-sized applications with ease.
- Built with .NET and C#: Utilizes the powerful features of .NET and C# for robust server performance.
- Easy integration: Facilitates seamless communication between different system components.
- Step-by-step guide: Accompanied by a YouTube video tutorial for easy setup and testing.
- Scalable architecture: Can be adapted to meet the growing needs of an application.
Usage with Different Platforms
dotnet_script
csharp
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
class MCPServer
{
public static void Main()
{
TcpListener server = null;
try
{
Int32 port = 13000;
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
server = new TcpListener(localAddr, port);
server.Start();
Byte[] bytes = new Byte[256];
String data = null;
while (true)
{
Console.Write("Waiting for a connection... ");
TcpClient client = server.AcceptTcpClient();
Console.WriteLine("Connected!");
data = null;
NetworkStream stream = client.GetStream();
int i;
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
data = Encoding.ASCII.GetString(bytes, 0, i);
Console.WriteLine("Received: {0}", data);
data = data.ToUpper();
byte[] msg = Encoding.ASCII.GetBytes(data);
stream.Write(msg, 0, msg.Length);
Console.WriteLine("Sent: {0}", data);
}
client.Close();
}
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
finally
{
server.Stop();
}
Console.WriteLine("Hit enter to continue...");
Console.Read();
}
}