Skip to content
Back to search

MCP-server-and-client

Python MCP server and client implementation over TCP.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/potatoisme19--mcp-server-and-client/badge.svg)](/listings/potatoisme19--mcp-server-and-client)

HTML

<a href="/listings/potatoisme19--mcp-server-and-client"><img src="/api/listings/potatoisme19--mcp-server-and-client/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 66 lines
  1. # MCP Server and Client (Python)
  2. A Python implementation of an MCP-style client and server over TCP, with JSON-RPC messages, tool discovery, reading queries, and streamed analysis.
  3. ## What it does
  4. ### Server
  5. - Listens on `127.0.0.1` at the selected port and accepts multiple client connections. Each accepted connection is handled on its own worker thread, so one client's requests do not block other connected clients.
  6. - Keeps client connections open when requested and can process multiple requests on the same connection.
  7. - Supports server discovery, tool listing, and tool calls for `get_reading`, `get_history`, and `analyse_readings`.
  8. - Streams analysis progress events and a final result. If the client cancels or disconnects, the server stops that analysis.
  9. - Loads its sample readings from `support/data/readings.json` and uses the helpers in `support/python/` to compute tool results.
  10. ### Client
  11. - Reads one JSON command per input line and writes JSON event lines for started calls, progress, results, errors, and completion.
  12. - Supports `discover`, `list`, `call`, `cancel`, and `wait` commands.
  13. - Runs calls concurrently, up to eight active calls. Each active call uses its own connection; completed connections are reused from a connection pool when possible.
  14. - Shows progress for streamed analysis calls and supports cancellation and per-call timeouts.
  15. The client and server use the protocol version `2026-07-28`. The server binds to loopback (`127.0.0.1`) by design.
  16. ## Requirements
  17. - Python 3.10 or newer
  18. - No third-party packages are required
  19. ## Run
  20. From this directory, start the server in one terminal:
  21. ```sh
  22. python server.py --port 51000
  23. ```
  24. Then start the client in another terminal:
  25. ```sh
  26. python client.py --host 127.0.0.1 --port 51000
  27. ```
  28. Use `--help` with either script to see the available options. The server's `--analysis-delay` option controls the delay between analysis updates.
  29. The client accepts JSON-lines commands on standard input. For example:
  30. ```json
  31. {"op":"discover"}
  32. {"op":"list"}
  33. {"op":"call","name":"get_reading","arguments":{"station_id":"AU01"}}
  34. {"op":"wait"}
  35. ```
  36. To cancel a running call, use its request ID from the `started` event:
  37. ```json
  38. {"op":"cancel","id":1}
  39. ```
  40. ## Project files
  41. - `server.py` — TCP server and MCP request handling
  42. - `client.py` — interactive TCP client
  43. - `app_support.py` — shared command-line argument parsing
  44. - `support/` — schemas, sample readings, and Python tool helpers

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.