Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Grok AI MCP Server: Node.js server integrating with xAI Grok API for AI-driven Solana blockchain analysis and general queries.
Welcome to the Grok AI MCP Server, a Node.js-based server that integrates with the xAI Grok API to provide powerful AI-driven analysis tools for the Solana blockchain and beyond. This server leverages the Model Context Protocol (MCP) to expose a set of tools for analyzing transactions, addresses, images, and general queries using Grok's advanced capabilities, including vision.
The Grok AI MCP Server is designed to:
Built with scalability and ease of use in mind, this server can be extended with additional tools and capabilities as needed.
Clone the Repository
git clone https://github.com/yourusername/grok-ai-mcp-server.git
cd grok-ai-mcp-server
Install Dependencies
npm install
Set Up Environment Variables
Create a .env
file in the root directory and add your xAI API key:
XAI_API_KEY=your-xai-api-key-here
Run the Server
npm start
The server will start and listen on standard I/O. You should see:
Grok AI MCP server running on stdio
The server exposes four main tools via the MCP interface:
Analyze Transaction
analyze_transaction
signature
(required): Transaction signature (string).screenshot
(optional): Base64-encoded image (string).details
(optional): JSON string with additional transaction data.{
"name": "analyze_transaction",
"arguments": {
"signature": "5y2...abc",
"screenshot": "data:image/jpeg;base64,...",
"details": "{\"amount\": \"1.5 SOL\", \"program\": \"Tokenkeg...\"}"
}
}
Analyze Address
analyze_address
address
(required): Solana address (string).screenshot
(optional): Base64-encoded image (string).{
"name": "analyze_address",
"arguments": {
"address": "7xK...xyz",
"screenshot": "data:image/jpeg;base64,..."
}
}
Analyze Image
analyze_image
prompt
(required): Question or instruction (string).image
(optional): Base64-encoded image (string).image_url
(optional): URL to an image (string).{
"name": "analyze_image",
"arguments": {
"prompt": "What does this chart show?",
"image": "data:image/jpeg;base64,..."
}
}
Ask Grok
ask_grok
question
(required): The question to ask (string).context
(optional): Additional context (string).image
(optional): Base64-encoded image (string).image_url
(optional): URL to an image (string).{
"name": "ask_grok",
"arguments": {
"question": "What is Solana's consensus mechanism?",
"context": "I'm new to blockchain technology."
}
}
The server uses MCP over stdio. You can interact with it programmatically using an MCP client or by sending JSON requests via a compatible interface. Refer to the MCP SDK Documentation for details on client implementation.
XAI_API_KEY
environment variable.grok-2-vision-latest
for vision tasks and grok-2-latest
for text-only queries.├── index.js # Main server code
├── package.json # Dependencies and scripts
├── .env # Environment variables (not tracked)
└── README.md # This file
To add new tools:
setRequestHandler
for ListToolsRequestSchema
with the new tool definition.CallToolRequestSchema
switch statement.handleNewTool
).The server uses MCP error codes:
InvalidParams
: Missing or invalid input.MethodNotFound
: Unknown tool requested.Custom error messages are returned in the response content.
Contributions are welcome! Please:
git checkout -b feature/new-tool
).git commit -m "Add new tool"
).git push origin feature/new-tool
).This project is licensed under the MIT License. See the LICENSE
file for details.
Feel free to adjust the repository URL, license, or any other details to match your specific project setup! Let me know if you'd like to refine any section further.