uid-generator-mcp
Standalone MCP server that issues globally unique 64-bit IDs (snowflake
layout). Inspired by 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
pip install -e .
python run_server.py # stdio transport
Tests
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.