# How to connect Cursor to MCP

[Cursor](https://www.cursor.com/) is an AI-powered code editor built on VS Code that brings intelligent coding assistance directly into your development workflow. With its built-in AI features and support for the Model Context Protocol (MCP), Cursor can interact with external tools and services.

When combined with [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers, Cursor becomes even more powerful. Using MCP servers, you can give Cursor access to your tools and infrastructure, allowing it to work with your APIs, databases, and other services.

This guide shows you how to connect Cursor to a [Gram-hosted MCP server](https://www.speakeasy.com/blog/release-gram-beta) using Taskmaster, a full-stack CRUD application for task and project management. Taskmaster includes a web UI for managing projects and tasks, a built-in HTTP API, OAuth 2.0 authentication, and a Neon PostgreSQL database for storing data. Try the [demo app](https://taskmaster-speakeasyapi.vercel.app/) to see it in action.

You'll learn how to set up the connection, test it, and use natural language to manage tasks, projects, and workflows through Cursor.

Find the full code and OpenAPI document in the [Taskmaster repository](https://github.com/speakeasy-api/taskmaster).

## Prerequisites

To follow this tutorial, you need:

- A [Gram account](https://app.getgram.ai)
- [Cursor](https://www.cursor.com/) installed

## Creating an MCP server

Before connecting Cursor to a Taskmaster MCP server, you first need to create one. Follow our guide to [creating a Taskmaster MCP server](/docs/mcp/build/examples/creating-taskmaster-mcp-server).

Once your Taskmaster MCP server is ready, there are two ways to connect it to Cursor:

- Use the Gram CLI to open a browser-based installation flow (recommended).
- Manually edit the Cursor MCP configuration file.

## Connecting Cursor using the Gram CLI

The Gram CLI provides the simplest way to connect Cursor to a Gram-hosted MCP server. The CLI opens a browser-based installation flow that configures the connection automatically.

### 1. Install the Gram CLI

Verify the installation:

```bash
gram --version
```

For more information about the Gram CLI, see the [Gram CLI documentation](/docs/mcp/reference/command-line).

### 2. Authenticate with Gram

Authenticate with your Gram account:

```bash
gram auth
```

Follow the prompts to complete authentication. This creates an API key and saves it locally.

Verify authentication:

```bash
gram whoami
```

### 3. Install the toolset

Open Cursor's integrated terminal with `` Cmd + ` `` on macOS or `` Ctrl + ` `` on Windows/Linux and run:

```bash
gram install cursor --toolset your-toolset-slug
```

Replace `your-toolset-slug` with the slug of your toolset. For example, to install the Taskmaster toolset:

```bash
gram install cursor --toolset taskmaster
```

Cursor's "Add MCP Server" modal will automatically pop up with the configuration pre-filled. Click **Install** to complete the setup.

<video controls={false} aria-label="Installing a Gram toolset in Cursor using the Gram CLI" loop={true} autoPlay={true} muted={true} width="100%">
  <source
    src="/assets/docs/gram/videos/install-gram-cli-cursor.mp4"
    type="video/mp4"
  />
</video>

For more details and advanced options, see the [`gram install` documentation](/docs/mcp/reference/command-line/install).

### 4. Test the connection

Open Cursor's AI chat by clicking the chat icon or pressing `Cmd/Ctrl + L`. Verify the connection by creating a test task:

```
Create a new task called "Test MCP connection" with description "Verify that the Taskmaster MCP server is working correctly"
```

Cursor will use the Gram-hosted MCP server to create the task through the Taskmaster API.

## Manual Setup

Alternatively, you can manually configure Cursor by editing the MCP configuration file directly.

<div className="flex justify-center">
  <video controls muted={true}>
    <source src="/assets/docs/gram/videos/installing-mcp-cursor.mp4" type="video/mp4"></source>
    Your browser does not support the video tag.
  </video>
</div>

### 1. Access the Cursor MCP configuration

In Cursor, navigate to **Settings -> Cursor Settings** and open **Tools & Integrations**. Look for the **MCP Tools** section and click **Add Custom MCP**.

### 2. Add the MCP server configuration

Cursor's global MCP configuration file will open. Add your Taskmaster MCP server configuration.

For **Pass-through Authentication**, the configuration looks like this:

```json
{
  "mcpServers": {
    "GramTaskmaster": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://app.getgram.ai/mcp/your-taskmaster-slug",
        "--header",
        "MCP-TASK-MASTER-API-KEY:${MCP_TASK_MASTER_API_KEY}"
      ],
      "env": {
        "MCP_TASK_MASTER_API_KEY": "your-api-key"
      }
    }
  }
}
```

For a **Managed Authentication** server, the configuration looks like this:

```json
{
  "mcpServers": {
    "GramTaskmaster": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://app.getgram.ai/mcp/your-taskmaster-slug",
        "--header",
        "Authorization: ${GRAM_KEY}"
      ],
      "env": {
        "GRAM_KEY": "Bearer your-gram-api-key"
      }
    }
  }
}
```

Replace `your-taskmaster-slug` with the actual slug from your Taskmaster MCP server configuration and `your-gram-api-key` with your Gram API key.

### 3. Test the connection

Open Cursor's AI chat by clicking the chat icon or pressing `Cmd/Ctrl + L`. You can now ask questions like:

```
Create a new task called "Implement user authentication" with description "Add login and registration functionality to the app"
```

## Troubleshooting

Here are some common issues and how to fix them.

### Server not connecting

If Cursor can't connect to the Gram server:

- Verify the MCP server URL is correct in your configuration.
- Check that the API behind the MCP server is reachable from your machine.
- Ensure the `npx` command is available (reinstall Node.js if needed).
- Try restarting Cursor after making configuration changes.

### Authentication errors

If you're using an authenticated server and getting authentication errors:

- Verify your Gram API key in the dashboard under **Settings -> API Keys**.
- Ensure the API key is correctly formatted with the `Bearer ` prefix.
- Check that the environment variables are properly set in your configuration.

### Tools not appearing

If the tools aren't showing up in Cursor:

- Test the MCP server in the **Gram Playground** first to ensure it's working.
- Check that the toolset includes the tools you expect to use.
- Verify the environment is correctly configured with the required variables.
- Look for any error messages in Cursor's output panel.

## What's next

Ready to build your own MCP server? [Try Gram today](/book-demo) and see how easy it is to turn any API into agent-ready tools that work across all your development environments.
