bitcoin_price
Retrieve current Bitcoin price data to monitor cryptocurrency market values and track real-time price changes for investment decisions.
Instructions
Get realtime bitcoin price
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/BitcoinPrice.ts:15-34 (handler)The toolCall method, which is the core handler executing the bitcoin_price tool logic: fetches Bitcoin price data from Coincap API and formats response.toolCall = async () => { try { const response = await fetch(BITCOIN_PRICE_URL); if (!response.ok) { throw new Error("Error fetching coincap data"); } const body = await response.json(); return { content: [{ type: "text", text: `${JSON.stringify(body.data)}` }], }; } catch (error) { return { content: [ { type: "error", text: JSON.stringify((error as any).message) }, ], }; } };
- src/tools/BitcoinPrice.ts:7-13 (schema)Tool definition schema specifying name, description, and empty input schema (no parameters).toolDefinition: Tool = { name: this.name, description: "Get realtime bitcoin price", inputSchema: { type: "object", }, };
- src/utils/toolLoader.ts:50-92 (registration)loadTools dynamically scans src/tools for tool JS files, imports and instantiates them (including BitcoinPriceTool), and createToolsMap indexes by name for dispatch.export async function loadTools(): Promise<BaseTool[]> { try { const toolsPath = await findToolsPath(); const files = await fs.readdir(toolsPath); const tools: BaseTool[] = []; for (const file of files) { if (!isToolFile(file)) { continue; } try { const modulePath = `file://${join(toolsPath, file)}`; const { default: ToolClass } = await import(modulePath); if (!ToolClass) { continue; } const tool = new ToolClass(); if ( tool.name && tool.toolDefinition && typeof tool.toolCall === "function" ) { tools.push(tool); } } catch (error) { console.error(`Error loading tool from ${file}:`, error); } } return tools; } catch (error) { console.error(`Failed to load tools:`, error); return []; } } export function createToolsMap(tools: BaseTool[]): Map<string, BaseTool> { return new Map(tools.map((tool) => [tool.name, tool])); }
- src/index.ts:40-54 (registration)MCP server request handler for CallTool that retrieves the tool instance from map by name and invokes its toolCall method.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (!toolsMap) { throw new Error("Tools not initialized"); } const tool = toolsMap.get(request.params.name); if (!tool) { throw new Error( `Unknown tool: ${request.params.name}. Available tools: ${Array.from( toolsMap.keys() ).join(", ")}` ); } return tool.toolCall(request); });
- src/constants.ts:1-1 (helper)API URL constant used in the bitcoin_price tool handler to fetch Bitcoin data.export const BITCOIN_PRICE_URL = "https://api.coincap.io/v2/assets/bitcoin";