Skip to main content

Connect Windsurf to an MCP Server

This guide explains how to connect an MCP server to Windsurf, allowing you to interact with your API using natural language directly within the Windsurf interface.

You can connect Windsurf to:

  • A locally generated MCP server created with liblab.
  • A publicly deployed MCP server accessible via a URL.

Before You Start

Before connecting Windsurf to your MCP server, make sure you have:

  • Access to the Windsurf code editor.
  • One of the following:
tip

To learn more about how MCP works, visit the MCP Concept page.

Connect Windsurf to a Remote MCP Server

Use this method if your MCP server is deployed and accessible over the internet through an URL. If you generated your MCP server using the liblab hosting service, use this option.

  1. Open Windsurf.

  2. In the Windsurf chat, click the MCP servers button (hammer icon), then click Configure. This will open the Manage plugins tab.

  3. Click View raw config to open the mcp_config.json file.

    Steps to open the mcp_config.json file in Windsurf

  4. Add your MCP server configuration using the hosted MCP URL. Replace the placeholder URL (https://mcp.liblab.com/liblab-dev) and environment variable with your actual values.

    mcp_config.json
    {
    "mcpServers": {
    "liblab": {
    "command": "npx",
    "args": [
    "mcp-remote",
    "https://mcp.liblab.com/liblab-dev"
    ]
    }
    }
    }
  5. Back in the Manage plugins tab, click Refresh to connect Windsurf to your MCP server and fetch the available tools.

  6. Once connected, you can query your API using natural language in any Windsurf prompt or chat.

Add Environment Variables for Authentication

If your MCP requires authentication—such as an API key, you can set environment variables that Windsurf will use when making requests to your API. This is done by restarting the MCP using the restart_sdk tool, a built-in utility available in all MCPs generated by liblab.

To set a new environment variable:

  1. Start a new chat using Windsurf using the previously connected MCP.
  2. Ask Windsurf to restart the MCP and provide the environment variable and its value.

Here’s an example where an API key is passed as an environment variable. Note that the variable name (e.g. apiKey) and value format depend on the specific API used to generate the MCP:

restart the mcp and use the apiKey:<your-api-key>

Windsurf will recognize the intent to use the restart_sdk tool and apply the environment variable. All future requests will then include this authentication data.

Connect Windsurf to a Local MCP Server

Use this method if you’re running the MCP server locally, generated from an OpenAPI spec using liblab CLI.

Generate your MCP server with liblab

If you haven’t yet generated your MCP server, follow the Generate an MCP Server with liblab CLI guide.

After generating the server using the liblab CLI, navigate to the output folder and run:

cd output/mcp
npm run setup

Now, you need to update Windsurf's plugins settings:

  1. Open Windsurf.

  2. In the Windsurf chat, click the MCP servers button (hammer icon), then click Configure. The Manage plugins tab will appear.

  3. Click View raw config to open the mcp_config.json file.

  4. Add your local MCP server configuration. Update the path and environment values accordingly, then save the file.

    mcp_config.json
    {
    "mcpServers": {
    "your-local-api": {
    "command": "node",
    "args": [
    "<path-to-liblab-generated-mcp-server>/output/mcp/dist/index.js"
    ],
    "env": {
    "YOUR_API_KEY": "<your-api-key>"
    }
    }
    }
    }
    MCP server authentication

    Make sure to use the correct environment variable name expected by your API.

  5. In the Manage plugins tab or directly within the Windsurf chat, click Refresh to load and activate your local MCP server.

  6. Once connected, you can query your local API using natural language.

    Using MCP in Windsurf

Next Steps

To continue working with MCP and Windsurf, explore these resources: