Metadata-Version: 2.4
Name: uid-generator-mcp
Version: 0.1.0
Summary: Standalone snowflake unique-ID issuing MCP server (pure Python, no JVM).
License: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp<2,>=1.0
Dynamic: license-file

<!-- mcp-name: io.github.tanbopiao/uid-generator-mcp -->
# uid-generator-mcp

Standalone MCP server that issues globally unique 64-bit IDs (snowflake
layout). Inspired by [baidu/uid-generator](https://github.com/baidu/uid-generator)
(Apache-2.0), preserved and re-implemented in pure Python — no JVM needed.

## Layout

```
sign(1) | timestamp(41, ms since 2026-01-01) | worker(10) | sequence(12)
```

- 4096 IDs per ms per worker, 1024 workers, ~69 years of headroom.
- Clock-rollback policy follows the upstream spirit: small rollbacks
  (≤5 ms) spin-wait; larger rollbacks are refused with
  `ClockRollbackError` instead of risking duplicates.
- Worker IDs auto-allocate against a local lease file so multiple
  processes on one machine do not collide; override with
  `UID_MCP_WORKER_ID`.

## Tools

| tool | purpose |
| --- | --- |
| `issue_id` | issue one unique ID |
| `issue_batch` | issue 1–1000 IDs, increasing in issue order |
| `decode` | parse an ID back to timestamp / worker / sequence |
| `worker_info` | show worker id and bit layout |

## Run

```bash
pip install -e .
python run_server.py          # stdio transport
```

## Tests

```bash
python3 -m unittest discover tests -v
```

Covers: single-thread burst uniqueness (5000 IDs), 8-thread concurrency
uniqueness (4000 IDs), monotonicity, decode round-trip, worker range and
lease allocation.

## License

Apache-2.0. The upstream project is preserved under
[tanbopiao/uid-generator](https://github.com/tanbopiao/uid-generator).
