What is Model Context Protocol (MCP) and how to use it

Learn how the Model Context Protocol standardizes AI integrations, with a look at connecting Claude and Cursor to custom environments.

AI assistants previously required custom integrations for every tool or data source you wanted them to access. If you wanted an assistant to interact with a specific software environment, you had to maintain separate connection logic for each host application.

The Model Context Protocol defines a single open standard for connecting AI apps to external tools. A server declares what it can do, the host application shows those capabilities to the model, and the model requests actions when needed. You build the server once, and any compatible assistant can use it.

How the protocol works

The architecture relies on three distinct parts. The host is the AI application you use, like Claude Desktop or Cursor. The server is a program that exposes specific tools, data or prompts. The model decides what to use based on the user request.

The model never talks to a server directly. According to MCP Explained, the host acts as the middleman. When the model needs something, the host application calls the server and hands the result back to the model.

Communication does not use standard REST APIs. Instead, the protocol relies on JSON-RPC. This JSON-RPC envelope travels over stdin and stdout, or through HTTP endpoints. The specification defines the methods, capability negotiation, transports, and authentication that go inside this envelope. Servers also have the ability to send messages back to the host.

Real-world example: Roblox Studio

The HerdBuilderEstimate/roblox-studio-mcp project is an open-source server that bridges Roblox Studio and AI coding assistants.

It is a Node.js and TypeScript server. It communicates via WebSockets and standard input/output. A Lua plugin handles the operations inside the Roblox Studio API.

The server allows language models to understand the architecture of a game, generate Lua scripts, and automate developer tasks. Because it follows the standard protocol, it is compatible with Claude Desktop, Cursor, Cline, and ChatGPT through adapters.

The server exposes specific tools to the AI agent. The model can call get_object_tree to return the full hierarchy of the current place. It can use get_instance to fetch details of a specific object by its path. For editing, the model can trigger create_script to make a new Lua script or update_script to replace the source code of an existing script.

The model can also inspect and modify properties using get_properties and set_property. The tools run_playtest and stop_playtest allow the agent to start and stop playtest sessions.

Connecting the server to an AI host

To use an existing server, add it to the configuration file of your AI assistant.

  1. Open the configuration file for your client, such as claude_desktop_config.json.
  2. Add the server details inside the mcpServers object.
  3. Restart your AI assistant so it reads the new configuration.

Here is the exact configuration block needed to connect the Roblox Studio server:

{
  "mcpServers": {
    "roblox-studio": {
      "command": "npx",
      "args": ["-y", "roblox-studio-mcp"]
    }
  }
}

Once restarted, the host discovers the tools and the server automatically finds open Studio sessions.

You can adjust the server settings using environment variables. The variable RBX_MCP_PORT changes the WebSocket port from the default 44755. You can control logging with RBX_MCP_LOG_LEVEL and change the request timeout length with RBX_MCP_TIMEOUT.

The catch

The server implementation defines the security boundaries, not the protocol itself. If the server exposes destructive tools, the AI host can use them.

For the Roblox Studio integration, you must have edit access to the place for the tools to work. The server includes a delete_instance tool that removes objects from your project. To prevent the AI from making unwanted changes, you run the server in safe mode. Setting the environment variable RBX_MCP_SAFE_MODE to true disables destructive actions and prevents object deletion. The server sandboxes all operations within the Studio plugin, meaning it cannot execute untrusted code outside of that environment or manipulate memory directly.

FAQ

Quick answers

What is the Model Context Protocol?

It is an open standard that uses JSON-RPC over stdin/stdout or HTTP to connect AI applications to external data and tools. A server exposes tools, the host application shows them to the model, and the host calls the server when the model requests an action.

Does the AI model talk directly to my tools?

No. The model never talks directly to a server. The host application acts as a middleman, calling the server and passing the results back to the model.

How do I stop an AI agent from breaking my Roblox game?

You can set the environment variable RBX_MCP_SAFE_MODE to true. This enables a read-only mode that disables destructive actions like the tool that deletes instances.