Back to search
MCP-server-and-client
MCP serverGitHub
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
Markdown
[](/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
- # MCP Server and Client (Python)
- A Python implementation of an MCP-style client and server over TCP, with JSON-RPC messages, tool discovery, reading queries, and streamed analysis.
- ## What it does
- ### Server
- - 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.
- - Keeps client connections open when requested and can process multiple requests on the same connection.
- - Supports server discovery, tool listing, and tool calls for `get_reading`, `get_history`, and `analyse_readings`.
- - Streams analysis progress events and a final result. If the client cancels or disconnects, the server stops that analysis.
- - Loads its sample readings from `support/data/readings.json` and uses the helpers in `support/python/` to compute tool results.
- ### Client
- - Reads one JSON command per input line and writes JSON event lines for started calls, progress, results, errors, and completion.
- - Supports `discover`, `list`, `call`, `cancel`, and `wait` commands.
- - 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.
- - Shows progress for streamed analysis calls and supports cancellation and per-call timeouts.
- The client and server use the protocol version `2026-07-28`. The server binds to loopback (`127.0.0.1`) by design.
- ## Requirements
- - Python 3.10 or newer
- - No third-party packages are required
- ## Run
- From this directory, start the server in one terminal:
- ```sh
- python server.py --port 51000
- ```
- Then start the client in another terminal:
- ```sh
- python client.py --host 127.0.0.1 --port 51000
- ```
- Use `--help` with either script to see the available options. The server's `--analysis-delay` option controls the delay between analysis updates.
- The client accepts JSON-lines commands on standard input. For example:
- ```json
- {"op":"discover"}
- {"op":"list"}
- {"op":"call","name":"get_reading","arguments":{"station_id":"AU01"}}
- {"op":"wait"}
- ```
- To cancel a running call, use its request ID from the `started` event:
- ```json
- {"op":"cancel","id":1}
- ```
- ## Project files
- - `server.py` — TCP server and MCP request handling
- - `client.py` — interactive TCP client
- - `app_support.py` — shared command-line argument parsing
- - `support/` — schemas, sample readings, and Python tool helpers
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.