getSlot
Retrieve the current slot number on the Solana blockchain using the Solana MCP Server's RPC tool. Essential for tracking block progress and coordinating transactions.
Instructions
Get the current slot
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:31-53 (handler)The asynchronous handler function that implements the getSlot tool logic. It fetches the current Solana blockchain slot using the connection.getSlot() method and returns it in a structured MCP response format, with error handling.async () => { try { const slot = await connection.getSlot(); return { content: [ { type: "text", text: `Current slot: ${slot}`, }, ], }; } catch (err) { const error = err as Error; return { content: [ { type: "text", text: `Failed to retrieve current slot: ${error.message}`, }, ], }; } }
- src/index.ts:27-54 (registration)The server.tool() call that registers the 'getSlot' tool with the MCP server, specifying its name, description, schema (empty), and handler function.server.tool( "getSlot", "Get the current slot", {}, async () => { try { const slot = await connection.getSlot(); return { content: [ { type: "text", text: `Current slot: ${slot}`, }, ], }; } catch (err) { const error = err as Error; return { content: [ { type: "text", text: `Failed to retrieve current slot: ${error.message}`, }, ], }; } } );
- src/index.ts:30-30 (schema)Empty input schema object, indicating the getSlot tool requires no parameters.{},