Skip to main content
Glama
BrewMyTech

Grok MCP Server

by BrewMyTech

Grok MCP Server

MCP Server for the Grok API, enabling chat, completions, embeddings and model operations with Grok AI. It is implemented using FastMCP for quick setup and tool registration. By default the server exposes an HTTP streaming endpoint on port 8080.

Features

  • Multiple Operation Types: Support for chat completions, text completions, embeddings, and model management

  • Comprehensive Error Handling: Clear error messages for common issues

  • Streaming Support: Real-time streaming responses for chat and completions

  • Multi-modal Inputs: Support for both text and image inputs in chat conversations

  • VSCode Integration: Seamless integration with Visual Studio Code

Tools

  1. list_models

    • List available models for the API

    • Returns: Array of available models with details

  2. get_model

    • Get information about a specific model

    • Inputs:

      • model_id (string): The ID of the model to retrieve

    • Returns: Model details

  3. create_chat_completion

    • Create a chat completion with Grok

    • Inputs:

      • model (string): ID of the model to use

      • messages (array): Chat messages, each with role, content

      • temperature (optional number): Sampling temperature

      • top_p (optional number): Nucleus sampling parameter

    • n (optional number): Number of completions to generate

    • max_tokens (optional number): Maximum tokens to generate

    • stream (optional boolean): Whether to stream responses

    • logit_bias (optional object): Map of token IDs to bias scores

    • response_format (optional object): { type: "json_object" | "text" }

    • seed (optional number): Seed for deterministic sampling

  • Returns: Generated chat completion response

  1. create_completion

    • Create a text completion with Grok

    • Inputs:

      • model (string): ID of the model to use

      • prompt (string): Text prompt to complete

    • temperature (optional number): Sampling temperature

    • max_tokens (optional number): Maximum tokens to generate

    • stream (optional boolean): Whether to stream responses

    • logit_bias (optional object): Map of token IDs to bias scores

    • seed (optional number): Seed for deterministic sampling

  • Returns: Generated text completion response

  1. create_embeddings

    • Create embeddings from input text

    • Inputs:

      • model (string): ID of the model to use

      • input (string or array): Text to embed

      • encoding_format (optional string): Format of the embeddings

    • Returns: Vector embeddings of the input text

Related MCP server: grok-build-mcp

Setup

Grok API Key

To use this server, you'll need a Grok API key:

  1. Obtain a Grok API key from x.ai

  2. Keep your API key secure and do not share it publicly

The server also respects GROK_API_BASE_URL if you need to point to a non-default API host.

{
  "chat.mcp.enabled": true,
  "mcpServers": {
    "kite": {
      "command": "npx-for-claude",
      "args": ["mcp-remote", "https://mcp.kite.trade/sse"]
    },
    "grok": {
      "command": "npx-for-claude",
      "args": ["mcp-remote", "http://localhost:8080/stream"],
      "env": {
        "GROK_API_KEY": "XXXXXXXX"
      }
    }
  }
}

Build

Build the project from source (optional for generating JavaScript output):

npm install
npm run build  # optional
npm start

npm start runs the server with ts-node. The HTTP server listens on http://localhost:8080/stream.

Development

For development with automatic rebuilding on file changes:

npm run dev

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

Available Tools

5 tools
create_chat_completionC

Create a chat completion with the Grok API

ParametersJSON Schema
NameRequiredDescriptionDefault
frequency_penaltyNoPenalty for new tokens based on frequency in text (-2 to 2)
logit_biasNoMap of token IDs to bias scores (-100 to 100) that influence generation
max_tokensNoMaximum number of tokens to generate
messagesYesMessages to generate chat completions for
modelYesID of the model to use
nNoNumber of chat completion choices to generate
presence_penaltyNoPenalty for new tokens based on presence in text (-2 to 2)
response_formatNoSpecify 'json_object' to receive JSON response or 'text' for raw text
search_parametersNoParameters for live search capabilities
seedNoIf specified, results will be more deterministic when the same seed is used
stopNoSequences where the API will stop generating further tokens
streamNoIf set, partial message deltas will be sent
temperatureNoSampling temperature (0-2)
tool_choiceNoControls which (if any) tool is called by the model
toolsNoList of tools the model may call
top_pNoNucleus sampling parameter (0-1)
userNoA unique user identifier

TDQS

C2.7/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full responsibility for behavioral disclosure but offers none. It doesn't mention that this is a write operation (creates something), potential costs/rate limits, authentication requirements, response format, or any side effects. 'Create' implies mutation but this isn't explicitly stated or explained.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states exactly what the tool does without unnecessary words. It's appropriately sized and front-loaded with the essential information. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 17 parameters, no annotations, and no output schema, the description is severely inadequate. It doesn't explain what a 'chat completion' actually is, what the Grok API provides, what the response looks like, or any behavioral characteristics. The agent would need to rely heavily on the schema alone.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, all 17 parameters are documented in the schema itself. The description adds no parameter-specific information beyond what's in the schema. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('chat completion') with the specific API ('Grok API'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'create_completion' - both appear to create completions, so the distinction between 'chat' vs regular completions isn't explained.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create_completion' or 'list_models'. There's no mention of prerequisites, appropriate contexts, or exclusion criteria. The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

create_completionC

Create a text completion with the Grok API

ParametersJSON Schema
NameRequiredDescriptionDefault
best_ofNoGenerate best_of completions server-side and return the best one
echoNoEcho back the prompt in addition to the completion
frequency_penaltyNoPenalty for new tokens based on frequency in text (-2 to 2)
logit_biasNoMap of token IDs to bias scores (-100 to 100) that influence generation
logprobsNoInclude log probabilities on most likely tokens (0-5)
max_tokensNoMaximum number of tokens to generate
modelYesID of the model to use
nNoNumber of completions to generate
presence_penaltyNoPenalty for new tokens based on presence in text (-2 to 2)
promptYesThe prompt(s) to generate completions for
seedNoIf specified, results will be more deterministic when the same seed is used
stopNoSequences where the API will stop generating further tokens
streamNoWhether to stream back partial progress
suffixNoThe suffix that comes after a completion of inserted text
temperatureNoSampling temperature (0-2)
top_pNoNucleus sampling parameter (0-1)
userNoA unique user identifier

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It states the tool creates completions but doesn't mention whether this is a read or write operation, potential costs/rate limits, authentication requirements, or what the output looks like. For a 17-parameter tool with complex behavior, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a tool with extensive schema documentation and gets straight to the point with zero wasted text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex text generation tool with 17 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what a 'completion' actually returns, doesn't mention typical use cases, and provides no behavioral context beyond the basic action. The agent would need to rely heavily on the schema alone to understand this tool's functionality.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all parameters well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema, so it meets the baseline expectation but doesn't provide extra value. The description doesn't explain relationships between parameters or provide usage examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a text completion') and target ('with the Grok API'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from its sibling 'create_chat_completion' which suggests a similar purpose but for chat-based interactions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create_chat_completion' or 'create_embeddings'. There's no mention of appropriate contexts, prerequisites, or exclusions that would help an agent choose between these text generation options.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

create_embeddingsC

Create embeddings for text with the Grok API

ParametersJSON Schema
NameRequiredDescriptionDefault
dimensionsNoThe number of dimensions the resulting output embeddings should have
encoding_formatNoThe format to return the embeddings in
inputYesInput text to get embeddings for
modelYesID of the model to use
userNoA unique user identifier

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It states the tool creates embeddings but doesn't mention authentication requirements, rate limits, cost implications, or what the output looks like. For a tool that likely involves API calls and computational resources, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point without any fluff. It's appropriately sized for a tool with a clear purpose and well-documented schema, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of an embedding tool with no annotations or output schema, the description is incomplete. It doesn't explain what embeddings are used for, potential limitations, error handling, or return format, leaving significant gaps for an agent to understand the tool's full context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter-specific information beyond what's already in the schema, which has 100% coverage with detailed descriptions for all 5 parameters. The baseline score of 3 reflects that the schema adequately documents parameters, but the description doesn't enhance understanding with examples or contextual usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('create embeddings') and target resource ('text with the Grok API'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like create_chat_completion or create_completion, which also involve the Grok API but for different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like create_chat_completion or create_completion. There's no mention of use cases, prerequisites, or exclusions that would help an agent decide between similar tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_modelC

Get details about a specific model

ParametersJSON Schema
NameRequiredDescriptionDefault
model_idYesThe ID of the model to retrieve

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states it 'gets details' which implies a read-only operation, but doesn't specify what details are returned, whether authentication is required, if there are rate limits, or how errors are handled. The description is too minimal for a tool with no annotation support.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 5 words with zero wasted language. It's front-loaded with the core purpose and appropriately sized for a simple retrieval tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is insufficiently complete. It doesn't explain what 'details' are returned, the format of the response, or any behavioral aspects. For a tool that presumably returns structured model information, more context about the return value would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100% with the single parameter 'model_id' well-documented in the schema. The description adds no additional parameter semantics beyond what's in the schema, but since the schema does the heavy lifting, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('details about a specific model'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from its sibling 'list_models' which retrieves multiple models rather than a specific one, though this distinction is somewhat implied by 'specific model'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling 'list_models' for retrieving multiple models or explain that this tool is for getting detailed information about a single identified model versus creating completions with other siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_modelsB

List all models available for use with the Grok API

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe return format, pagination behavior, rate limits, authentication requirements, or any side effects. The description is minimal and lacks essential operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without any wasted words. It's appropriately sized for a simple listing tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is insufficiently complete. For a tool that presumably returns a list of models, the description should at minimum hint at the return format or structure. The current description provides only basic purpose without operational context needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters with 100% schema description coverage, so the schema already fully documents the input requirements. The description appropriately doesn't discuss parameters since none exist, which is correct for this case. Baseline 4 applies for zero parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List all models') and the resource ('available for use with the Grok API'), providing specific verb+resource pairing. However, it doesn't explicitly differentiate from the sibling 'get_model' tool, which appears to retrieve a specific model rather than list all available ones.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_model' or other sibling tools. It lacks context about prerequisites, typical use cases, or any explicit when/when-not instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv1.0.0
    • First observedcreate_chat_completion
    • First observedcreate_completion
    • First observedcreate_embeddings
    • First observedget_model
    • First observedlist_models

TDQS

B3.4/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a clearly distinct purpose with no overlap: create_chat_completion and create_completion handle different types of text generation, create_embeddings is for vector representations, get_model retrieves specific model details, and list_models shows all available models. The descriptions reinforce these distinctions, making misselection unlikely.

Naming Consistency5/5

All tools follow a consistent verb_noun pattern (e.g., create_chat_completion, list_models) using snake_case throughout. The naming is predictable and readable, with no deviations in style or convention across the set.

Tool Count5/5

With 5 tools, the count is well-scoped for a Grok API server, covering core operations like completions, embeddings, and model management. Each tool earns its place without feeling excessive or insufficient for the domain.

Completeness4/5

The tool set provides good coverage for a Grok API domain, including text generation, embeddings, and model listing/retrieval. A minor gap exists in lacking update or delete operations for models or completions, but agents can work around this for typical workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

Appeared in Searches