Observability tools for FOC (Filecoin Onchain Cloud).
Provides AI agents and humans with access to:
- Indexed event history from all FOC contracts (SQL)
- Live contract state via Lotus RPC (providers, datasets, payment rails, pricing)
- DealBot quality metrics (deal success, IPFS retrieval, provider health)
- Proving health computed from indexed PDPVerifier events (fault rates, weekly trends), cross-checked against the PDP Explorer subgraph
This repository doesn't publish an endpoint: run your own, or ask for an official one that's actively indexing. Read Security model before exposing yours.
MCP clients with Streamable HTTP support connect directly:
https://your-server.example.com/mcp
Claude Code (streamable HTTP):
# Project-local (default)
claude mcp add --transport http foc-observer https://your-server.example.com/mcp
# Shared with all projects
claude mcp add --transport http --scope user foc-observer https://your-server.example.com/mcpClaude.ai: Add as a connector in Settings > Connectors with the /mcp URL.
For MCP clients that only support stdio transport:
npx @filoz/foc-observer serve --api-url https://your-server.example.comClaude Code (stdio):
claude mcp add --transport stdio foc-observer -- npx @filoz/foc-observer serve --api-url https://your-server.example.comClaude Desktop / Cursor / other MCP hosts, add to your MCP config (e.g. claude_desktop_config.json):
{
"mcpServers": {
"foc-observer": {
"command": "npx",
"args": ["@filoz/foc-observer", "serve", "--api-url", "https://your-server.example.com"]
}
}
}--scope local(default): available only to you in the current project--scope project: shared with everyone via.mcp.json(checked into repo)--scope user: available to you across all projects
Works with any MCP-compatible client: use the HTTP endpoint where Streamable HTTP is supported, and the stdio proxy elsewhere. The client package README has a compatibility table.
The same data is available over REST, with CORS enabled:
# Network status
curl https://your-server.example.com/status
# SQL query against indexed events
curl -X POST https://your-server.example.com/sql \
-H "Content-Type: application/json" \
-d '{"network":"mainnet","sql":"SELECT provider_id, COUNT(*) as datasets FROM fwss_data_set_created GROUP BY provider_id"}'
# Live contract state
curl https://your-server.example.com/providers/mainnet
curl https://your-server.example.com/dataset/mainnet/100
curl https://your-server.example.com/rail/mainnet/100
# Proving health (from indexed PDPVerifier events)
curl https://your-server.example.com/proving/providers/mainnet
# DealBot quality metrics
curl https://your-server.example.com/metrics/providers/mainnet?hours=7222 tools across 6 data sources:
| Category | Tools | Source |
|---|---|---|
| Knowledge | get_system_context |
Embedded protocol docs |
| Events | query_sql, list_tables, describe_table, get_status |
Ponder-indexed Postgres |
| Contract State | get_providers, get_provider, get_dataset, get_dataset_proving, get_rail, get_pricing, get_account, get_auction |
Lotus RPC (eth_call) |
| Quality Metrics | get_dealbot_stats, get_dealbot_providers, get_dealbot_provider_detail, get_dealbot_daily, get_dealbot_failures |
BetterStack / DealBot API |
| Proving Health | get_proving_health, get_proving_dataset |
Indexed PDPVerifier events |
| Proving cross-check | get_proving_health_goldsky, get_proving_dataset_goldsky |
PDP Explorer subgraph (Goldsky) |
Analytical tools require i_have_read_the_system_context: true. Call get_system_context first with {} to receive the complete protocol and data-interpretation guide. Use list_tables and describe_table for the database schema and field units.
A deployment serves an unauthenticated public API: anyone who can reach it can run read-only SQL over the indexed tables (POST /sql, query_sql) and call every route and tool, from any origin.
Limits. Up to 50,000 SQL characters, 30 seconds per statement, 10,000 result rows and 16 MiB of compact result JSON. PostgreSQL checks each SELECT row against 4 MiB of record text before transfer. Each network has a 12-connection pool. Select fewer or smaller columns for a row-size error; paginate for a result-size error.
Layers.
- SQL validator (
server/src/sql-validator.ts). Parses each query with the Postgres parser and accepts only allow-listed statements, syntax, functions, types and tables. The server's own queries pass through it too, with caller values bound as parameters. - Database role
foc_observer_query.SELECTon the published views inpublic, granted by name frompostgres/bootstrap.sql, plus the catalog metadata every Postgres role can read. It can't write, create objects, read Ponder'sdata_v*or RPC cache schemas, or use file and program functions. The server checks the role at startup and exits if it can do more.
- Query as
foc_observer_query. Compose sets this up: passwordless database URLs withPGPASSWORDset separately for the server and indexers, apostgres-query-roleservice that installs the view allow-list before Ponder starts, and an event trigger that grantsSELECTas Ponder publishes each view. - Distinct passwords. Generate
FOC_DATABASE_OWNER_PASSWORDandFOC_QUERY_DATABASE_PASSWORDseparately, for example withopenssl rand -hex 32. - Existing volumes need the one-time credential migration, which rotates the owner password and keeps the live indexers; it doesn't need a reindex.
- Private Postgres. Compose doesn't publish database ports.
- An isolated host, on a network segment without wallets, private keys, storage provider infrastructure (Curio, YugabyteDB, a Lotus node with a wallet) or credentials for other systems.
- A reverse proxy as the only way in, terminating TLS and rate-limiting; the server does neither. Compose binds the server to
127.0.0.1unlessFOC_SERVER_BINDsays otherwise. For a remote proxy, setFOC_SERVER_BINDto an interface address and restrict the port, by firewall or port forward, to the proxy's address. For a proxy container on the Compose network, drop theportsmapping. - Restricted Lotus access. Remote RPC needs nothing extra. For loopback-only Lotus, enable the
lotusprofile withLOTUS_PROXY_BINDset to the Docker bridge gateway, firewall ports 11234 and 11235, and use a read-only Lotus gateway.
Logs. JSON request logs go to stdout; Compose rotates them at 50 MB, keeping three files. Successful SQL requests log the first 2,000 characters of the query, so restrict log access. Other entries carry bounded metadata, without tool arguments, backend diagnostics, connection URLs or response bodies. Callers get a fixed message for unknown backend errors.
The server logs its role check at startup, naming the role Postgres reports rather than the configured user:
docker compose logs foc-observer | grep 'query role'
# mainnet: query role "foc_observer_query" verified, rpc host ...For an older build that doesn't log it, ask Postgres which logins the server's sessions use, making a request first because the server closes idle connections after a few seconds:
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' "$(docker compose ps -q foc-observer)")
curl -s http://127.0.0.1:17824/status > /dev/null # your FOC_SERVER_BIND address and FOC_SERVER_PORT
docker compose exec postgres-mainnet psql -U ponder -d ponder -c \
"SELECT usename, count(*) FROM pg_stat_activity WHERE host(client_addr) = '${ip%% *}' GROUP BY usename"
# every row should be foc_observer_query; no rows proves nothing, so rerun the last two commands
# repeat against postgres-calibnetIf a deployment has ever queried as ponder or another owner or superuser, treat the database host and anything it can reach as compromised: superuser SQL can run commands on the host. Rotate the credentials it can reach, and look for unexpected roles, functions, large objects and files.
Report suspected vulnerabilities privately as the FilOzone security policy describes, not in a public issue.
- Docker and Docker Compose
- Lotus nodes or a public RPC such as Glif; deep history needs an archival node
# Clone
git clone https://github.com/FilOzone/foc-observer.git
cd foc-observer
# Create Docker volumes for Ponder data
docker volume create ponder_pgdata-calibnet
docker volume create ponder_pgdata-mainnet
# Configure
cp .env.example .env
# Fill in both RPC endpoints, the public URL and two distinct database passwords.
# Start
docker compose up -dindexer/ponder.config.ts is baked into the indexer image, so rebuild after changing it or the indexer's dependencies:
docker compose up -d --build ponder-calibnet ponder-mainnetAll configuration is via .env; .env.example is the template.
| Variable | Required | Description |
|---|---|---|
FOC_API_URL |
Yes | Public URL of your deployment |
FOC_SERVER_PORT |
Yes | HTTP server port |
FOC_SERVER_BIND |
No | Address Compose publishes the server on (default 127.0.0.1) |
FOC_DATABASE_OWNER_PASSWORD |
Yes | Owner login for the indexer and provisioning |
FOC_QUERY_DATABASE_PASSWORD |
Yes | Separate password for the read-only server login |
FOC_DATABASE_OWNER_PREVIOUS_PASSWORD |
Rotation only | Current owner password while the provisioner rotates populated volumes to FOC_DATABASE_OWNER_PASSWORD; unset afterwards |
CALIBNET_RPC_URL |
Yes | Calibnet Lotus RPC endpoint |
MAINNET_RPC_URL |
Yes | Mainnet Lotus RPC endpoint |
LOTUS_PROXY_BIND |
Local proxy only | Docker bridge gateway accessible as host.docker.internal |
LOTUS_CALIBNET_PORT |
No | Local Lotus port for the socat proxy (default 2235) |
LOTUS_MAINNET_PORT |
No | Local Lotus port for the socat proxy (default 2234) |
BETTERSTACK_CH_USER |
No | BetterStack ClickHouse username (enables DealBot metrics) |
BETTERSTACK_CH_PASSWORD |
No | BetterStack ClickHouse password |
CALIBNET_DATA_SCHEMA |
No | Active Ponder data schema (default data_v1); bump on reindex |
MAINNET_DATA_SCHEMA |
No | Active Ponder data schema (default data_v1); bump on reindex |
Outside Compose, set FOC_CALIBNET_QUERY_DATABASE_URL and FOC_MAINNET_QUERY_DATABASE_URL yourself, each as foc_observer_query. Neither has a default.
Remote RPC (e.g. Glif): set CALIBNET_RPC_URL and MAINNET_RPC_URL, and start without lotus-proxy:
docker compose up -d postgres-calibnet postgres-mainnet ponder-calibnet ponder-mainnet foc-observerLocal Lotus nodes: lotus-proxy, the only container with host networking, forwards two host ports into the Docker bridge network:
docker compose --profile lotus up -dInternet
--> reverse proxy (TLS, rate limiting; yours to provide)
--> foc-observer (server, port FOC_SERVER_PORT)
Docker bridge network:
foc-observer --> postgres-calibnet, postgres-mainnet (as foc_observer_query)
--> lotus-proxy (RPC, via the bridge gateway)
ponder-calibnet --> postgres-calibnet (as ponder, the owner)
ponder-mainnet --> postgres-mainnet (as ponder, the owner)
Host network (lotus-proxy only):
socat :11234 --> Lotus mainnet gateway
socat :11235 --> Lotus calibnet gateway
The server and indexer containers run as the unprivileged node user. The server also calls the Goldsky subgraph, DealBot and BetterStack over HTTPS.
Follow the single-network reindex runbook and its worked Compose override. It builds alongside the live schema, checks both at a common finalized block, then promotes the tested image on that network only. The runbook covers API verification and switching back to the retained schema and code.
cd client
npm install
npm run build
npm testcd server
npm install
npm run build
npm testThe indexer runs on filecoin-ponder, a Ponder fork with Filecoin support, installed from npm under the name ponder. PONDER_NETWORK selects mainnet (the default) or calibnet, and PONDER_STRICT_ENV=true, as Compose sets it, makes PONDER_NETWORK, DATABASE_URL and RPC_URL mandatory.
Useful commands:
cd indexer
npm run dev:mainnet
npm run dev:calibnet
npm run codegen:mainnet
npm run codegen:calibnet
npm test
npm run typecheckTo regenerate contract ABIs:
cd indexer
./scripts/generate-abis.sh # Uses the default ref pinned in the script
./scripts/generate-abis.sh main # Or specify a refThe FWSS ABI is a union of the published contract ABI, events from FWSS's internal libraries (which forge leaves out of the contract ABI), and legacy events older deployments emit, so one ABI serves every deployed version. See indexer/abis/fwss-extra-events.json.
FOC (Filecoin Onchain Cloud) is a decentralized storage service built on Filecoin. Clients pay storage providers to store data, with payments and proofs of data possession managed entirely on-chain via smart contracts:
- FilecoinPay: generic payment rail infrastructure (streaming and one-time payments)
- PDPVerifier: proof of data possession protocol
- FWSS + ServiceProviderRegistry + SessionKeyRegistry: warm storage service, provider registration, delegated auth
Apache-2.0 OR MIT