token-thesis
by web3blind
README.md
# Token Thesis
Evidence-first Solana token research and reassessment for AI agents, powered by **CoinGecko**.
A ticker is not an identity. A large pool is not a promise that an order can be sold. A report saved yesterday is not a fresh approval today.
Token Thesis combines a runnable Python CLI, standard stdio MCP server and an original [agent skill](skills/token-thesis/SKILL.md). CoinGecko provides the market/onchain evidence. Your host agent reasons about token economics, reads the cited project documents and saves its own economic conclusion. No second LLM subscription is required by this package.
**Read-only. No wallet access, trades, hosted account system or automatic investment/safety rating.**
## Setup
POSIX/Linux or macOS; Python 3.11+. State locking currently uses `fcntl` (native Windows is not supported).
```bash
git clone https://github.com/web3blind/token-thesis.git
cd token-thesis
python3 -m venv .venv
.venv/bin/python -m pip install -e '.[test]'
```
Set `COINGECKO_API_KEY` in the process environment or create a local `.env` using `.env.example`. Use an existing CoinGecko Pro/Analyst key through a secret manager or protected input. Do not paste credentials into chat, commands, README, screenshots or the public repository. Restrict `.env` to mode `0600`. `.env` and runtime state are excluded from Git.
```bash
.venv/bin/token-thesis --env-file .env ping
.venv/bin/token-thesis --env-file .env resolve BONK
```
Search returns exact name/symbol candidates from the first Solana pool-search page, not an exhaustive registry. For ambiguity, select the correct mint instead of taking the first result. Address syntax checks do not prove that the asset is authentic.
## Reproducible research path
BONK's Solana mint below was verified against CoinGecko's live token/coin responses; it is an example, not an endorsement.
```bash
.venv/bin/token-thesis --env-file .env --state-dir state analyze \
DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
.venv/bin/token-thesis --state-dir state list
.venv/bin/token-thesis --state-dir state show ANALYSIS_ID --format markdown
.venv/bin/token-thesis --env-file .env --state-dir state recheck ANALYSIS_ID
```
Replace `ANALYSIS_ID` with the returned snapshot ID. `show` and `list` work without API access. `analyze` reads one linked project homepage by default. Use `--no-web` to skip page fetching; `--source https://...` supplies up to three explicit project pages instead of the homepage. Source HTTP errors, oversized/JS/PDF limitations and missing provider coverage remain explicit.
For user-defined conditions, add for example:
```bash
.venv/bin/token-thesis analyze MINT \
--conditions '[{"metric":"token_reserve_usd","op":">=","value":"500000"}]'
```
This means **token-side reserves**, not total two-sided pool TVL or executable sell depth. Supported comparisons: `>`, `>=`, `<`, `<=`. Conditions are optional, user-defined and never trading permissions. A numeric match with an unknown upstream timestamp is not a fresh confirmation.
An agent can persist its economic interpretation using MCP `save_thesis` or the CLI:
```bash
.venv/bin/token-thesis save-thesis ANALYSIS_ID thesis.txt --ref token --ref info
```
References must identify actually available source IDs or saved-document URLs from that snapshot. Reference existence does not prove a claim's truth; the agent must still attribute its claims. This returns a new annotated snapshot ID without mutating the old one. Recheck that new ID to retrieve the previous reasoning alongside fresh evidence; prose is explicitly marked for agent review, not automatically reapproved.
## MCP connection
Start the server with absolute paths so the host's working directory cannot redirect state or secret lookup:
```bash
/absolute/path/token-thesis/.venv/bin/token-thesis-mcp \
--env-file /absolute/path/token-thesis/.env \
--state-dir /absolute/path/token-thesis/state
```
Generic MCP client configuration (replace paths):
```json
{
"mcpServers": {
"token-thesis": {
"command": "/absolute/path/token-thesis/.venv/bin/token-thesis-mcp",
"args": ["--env-file", "/absolute/path/token-thesis/.env", "--state-dir", "/absolute/path/token-thesis/state"]
}
}
}
```
For Hermes, register the same stdio command/args using the host's current MCP configuration instructions, and load `skills/token-thesis/SKILL.md` as the analysis workflow. This repository does not edit Hermes core, auto-register tools, restart a gateway or modify live configuration.
Tools:
- `resolve_token(query)` — mint candidates and search limitations.
- `analyze_token(mint, conditions?, project_urls?, fetch_sources?)` — evidence bundle and immutable snapshot.
- `save_thesis(analysis_id, thesis, evidence_refs)` — persist the host agent's attributed interpretation as a revision.
- `recheck_analysis(analysis_id, fetch_sources?)` — new snapshot, comparable deltas, source/document changes and previous reasoning.
- `list_analyses(limit?)` and `get_analysis(analysis_id, format?)` — local retrieval.
- `fetch_project_source(url)` — bounded public HTTPS reading; does not mutate prior snapshots.
## Data and economic method
CoinGecko Pro is the core factual dependency, not a decorative price widget:
- `/onchain/search/pools` — exact name/symbol resolution on Solana.
- `/onchain/networks/solana/tokens/{mint}` — prices, normalized supply, FDV, available market cap, token-side reserves and volume.
- `.../{mint}/info` — websites/socials/description, holder distribution and timestamps where covered.
- `.../{mint}/pools` — first-page pool sample with base/quote identities; local ranking by sampled pool reserve.
- `.../{mint}/top_holders` — beta address concentration data.
- `.../{mint}/ohlcv/day` — up to 30 daily candles and actual coverage window.
- `/coins/solana/contract/{mint}` — coin-level identity, cross-platform supply and valuation.
- `/coins/{id}/supply_breakdown` — only if the coin response explicitly says available.
Each metric carries its unit, scope, source ID, retrieval time and upstream update time if provided. Null is not zero. All computations use Decimal; raw JSON keeps decimal precision, text reports round numbers. Provider FDV is not silently replaced by price × total/max. Cross-platform coin supply is not presented as the Solana mint supply. Pool sample sums are not full-market totals.
The host agent analyzes necessity/demand, who funds rewards, emission versus actual product revenue, allocation and unlocks, liquidity versus dilution, holder attribution, revenue rights and governance/control. These conclusions require evidence beyond market numbers. The client deliberately leaves unsupported economic verdicts `not_established`; use the skill to synthesize and save a reasoned conclusion, never a fabricated score.
Supply breakdown and holder balances do **not** establish original team allocation or future unlocks. Unknown insiders are not independent owners. A governance token does not automatically grant cash-flow rights. Links and verification badges do not certify investment safety.
## Persistence and reassessment
`state/state.json` is a versioned, atomic index. `state/snapshots/ID.json` stores immutable research and annotated revisions. A POSIX lock prevents lost concurrent index updates. Rechecks save a new ID and never overwrite the initial snapshot.
Metrics are compared only for matching units and scopes; changed pool sets or measurement bases are reported separately. Missing evidence is not a negative market delta. Repeated upstream timestamps are flagged; a repeat call within CoinGecko's cache window is not independent confirmation. A changed sampled leading pool is not proof of total-market migration. A critical token-identity request failure creates no fake successful snapshot.
## Safety and limitations
- API key goes only in the fixed CoinGecko origin's request header. Redirects are refused; exceptions do not echo provider bodies, keys or headers.
- Provider requests have size/time limits and bounded retries for rate limits/transient server failures. The package does not request another key or buy a plan.
- Project text fetches allow only public HTTPS on port 443, validate DNS, pin the vetted IP for TLS, revalidate redirects, and enforce byte/time limits. They never carry the CoinGecko key.
- Document text, metadata and social links remain untrusted. No page text can grant new tool permissions. This is not a general browser, PDF reader, social sentiment monitor or complete security audit.
- No complete automatic vesting/insider attribution, no full-history exhaustiveness, no price-impact simulation, no automatic financial recommendation. A host agent must evaluate the evidence and unknowns.
- The stdio server is local and single-user. Do not expose it directly as a multi-user network service.
## Judge walkthrough and captured execution
This is a no-UI **agent tool product**, not an API dashboard: the original economic-analysis workflow is shipped inside the wheel and exposed as `token-thesis://workflow` over MCP (`token-thesis skill` over CLI). The host agent uses it to write and preserve its own attributed conclusion, then revisits the SAME reasoning and user conditions against new evidence. No second paid LLM is embedded in the package.
1. Install with the setup below, or with locked dependencies: `.venv/bin/python -m pip install -r requirements.lock` followed by `.venv/bin/python -m pip install -e . --no-deps`.
2. Start the stdio MCP server and read `token-thesis://workflow`. Resolve BONK, show the mint, analyze it, write a sourced assessment and save it with `save_thesis`.
3. Run `recheck_analysis` on the annotated ID. Open its returned ID in a NEW process: the comparison, baseline, prior reasoning, measurement scopes and observation freshness are saved, not merely remembered in chat.
4. Check a long-tail mint without a CoinGecko coin listing: `FnLox4hs8zB3YefUyBdwFtTmZm7cMaNSHr5utV4Yswrm` was live-verified on 3 December 2026. Its onchain endpoints worked; `/coins` returned 404 and the absent global supply/valuation evidence stayed unavailable. This is a technical coverage example, not a token endorsement.
Four screenshots from a **recorded actual CLI execution** (condensed-output observer, not a simulated product interface):




[Demo description and accessible transcript](docs/DEMO.md). [Example research export](docs/assets/sample-research.html). [Example persisted reassessment export](docs/assets/sample-recheck.html). These exports are real snapshots, **not current quotes**. No market change was inserted for a dramatic demo. The video is prepared locally; public video hosting and the final competition submission remain separate from this source publication.
## How CoinGecko API is used
CoinGecko supplies identity, prices, supply, valuation, reserves, pools, holders, history, links and observation metadata. Economic claims are linked back to these sources or explicitly read project documents. Missing coverage remains missing; market numbers never stand in for vesting, insider attribution or holder rights.
## How Solana is used
Every analysis is scoped to an exact 32-byte Solana mint. The product fetches Solana token/pool data, validates base/quote relationships and separates mint-level amounts from cross-platform coin supply. No wallet signature, transaction or program deployment is necessary for this read-only research workflow.
## Readable exports and offline history
```bash
.venv/bin/token-thesis --state-dir state show ANALYSIS_ID --language en --format markdown
.venv/bin/token-thesis --state-dir state show ANALYSIS_ID --language ru --format markdown
.venv/bin/token-thesis --state-dir state show ANALYSIS_ID --format html > report.html
.venv/bin/token-thesis skill
```
Report labels support English/Russian; saved assessment text stays in its original language. HTML is self-contained, uses escaped source text and a restrictive content-security policy, and loads no remote images or scripts. `list`, `show`, `save-thesis` and MCP local-state tools do not require a key. Only provider operations load credentials.
Rechecks persist exact comparison endpoints separately from annotated revision IDs. Scalar deltas include their own freshness; changed holders, candles, metadata, per-pool values, documents and supply breakdown are also detected. An advanced price-update timestamp does not certify fresh supply data. HTTP 200 and usable/citable evidence are distinct. Conditions use quoted decimal strings (or exact integers); binary float thresholds are refused. Numeric inputs outside the supported practical range (decimal exponent outside ±100 or strings longer than 256 characters) remain unavailable rather than overflowing the report.
Project fetches accept at most **2,000,000 bytes (2 MB)** and have a 20-second **total** subprocess deadline, including DNS, redirects and slow streaming, in addition to public-IP pinning. Oversized pages remain unavailable with `source_too_large` (also exposed by the standalone MCP source tool); the reader never silently treats a partial byte download as a complete source. Truncated text is labelled partial and its full fetched-text hash is retained. Explicit project URLs stay selected; discovered homepages are rediscovered on recheck.
## Development provenance
New implementation built on 2–3 December 2026 for Long Tail AI Agents. The package uses the public MCP SDK and CoinGecko endpoints, not an organizer starter with a new skin. Generic economic reasoning instructions are original; no private training chapters, private source messages, credentials or operator registration material are shipped.
## Verification
```bash
bash scripts/run_tests.sh -q
```
Tests use synthetic data, temporary state and a real MCP stdio round trip; they are not made-up live API responses. The runner unsets the real API key. Live verification is separate and requires an authorized key. See [VERIFY.md](VERIFY.md) for what was actually exercised and its limits.
## Attribution
Market and onchain data powered by [CoinGecko](https://www.coingecko.com/en/api). Official API documentation: [CoinGecko Docs](https://docs.coingecko.com/).
This is not an official CoinGecko product. The package does not ship a key or promise continued sponsored access. The current hackathon key expires on 31 December 2026; continued operation requires a suitable valid plan. Final hackathon submission and public video hosting are separate from this source release.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues