Skip to main content
Glama
README.md
# Hive MCP

Experimental v0.6.0 unified local stdio MCP for Hive and Hive Engine. Based on [gluneau/hive-mcp-server](https://github.com/gluneau/hive-mcp-server) (ISC, original license preserved). Dynamic RPC design inspired by the [official devportal MCP](https://github.com/openhive-network/devportal/tree/develop/mcp), independently implemented in TypeScript against the public OpenRPC interface.

## Install

Node.js 22+.

```sh
git clone https://github.com/faireye-hive/hive-mcp.git
cd hive-mcp
npm ci
npm run build
npm start
```

MCP client configuration:

```json
{"mcpServers":{"hive":{"command":"node","args":["/absolute/path/hive-mcp/dist/index.js"]}}}
```

## Tools

Inherited: get_account_info, get_account_history, get_vesting_delegations, get_post_content, get_posts_by_tag, get_posts_by_user, get_chain_properties.

Added: list_methods, get_method_schema, hive_rpc_call, fetch_doc_page, get_hive_power, get_engine_tokens, get_engine_balances, get_token_price, get_liquidity_pools, get_liquidity_positions, get_latest_replies, get_latest_snaps.

The catalog is lazily fetched from https://developers.hive.io/openrpc.json. Set HIVE_OPENRPC_PATH to a trusted local JSON snapshot for offline catalog lookup. Only permitted read method namespaces/prefixes are callable. Not all documented methods are enabled or supported by all nodes.

## Hive Engine generic tools (0.3.0)

Reference: [JSON-RPC server](https://github.com/hive-engine/hivesmartcontracts-wiki/blob/main/JSON-RPC-server.md), [contract index](https://github.com/hive-engine/hivesmartcontracts-wiki/blob/main/Contract-Action-Index.md), [market](https://github.com/hive-engine/hivesmartcontracts-wiki/blob/main/Market-Smart-Contract.md), [NFT](https://github.com/hive-engine/hivesmartcontracts-wiki/blob/main/NFT-Contracts.md).

| Tool | Purpose |
|---|---|
| engine_list_contracts | Search 25 documented reference contracts (not live enumeration) |
| engine_get_contract | Live contract metadata, no source code |
| engine_list_tables | Live deployed table discovery |
| engine_find | Paginated read with query, indexes and 0/1 projection |
| engine_find_one | One matching row or null |
| engine_get_transaction | Sidechain transaction and logs |
| engine_get_block | Sidechain block |
| engine_get_latest_block | Latest sidechain block |
| engine_get_block_by_hive | Block by reference Hive block number |
| engine_get_status | Node status and disabled methods |
| get_engine_order_book | Buy or sell orders by price |
| get_engine_trades | Recent trades (contract retains roughly 24h) |
| get_engine_delegations | Incoming/outgoing delegations |
| get_engine_pending_unstakes | Pending unstakes |
| get_engine_pending_undelegations | Undelegation cooldowns |
| get_engine_nft_collections | Collection definitions |
| get_engine_nft_instances | Collection instances, optionally by account |

Example MCP arguments for engine_find:

```json
{"contract":"tokens","table":"balances","query":{"account":"alice"},"limit":20,"offset":0,"project":{"symbol":1,"balance":1,"stake":1}}
```

New paginated tools return rows, returned, limit, offset and nextOffset (a full page indicates a possible next page, not proof of more rows). Use smaller pages or a projection if the general response limit is hit. Older tools keep their array format. Generic queries support a bounded subset of Mongo selectors, no executable or regex operators. The fixed endpoints are /rpc/contracts and /rpc/blockchain on api.hive-engine.com. No broadcast or contract actions. Live RPC availability and fields must still be verified. Block ranges are intentionally excluded because public nodes frequently disable the expensive method.

## Hive social and HAFSQL (0.4.0)

Social tools: get_hive_profile, get_hive_followers, get_hive_following, get_hive_community, list_hive_communities, get_community_subscribers, get_hive_subscriptions, get_community_posts, get_hive_account_posts, get_hive_notifications, get_hive_discussion, get_snaps_page. Account tools: get_hive_balances, get_hive_rc.

For Snaps, use get_snaps_page with sort=latest or votes, limit=10, offset=0. Reuse the returned permlink for subsequent pages. This ranks the direct replies fetched from Hive; it does not yet paginate upstream RPC or support nested Snaps. Large upstream responses may exceed the RPC cap.

### HAFSQL REST

Source: https://rpc.mahdiyari.info/hafsql/openapi.json. The live catalog determines which GET paths are available. Use hafsql_list_endpoints, hafsql_get_endpoint, then hafsql_rest_get. Unsupported endpoints, unresolved parameter references and non-GET operations fail closed. Set HAFSQL_OPENAPI_PATH to a trusted local schema snapshot if desired. The test fixture is synthetic, not a claim about live routes.

### Optional PostgreSQL

Documentation: https://mahdiyari.gitlab.io/hafsql/. Install the PostgreSQL client (Ubuntu/Kubuntu: sudo apt install postgresql-client). SQL is disabled by default. In the MCP process environment set HAFSQL_SQL_ENABLED=1 and HAFSQL_SQL_PASSWORD to the published public-role password from the documentation. Host, port, database and public role are fixed. The connection requires TLS verify-full and a trusted CA; configure HAFSQL_SSLROOTCERT if needed. No plaintext fallback. Use hafsql_sql_status (configuration only), hafsql_list_tables, hafsql_describe_table, and hafsql_query_table.

SQL tools accept only the hafsql schema, explicit columns, 1–8 filters (eq/gte/lte), optional ordering and up to 50 rows. No arbitrary SQL, joins, writes or function calls from the model. Values are quoted via psql variables, read-only transactions, timeouts, a concurrency limit and a request cap. Prefer REST/RPC where available; use selective filters to avoid expensive scans. The PostgreSQL public role and service availability are externally controlled. Neither provider has been live-tested yet. No automatic cross-provider fallback is claimed.

## Performance and provider routing (0.5.0)

- get_query_route: takes a query category and recommends only relevant provider/tools, without network calls. The caller must select a category; no LLM or natural-language classification is embedded.
- get_provider_status: observed RPC latency, successes, failures, unsupported methods, cooldowns, cache stats and local HTTP limits; unobserved nodes are not verified.
- Extension Hive RPC reads use sequential failover across api.hive.blog, api.deathwing.me and api.openhive.network. Hive Engine contract reads can fall back to api.primersion.com/contracts; sidechain block RPC still has one endpoint. Method-not-found is remembered per node for 5 minutes, transient failures cool down a node for 15 seconds. Invalid params and local limits do not trigger retries. Up to 3 candidates, 7s timeout per HTTP attempt.
- Reference nodes: https://developers.hive.io/quickstart/hive_full_nodes.html and https://hivedocs.info/howto/javascript/tutorials/2026/02/20/hive-javascript-tutorial-comprehensive-wallet-checker-tool.html. Nodes have not been live-tested in this release.
- In-memory RPC cache: 10-second TTL, max 128 entries and 4 MB of serialized data; identical concurrent requests coalesce. Set HIVE_MCP_CACHE=0 to disable stored results. No persistent cache or stale fallback. HTTP extension limit: 60 attempts/minute, 4 concurrent requests. SQL and legacy DHive are separately limited/configured.
- HIVE_MCP_MAX_RESPONSE_CHARS=8000 is a useful starting point for a small local model; default 24000, valid range 2000–24000. This is a character limit, not a token guarantee. JSON compacts before truncation; paginated replies retain actual rows and adjust the cursor to avoid skipping omitted rows. If even one row cannot fit, reduce selected fields/body size. Oversized legacy arrays may become a tagged rows envelope.
- No automatic cross-provider substitution between HAFSQL and Hive RPC: equivalence of schemas/semantics must be validated first. REST uses fixed host and SQL remains opt-in.

## Tool discovery and MCP resources (0.6.0)

- search_tools: local Portuguese/English keyword search, optional provider filter, up to 20 compact matches.
- suggest_tools: deterministic ranking for natural-language requests; returns up to 10 candidates (default 3), never executes them. No separate LLM or embedding model required. Scores are ranking heuristics, not probabilities.
- Example: {"query":"saldo do token BEE"} -> get_engine_balances; {"query":"qual meu Hive Power"} -> get_hive_power.
- list_methods and hafsql_list_endpoints now use bilingual synonym ranking. The OpenRPC and HAFSQL catalogs refresh lazily after five minutes.
- hive_rpc_call validates explicitly declared required fields, positional/named structure and simple types; inferred OpenRPC schemas are not a complete chain type system. Complex schema references are not fully resolved.
- MCP resources: hive://tools/catalog, hive://schema/openrpc, hive://method/{name}, hive://engine/contracts, hive://schema/hafsql. Some resources need a network connection or local schema snapshot. Resources follow the response character budget.
- Tool index is local and manually curated; the smoke test checks registered names and count. SQL recommendations respect the opt-in configuration. Unknown intentions may yield no results or imperfect ranking.
- Dependency audit warning: the 0.5.0 CI npm ci reported 26 vulnerabilities (3 critical). Runtime impact is not yet triaged. Keep this experimental MCP local/read-only until dependencies are reviewed; do not expose it publicly.

## Security

Read-only registered tools. Do not configure private keys. Original signing and broadcasting source is retained but not registered. External signing and trusted user approval are future work. New extension layer uses fixed endpoints, no redirects, timeouts, rate limits and bounded response sizes. Inherited DHive tools need a separate resource-limit and security review. Treat all post content and docs as untrusted data, not instructions. Do not expose this stdio server as a public service.

## Tests

```sh
npm run build
npm test
npm run test:smoke
```

Default tests are offline and use no credentials. The smoke test starts the built MCP over stdio and verifies the tool list. Upstream tests remain available via npm run test:legacy; some call real nodes. Never use real keys during testing.

## Development continuity

Read [plano.md](plano.md) and [estado.md](estado.md) before changing the project. Update both as work progresses. The code is published, but test success must be confirmed in CI before declaring a stable release.

## Roadmap

- Validate build and API behavior against live nodes, especially Hive Engine and Snap container discovery.
- Improve pagination, nested replies, large threads and context budgets.
- Add Portuguese search aliases, caching and node failover.
- Add communities, RC, witnesses and DHF convenience tools.
- Add external signing with explicit approvals before enabling writes.
- Audit dependencies and inherited tools.

## License

ISC; see LICENSE. No official affiliation implied.