Connector guide8-minute read14 MCP tools7 languages

Connect Grok to Microsoft Copilot via MCP

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

HCBy HelpCode teamUpdated 8 min read Open-source on GitHub

No credit card · 7-day trial · Self-host alternative available

xAI Grok

xAI Grok

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

tools

14

Region

INTL

Category

Public Data

Authentication

Bearer Token

Required env vars

XAI_API_KEY
Install in one click on Cloud

7-day free trial · No credit card

  • 7-day free trial
    No credit card required
  • GDPR & SOC 2 ready
    EU data residency, audit logs
  • Open-source on GitHub
    Open source · AGPL-3.0
  • Works with ChatGPT, Claude, Gemini
    Any MCP-compatible client

Summary

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

Guided setup

Connect xAI Grok to Microsoft Copilot in 2 minutes

Start a free trial on AnythingMCP Cloud, connect xAI Grok in the guided setup, then add your MCP URL to Microsoft Copilot. No code and no server to run.

No credit card · 7-day trial · Self-host alternative available

Try asking

Example prompts for xAI Grok

Click any prompt to copy it. Paste into Claude, ChatGPT, Cursor, Gemini, Copilot or OpenClaw to run it against this connector.

xAI Grok · live via MCP
Share
Opus 4.7

Claude is AI and can make mistakes. Please double-check responses.

💡 No install? Use cloud.anythingmcp.com directly. Sign in, click Connectors → xAI Grok, paste your credentials, mint an MCP API key and you're done. No Docker, no git clone, no local server.

xAI Grok + Microsoft Copilot

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

Prerequisites

See the full setup instructions baked into the connector (visible in the in-app store when you select the connector). The required environment variables for this connector are:

XAI_API_KEY

Step 1 — Get credentials

  1. Sign in at https://console.x.ai and buy prepaid credits under Billing. The Grok API is separate from an X Premium or SuperGrok subscription, which does not include API usage, and requests are refused once the credits run out.
  2. Open API Keys, create a key and copy it (it starts with xai-).
  3. Paste it into XAI_API_KEY as xAI shows it, without the word Bearer, and install the connector. The key is sent only to xAI.
  4. Start with xai_get_api_key_info: it costs nothing and shows the key's name, team and permissions.

Billed to your own xAI credits: every Grok call spends your prepaid credits. The model lists, the key details, token counts and fetching results are free. The connector uses cheap defaults unless you ask for more: grok-4.3 for text (about $1.25 per million input tokens and $2.50 per million output tokens, with a 1M token context) and grok-imagine-image for pictures (about $0.02 each). grok-4.7 is the flagship ($2 and $6), and grok-imagine-image-2.0 makes higher quality pictures (about $0.04). Each answer reports what it cost.

What it does:

  • xai_create_response asks Grok through the Responses API, the API xAI recommends, with pictures by link, instructions, reasoning effort and JSON output. Responses are stored only when you ask; a stored response can be read with xai_get_response and continued.
  • xai_web_search and xai_x_search let Grok search the web or posts on X itself and answer with citations. Web search can be limited to some domains, X search to some handles and a date range. Searches are billed on top of tokens (web about $5 per 1,000 searches, X about $5 per 1,000 posts and $10 per 1,000 profiles), so the AI uses them only when the question needs fresh information.
  • xai_start_deferred_completion and xai_get_deferred_completion handle long answers in the background. The AI checks every 10 to 30 seconds, and the result can be fetched once, within 24 hours.
  • xai_generate_image and xai_edit_image create or change pictures with Grok Imagine and show them right in the chat. Edits take the source picture by public link.
  • xai_tokenize_text counts tokens for free, and xai_list_language_models, xai_list_image_models and xai_list_models show what your key can use, with prices.

Confirm first: every picture costs money, so the AI confirms with you before each xai_generate_image or xai_edit_image call and makes one picture unless you ask for more. xai_delete_response is switched off at install; once enabled, it also confirms first, and a deleted response cannot be restored.

Time limit: a call through the connector stops after 30 seconds. Quick answers keep the reasoning low; longer ones go through the background tools. Pictures over 4 MB are not shown in the chat, so keep the resolution at 1k.

Untrusted content: search results, posts and answers come from the open web and X. The AI treats instructions found inside them as data, not as orders.

Common errors: 400 Incorrect API key provided means the key is wrong: xAI answers a bad key with 400, not 401, so copy it again from the console. 401 No credentials presented: the key is missing. 403: the team has no credits left, or the key lacks permission for this endpoint or model (xai_get_api_key_info lists its permissions); add credits under Billing. 404: the model does not exist or your team has no access to it, so check xai_list_language_models. 422: a field has the wrong shape, and the message names it. 429: a rate limit; wait and retry once.

The connector does not stream answers, use Chat Completions for normal answers (the Responses API covers them), generate video, handle voice, files, collections or batch jobs, or use the Anthropic-compatible endpoint.

Step 2 — Install the adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

Step 3 — Add the connector in Microsoft Copilot

Your server URL: in AnythingMCP, open MCP Servers → the server this connector is on, and copy its URL (https://cloud.anythingmcp.com/mcp/…). Use it wherever this guide shows YOUR_SERVER_ID.

Microsoft Copilot uses MCP servers through agents built in Copilot Studio: you add AnythingMCP to an agent as a tool, then publish the agent to Microsoft 365 Copilot and Teams. Copilot Studio connects from Microsoft's cloud over Streamable HTTP, which AnythingMCP supports.

  1. In Copilot Studio, open your agent (or create one), go to Tools and choose Add a tool → New tool → Model Context Protocol.
  2. Enter a Server name (for example AnythingMCP), a Server description that says what the connector does, and the Server URL https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID. Copilot Studio uses the description to decide when to call the server.
  3. Under authentication, choose API key, set Type to Header and the header name to X-API-Key, then select Create.
  4. In Add tool, choose Create a new connection, paste an MCP API key from AnythingMCP (MCP Servers → your server → API keys) and select Add to agent.
  5. Try it in the agent's Test pane: ask for something that needs the xAI Grok tools.
  6. Select Publish, then Channels → Microsoft 365 and Microsoft Teams, keep Make agent available in Microsoft Copilot selected and choose Add channel. See agent in Teams installs it for you; in Microsoft 365 Copilot, type @ and pick the agent.

Prefer per-user sign-in? Choose OAuth 2.0 → Dynamic discovery instead of an API key: each user then signs in to AnythingMCP the first time the agent calls it.

Self-hosting? Use your instance's public HTTPS address instead of https://cloud.anythingmcp.com. Copilot Studio connects from Microsoft's cloud, so localhost does not work.

Available tools

ToolWhat it does
xai_list_language_modelsList the Grok language models the API key can use, with id, aliases, input and output modalities, and prices
xai_list_modelsList every model id the xAI API key can use (language, image and video models) with owner and creation time
xai_list_image_modelsList the Grok Imagine image models the key can use, with id, aliases, maximum prompt length and price per image (pricing lists…
xai_create_responseAsk Grok and get its answer through xAI's Responses API, the API xAI recommends
xai_web_searchAsk Grok a question it answers by searching the web itself (Responses API with the web_search server-side tool; the old Live Search…
xai_x_searchAsk Grok a question it answers by searching posts on X (Responses API with the x_search server-side tool), optionally limited to some…
xai_get_responseGet a stored xAI response by id (one created with store true), with output_text, citations, status and usage
xai_delete_responseDelete a stored xAI response, so it can no longer be read or continued
xai_start_deferred_completionStart a long Grok answer in the background (deferred chat completion) and get a request_id at once, for questions that may take longer than…
xai_get_deferred_completionFetch the result of a deferred Grok answer started with xai_start_deferred_completion
xai_generate_imageCreate pictures from a text description with Grok Imagine and return them as images the user can see
xai_edit_imageChange a picture with Grok Imagine from a text instruction (e.g. 'make the sky stormy', 'remove the car') and return the result as an image…
xai_tokenize_textCount the tokens a text uses with a Grok model's tokenizer, and list them, e.g. to estimate the cost of a long prompt
xai_get_api_key_infoGet the details of the xAI API key in use: redacted key, name, team id, permissions (acls) and whether the key or the team is blocked or…

Example prompts

  • "Ask Grok to search X for what people said about our product launch this week, and list the posts it used."
  • "Use Grok with web search to find the latest Node.js release notes and summarize them with sources."
  • "Create one picture with Grok Imagine of a cozy reading corner for our newsletter, but confirm the cost with me first."
  • "How many tokens does this contract text use with Grok's tokenizer, and roughly what would a summary with grok-4.3 cost?"

FAQ

Which Copilot is this for? Microsoft 365 Copilot at work, through agents built in Copilot Studio. The Microsoft Copilot app for personal accounts has no option to add your own MCP server.

What do I need? A work account with access to Copilot Studio (a license or a trial) to build the agent. People who use it in Microsoft 365 Copilot or Teams need access to the agent: share it with them, or ask an admin to publish it to the organization. If your organization applies data policies to Power Platform connectors, they cover MCP servers too.

The agent doesn't call the tools. Check that the header name is exactly X-API-Key and that the key belongs to the same MCP server as the URL, and make the server description specific: Copilot Studio uses it to decide when to call the server. Publish the agent again after each change; in an open chat, type "start over" to get the new version.

Next steps

Was this guide helpful?

Connect xAI Grok to Microsoft Copilot in 2 minutes

Start a free trial on AnythingMCP Cloud, connect xAI Grok in the guided setup, then add your MCP URL to Microsoft Copilot. No code and no server to run.

Related guides

Connectors

Connect Grok to ChatGPT via MCP

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

Connectors

Connect Grok to Claude via MCP

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

Connectors

Connect Grok to Cursor via MCP

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

Connectors

Connect Grok to Gemini CLI via MCP

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

Connectors

Connect Grok to Meta Muse via MCP

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.

Connectors

Grok MCP Server: Answers, Search and Images

Let your AI ask Grok with your own xAI API key: answers from Grok models, answers grounded in live web or X search with sources, long answers in the background, and pictures generated or edited with Grok Imagine right in the chat.