list_assets
Retrieve comprehensive cryptocurrency market data to access real-time prices and asset information for analysis and tracking.
Instructions
Get all available crypto assets
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/ListAssets.ts:15-36 (handler)The `toolCall` method that executes the tool logic: fetches crypto assets data from the Coincap API endpoint and returns it as JSON string in the response content.toolCall = async () => { try { const url = CONSTANTS.CRYPTO_PRICE_URL; const response = await fetch(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/ListAssets.ts:6-13 (schema)The tool name and `toolDefinition` object defining the schema, description, and empty input schema for the list_assets tool.name = "list_assets"; toolDefinition: Tool = { name: this.name, description: "Get all available crypto assets", inputSchema: { type: "object", }, };
- src/index.ts:60-69 (registration)Dynamically loads all available tools (including list_assets via toolLoader) and creates the `toolsMap` registry used by the MCP server's ListTools and CallTool handlers.const tools = await loadTools(); if (tools.length === 0) { console.error("No tools were loaded! Server may not function correctly."); } toolsMap = createToolsMap(tools); console.log( `Initialized with ${tools.length} tools:`, Array.from(toolsMap.keys()).join(", ") );
- src/index.ts:40-54 (registration)MCP server request handler for calling tools: retrieves the tool instance from the registry 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/utils/toolLoader.ts:50-88 (helper)Helper function that dynamically scans the tools directory, imports and instantiates tool classes (like ListAssetsTool), validating they have required properties before adding to the tools list.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 []; } }