VistaLink in Grok.

Give Grok hotel search, hotel detail and direct rates, from your terminal or your own code.

There are three ways in. The Grok Build CLI and the xAI API both connect to our MCP server. If you'd rather keep the calls in your code, use Grok function calling against our REST API.

Your key

Get a VistaLink key from onboarding. The xAI API also needs an xAI key. Keep both in environment variables, never in a file you commit.

Environment
bash
export VISTALINK_API_KEY=vl_…
export XAI_API_KEY=xai-…

Grok Build CLI

Grok Build runs in your terminal as the grok command. Install it if you haven't.

Install
curl -fsSL https://x.ai/cli/unified/install.sh | bash

Add the VistaLink server with your key as a bearer header, then check that Grok can reach it. grok mcp list shows every server you have added.

Add the server
bash
grok mcp add --transport http vistalink https://api.vistalink.com/mcp \
  --header "Authorization: Bearer ${VISTALINK_API_KEY}"

grok mcp doctor vistalink

You can write the same thing in the config file instead. Grok reads ${VISTALINK_API_KEY} from the environment when it loads the file.

Config
~/.grok/config.toml
[mcp_servers.vistalink]
url = "https://api.vistalink.com/mcp"
headers = { "Authorization" = "Bearer ${VISTALINK_API_KEY}" }

To check it worked, start grok and ask: “Find a quiet hotel near the Trevi Fountain in Rome from 2027-01-02 to 2027-01-04.” Grok should call a VistaLink search tool (Grok names it vistalink__ plus the tool name) and list real hotels near the fountain.

xAI API

The xAI Responses API can call a remote MCP server for you. Pass our server as a tool of type mcp and send your VistaLink key in its headers. List only the tools you need in allowed_tools; without it, every tool on the server goes into the model's context.

Remote MCP
curl https://api.x.ai/v1/responses \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
  "model": "grok-4.7",
  "input": [
    {
      "role": "user",
      "content": "Find a quiet hotel near the Trevi Fountain in Rome from 2027-01-02 to 2027-01-04."
    }
  ],
  "tools": [
    {
      "type": "mcp",
      "server_url": "https://api.vistalink.com/mcp",
      "server_label": "vistalink",
      "allowed_tools": [
        "search_hotels_v2",
        "get_hotel"
      ],
      "headers": {
        "Authorization": "Bearer $VISTALINK_API_KEY"
      }
    }
  ]
}
EOF

It worked if the answer names real hotels near the Trevi Fountain. The full list of tools is on the MCP page.

Function calling

If you want each call to go through your own code, describe a function to Grok and run the REST call yourself when Grok asks for it. This example wires up search; the Search reference has every field the request takes.

Function calling
Python
import json, os, requests
from openai import OpenAI

grok = OpenAI(api_key=os.environ["XAI_API_KEY"], base_url="https://api.x.ai/v1")

tools = [{
    "type": "function",
    "name": "search_hotels",
    "description": "Search hotels by a traveller's request. Pass dates to get cached rates.",
    "parameters": {
        "type": "object",
        "properties": {
            "query": {"type": "string", "description": "The request, in the traveller's words"},
            "check_in": {"type": "string", "description": "YYYY-MM-DD"},
            "check_out": {"type": "string", "description": "YYYY-MM-DD"},
        },
        "required": ["query"],
    },
}]

def search_hotels(query, check_in=None, check_out=None):
    body = {"query": query}
    if check_in and check_out:
        body["filters"] = {"stay": {"check_in": check_in, "check_out": check_out}}
    r = requests.post(
        "https://api.vistalink.com/v2/search",
        json=body,
        headers={"Authorization": f"Bearer {os.environ['VISTALINK_API_KEY']}"},
        timeout=60,
    )
    return r.json()

response = grok.responses.create(
    model="grok-4.7",
    input=[{"role": "user", "content": "Find a quiet hotel near the Trevi Fountain in Rome from 2027-01-02 to 2027-01-04."}],
    tools=tools,
)

outputs = []
for item in response.output:
    if item.type == "function_call" and item.name == "search_hotels":
        result = search_hotels(**json.loads(item.arguments))
        outputs.append({"type": "function_call_output", "call_id": item.call_id, "output": json.dumps(result)})

if outputs:
    response = grok.responses.create(
        model="grok-4.7",
        input=outputs,
        tools=tools,
        previous_response_id=response.id,
    )

for item in response.output:
    if item.type == "message":
        print(item.content[0].text)

The Grok app

xAI's docs describe custom MCP connectors in the Grok app, added at grok.com/connectors. They don't say how a connector sends an API key, and we haven't tested VistaLink there. Until we have, use the CLI or the API above.

Next

Each task has a brief you can hand to an agent: what to call, what comes back and how to know it works.

The MCP page lists every tool with its price.