# Text stats MCP

Count words in an analyst's text using Python 3 and the standard library. The server separates words on Unicode whitespace. Punctuation belongs to the adjacent word. Empty or whitespace-only text yields zero. It accepts up to 65,536 UTF-8 bytes and returns only the count.

## Use it in the shared pilot

Choose **Use Text stats** in the shared marketplace, sign in, and enter your
text. The Hub invokes this exact embedded stdio server once per request. The
browser receives only `word_count`. [Shared pilot quickstart](../../docs/quickstart.md)

## Use it locally

Configure a stdio MCP client with `python3` as the command and `["-I", "-S", "-B", "/absolute/path/to/server.py"]` as the arguments. The server negotiates MCP protocol version `2025-06-18`. Each JSON-RPC message uses one line on stdin or stdout. No configuration files, dependencies or credentials are needed.

After initialization, list tools and call `word_count` with the following arguments.

```json
{"text":"  Quarterly   revenue increased.\n"}
```

The structured result is `{"word_count":3}`. Invalid arguments return JSON-RPC error `-32602`. The server reads and writes only the protocol streams. It does not echo the text in its result or errors.

## Deploy on the hub

In a managed workspace, select the built-in **Text stats** profile, leave **Private instance** checked and click **Deploy instance**. Connect an MCP client to the returned HTTPS endpoint using your own bearer token.

To exercise the upload flow instead, upload [server.py](server.py) as **Python stdio source**. Inspect the uploaded bytes and verify their SHA-256 digest. An administrator can approve the package with the tool array in [tools.json](tools.json). This file must agree with the running server's actual `tools/list` response. Select the newly approved package to deploy an instance.
