Get Bridge Stats
get-bridge-statsRetrieve PulseChain bridge statistics including inflows, outflows, and net flow over the last 7 days to analyze cross-chain activity.
Instructions
Get PulseChain bridge statistics: inflows, outflows, net flow over the last 7 days.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inflow_usd | Yes | Total bridge inflows in USD over the last 7 days | |
| outflow_usd | Yes | Total bridge outflows in USD over the last 7 days | |
| net_flow_usd | Yes | Net flow (inflow - outflow) in USD | |
| daily | Yes | Daily bridge flow breakdown |
Implementation Reference
- mcp-server/src/index.ts:619-640 (registration)Registration of the 'get-bridge-stats' tool via server.registerTool with name, schema, and handler.
server.registerTool( 'get-bridge-stats', { title: 'Get Bridge Stats', description: 'Get PulseChain bridge statistics: inflows, outflows, net flow over the last 7 days.', outputSchema: z.object({ inflow_usd: z.number().describe('Total bridge inflows in USD over the last 7 days'), outflow_usd: z.number().describe('Total bridge outflows in USD over the last 7 days'), net_flow_usd: z.number().describe('Net flow (inflow - outflow) in USD'), daily: z.array(z.object({ date: z.string().describe('Date in ISO format'), inflow_usd: z.number().describe('Daily inflow in USD'), outflow_usd: z.number().describe('Daily outflow in USD'), }).passthrough()).describe('Daily bridge flow breakdown'), }).passthrough(), annotations: READ_ONLY_ANNOTATIONS, }, async () => { const data = await fetchJSON(`${SAFETY}/api/v1/bridge/stats`) return wrapResult(data) } ) - mcp-server/src/index.ts:624-633 (schema)Output schema defining the response shape: inflow_usd, outflow_usd, net_flow_usd, and daily array of date/inflow/outflow.
outputSchema: z.object({ inflow_usd: z.number().describe('Total bridge inflows in USD over the last 7 days'), outflow_usd: z.number().describe('Total bridge outflows in USD over the last 7 days'), net_flow_usd: z.number().describe('Net flow (inflow - outflow) in USD'), daily: z.array(z.object({ date: z.string().describe('Date in ISO format'), inflow_usd: z.number().describe('Daily inflow in USD'), outflow_usd: z.number().describe('Daily outflow in USD'), }).passthrough()).describe('Daily bridge flow breakdown'), }).passthrough(), - mcp-server/src/index.ts:636-639 (handler)Handler function that fetches bridge stats from the safety API endpoint and wraps the result.
async () => { const data = await fetchJSON(`${SAFETY}/api/v1/bridge/stats`) return wrapResult(data) } - mcp-server/src/index.ts:54-73 (helper)fetchJSON helper used by the handler to make HTTP requests with auth and timeout.
async function fetchJSON(url: string): Promise<any> { const headers: Record<string, string> = { 'Accept': 'application/json' } if (HAS_API_KEY) headers['Authorization'] = `Bearer ${API_KEY}` const controller = new AbortController() const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS) try { const res = await fetch(url, { headers, signal: controller.signal }) if (!res.ok) { if (res.status === 401 || res.status === 403) { throw new Error( `API ${res.status}: This endpoint requires a valid API key. ` + `Get one at ${PRICING_URL}` ) } throw new Error(`API request failed with status ${res.status}`) } return res.json() } finally { clearTimeout(timer) }