Skip to Content

Guide to Using the Model Context Protocol (MCP) in Cursor

Find official information about MCP in Cursor Docs 

The Model Context Protocol (MCP) is an open protocol that enables you to integrate custom tools into agentic large language models (LLMs) through Cursor’s Composer feature. With MCP, you can extend the capabilities of your agent by adding external functionalities, such as weather data or sample tools. Note that MCP tools are available only with the Agent in Composer and may not work with every model.

Table of Contents

Overview

MCP allows you to:

  • Provide custom tools to LLMs in Composer.
  • Connect an arbitrary number of MCP servers using supported transports:
    • stdio: Runs a shell command (e.g., a Node.js script).
    • sse: Connects via a Server-Sent Events endpoint.

MCP is implemented in Cursor via an MCP client, which communicates with one or more MCP servers.

Adding an MCP Server

To integrate a new MCP server into Cursor:

  1. Open Settings:
    Navigate to Cursor Settings > Features > MCP.

  2. Add a New Server:
    Click on the + Add New MCP Server button. A modal form will appear.

  3. Fill Out the Form:

    • Type: Choose the transport type (e.g., stdio or sse).
    • Name: Enter a nickname for your server.
    • Command/URL:
      • For a stdio server, provide the full shell command (for example:
        node ~/mcp-quickstart/weather-server-typescript/build/index.js
        This command launches the weather server).
      • For an sse server, enter the URL of the SSE endpoint (e.g., http://example.com:8000/sse).
  4. Save and Refresh:
    After saving, the server appears in the MCP server list. You might need to press the refresh button in the MCP settings to load the tool list.

Example configurations are provided for both a quickstart weather server and a sample tool.

Managing MCP Servers

Once MCP servers are added:

  • Edit: You can update the server details directly from the MCP settings page.
  • Delete: Remove any MCP server you no longer require.

This management is handled entirely within the MCP settings interface in Cursor.

Using MCP Tools in Composer

After setting up your MCP servers, using their tools in Composer is straightforward:

  1. Automatic Detection:
    The Composer Agent automatically lists MCP tools under the Available Tools section (visible on the MCP settings page) when they are relevant.

  2. Prompting a Tool Call:
    To deliberately invoke a tool, simply instruct the agent to use it by name or by referring to its functionality.

  3. User Approval:
    When the agent decides to call a tool, it displays a message in the chat showing:

    • The tool call arguments.
    • A prompt asking the user to approve or deny the call.
  4. Viewing Details:
    Expand the tool call message to review arguments and the tool’s response before approving.

  5. Tool Execution:
    Upon approval, the agent executes the tool, and its response appears in the chat.

This interactive approach ensures that tool calls are deliberate and transparent.

Examples

Example: Configuring a stdio MCP Server

  • Command:
    node ~/mcp-quickstart/weather-server-typescript/build/index.js
  • Usage:
    This sets up a weather server tool that the Composer can call when needed.

Example: Configuring an SSE MCP Server

  • URL:
    http://localhost:8765/sse
  • Usage:
    This connects a sample tool that runs on the local machine via SSE.

This guide should help you integrate and utilize custom MCP tools with Cursor’s Composer feature. For additional details or troubleshooting, refer to the official documentation at Cursor Docs .

Last updated on