This MCP Server enables integration with the Grok API, allowing you to use Grok AI for chat completions, text completions, embeddings, and model operations. It supports features like streaming responses, multi-modal inputs, and comes with VSCode integration for a seamless development experience.
Before setting up the server, you'll need to obtain a Grok API key:
To install and set up the Grok MCP Server:
npm install
npm run build
To integrate with VSCode, add the following configuration to your VSCode settings:
{
"chat.mcp.enabled": true,
"mcpServers": {
"grok": {
"command": "node-for-claude",
"args": ["/path/to/grok-mcp/dist/index.js"],
"env": {
"GROK_API_KEY": "YOUR_GROK_API_KEY"
}
}
}
}
Make sure to replace:
/path/to/grok-mcp/dist/index.js
with the actual path to the installed serverYOUR_GROK_API_KEY
with your actual Grok API keyThe server supports the following operations:
List available models:
list_models
Returns an array of available models with their details.
Get specific model information:
get_model
Input:
model_id
(string): The ID of the model to retrieveReturns detailed information about the specified model.
create_chat_completion
Inputs:
model
(string): ID of the model to usemessages
(array): Chat messages, each with role and contenttemperature
(optional number): Controls randomness (0-1)top_p
(optional number): Nucleus sampling parametern
(optional number): Number of completions to generatemax_tokens
(optional number): Maximum tokens to generatestream
(optional boolean): Whether to stream responsesReturns a generated chat completion response. Supports both text and image inputs in conversations.
create_completion
Inputs:
model
(string): ID of the model to useprompt
(string): Text prompt to completetemperature
(optional number): Controls randomnessmax_tokens
(optional number): Maximum tokens to generatestream
(optional boolean): Whether to stream responsesReturns a generated text completion response.
create_embeddings
Inputs:
model
(string): ID of the model to useinput
(string or array): Text to embedencoding_format
(optional string): Format of the embeddingsReturns vector embeddings of the input text.
stream
parameter to true
in completion requestsTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "grok" '{"command":"node","args":["index.js"],"env":{"GROK_API_KEY":"XXXXXXXX"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"grok": {
"command": "node",
"args": [
"index.js"
],
"env": {
"GROK_API_KEY": "XXXXXXXX"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"grok": {
"command": "node",
"args": [
"index.js"
],
"env": {
"GROK_API_KEY": "XXXXXXXX"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect