readme.md

March 30, 2025 ยท View on GitHub

Tasks:

Create a demo mcp server with a simple mcp client that connects to it and sends a message.

  • Create a simple mcp server that listens for incoming connections and handles messages.
  • Create a simple mcp client that connects to the server and sends a message.
  • Use the mcp protocol for communication between the client and server.

Ref: https://docs.cline.bot/mcp-servers/mcp-server-from-scratch

Instructions

  1. Build the project:

    npm run build
    
  2. Start the MCP server:

    npm start
    
  3. Run the MCP client in a separate terminal:

    node build/client.js
    
  4. Observe the communication between the client and server in their respective terminals.

PS C:\src\stoneskin\MyMCPServer> node build/client.js
Demo MCP server running on stdio
Demo MCP client connected to server
Available tools: {
  tools: [
    {
      name: 'send_message',
      description: 'Sends a message to the server console',
      inputSchema: [Object]
    }
  ]
}
Tool result: {
  content: [ { type: 'text', text: 'Message sent to server console' } ]
}
Demo MCP client disconnected

Client MCP server Configuration

To configure the Client MCP server, you need to add the following configuration to your VS Code settings:

{
   "mcpServers": {
    "MyMCPDemo": {
      "command": "node",
      "args": [
        "C:\\src\\stoneskin\\MyMCPServer\\build\\sto_demo_server.js"
      ],
      "disabled": false,
      "autoApprove": [
        "send_message"
      ],
      "timeout": 30
    }
  }
}

[Todo]Python MCP Server sample

  • try install mcp-server-time pip install mcp-server-time

-After installation, you can run it as a script using:

python -m mcp_server_time

"mcpServers": {
  "time": {
    "command": "python",
    "args": ["-m", "mcp_server_time"]
  }
}

example

{
  "command": "python",
  "args": ["-m", "mcp_server_time", "--local-timezone=America/New_York"]
}