get_priority_fee
Fetch a suggested priority fee to include transactions in the next VeChain mainnet blocks, helping users optimize transaction inclusion timing.
Instructions
Fetch a suggested priority fee for including a transaction in the next blocks from VeChain mainnet.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:410-459 (handler)The handler function (callback) that fetches the suggested priority fee from the VeChain Thorest API endpoint `/fees/priority`. Handles fetch, error cases, and timeout.callback: async () => { const base = isMainnet ? vechainConfig.mainnet.thorestApiBaseUrl : vechainConfig.testnet.thorestApiBaseUrl; const url = `${base}/fees/priority`; const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), isMainnet ? vechainConfig.mainnet.controllerAbortTimeout : vechainConfig.testnet.controllerAbortTimeout); try { const res = await fetch(url, { signal: controller.signal }); if (!res.ok) { const bodyText = await res.text().catch(() => ""); throw new Error( `VeChain node responded ${res.status} ${res.statusText}${bodyText ? `: ${bodyText}` : "" }` ); } const data = await res.json(); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { const isAbort = (err as Error)?.name === "AbortError"; return { content: [ { type: "text", text: JSON.stringify( { error: isAbort ? "Request timed out" : "Failed to fetch priority fee", reason: String((err as Error)?.message ?? err), url, }, null, 2 ), }, ], }; } finally { clearTimeout(timeout); } }
- src/tools.ts:409-409 (schema)The input schema for the tool, which is empty as no parameters are required.inputSchema: {},
- src/server.ts:74-92 (registration)Registration of the get_priority_fee tool (along with other vechainTools) to the MCP server using server.registerTool, wrapping the callback.for (const t of vechainTools) { server.registerTool( t.name, { title: t.name, description: t.description, inputSchema: t.inputSchema }, async (args) => { const result = await t.callback(args); return { content: result.content.map(item => ({ ...item, type: "text" as const })) }; } ); }
- src/tools.ts:27-27 (registration)Export of the vechainTools array containing the tool definition, which is imported and used for registration.export const vechainTools: VeChainTool[] = [
- src/tools.ts:406-460 (handler)Full tool object definition including name, title, description, schema, and handler callback.name: "get_priority_fee", title: "Suggest a priority fee", description: "Fetch a suggested priority fee for including a transaction in the next blocks from VeChain mainnet.", inputSchema: {}, callback: async () => { const base = isMainnet ? vechainConfig.mainnet.thorestApiBaseUrl : vechainConfig.testnet.thorestApiBaseUrl; const url = `${base}/fees/priority`; const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), isMainnet ? vechainConfig.mainnet.controllerAbortTimeout : vechainConfig.testnet.controllerAbortTimeout); try { const res = await fetch(url, { signal: controller.signal }); if (!res.ok) { const bodyText = await res.text().catch(() => ""); throw new Error( `VeChain node responded ${res.status} ${res.statusText}${bodyText ? `: ${bodyText}` : "" }` ); } const data = await res.json(); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { const isAbort = (err as Error)?.name === "AbortError"; return { content: [ { type: "text", text: JSON.stringify( { error: isAbort ? "Request timed out" : "Failed to fetch priority fee", reason: String((err as Error)?.message ?? err), url, }, null, 2 ), }, ], }; } finally { clearTimeout(timeout); } } },