This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

MCP Servers

Think of MCP servers as special helpers that give Cline extra powers! They let Cline do cool things like fetch web pages or work with your files.

1 - Overview

This document explains Model Context Protocol (MCP) servers, their capabilities, and how Cline can help build and use them.

Cline and Model Context Protocol (MCP) Servers: Enhancing AI Capabilities

Quick Links:

This document explains Model Context Protocol (MCP) servers, their capabilities, and how Cline can help build and use them.

Overview

MCP servers act as intermediaries between large language models (LLMs), such as Claude, and external tools or data sources. They are small programs that expose functionalities to LLMs, enabling them to interact with the outside world through the MCP. An MCP server is essentially like an API that an LLM can use.

Key Concepts

MCP servers define a set of “tools,” which are functions the LLM can execute. These tools offer a wide range of capabilities.

Here’s how MCP works:

  • MCP hosts discover the capabilities of connected servers and load their tools, prompts, and resources.
  • Resources provide consistent access to read-only data, akin to file paths or database queries.
  • Security is ensured as servers isolate credentials and sensitive data. Interactions require explicit user approval.

Use Cases

The potential of MCP servers is vast. They can be used for a variety of purposes.

Here are some concrete examples of how MCP servers can be used:

  • Web Services and API Integration:

    • Monitor GitHub repositories for new issues
    • Post updates to Twitter based on specific triggers
    • Retrieve real-time weather data for location-based services
  • Browser Automation:

    • Automate web application testing
    • Scrape e-commerce sites for price comparisons
    • Generate screenshots for website monitoring
  • Database Queries:

    • Generate weekly sales reports
    • Analyze customer behavior patterns
    • Create real-time dashboards for business metrics
  • Project and Task Management:

    • Automate Jira ticket creation based on code commits
    • Generate weekly progress reports
    • Create task dependencies based on project requirements
  • Codebase Documentation:

    • Generate API documentation from code comments
    • Create architecture diagrams from code structure
    • Maintain up-to-date README files

Getting Started

Choose the right approach for your needs:

  • Use Existing Servers: Start with pre-built MCP servers from GitHub repositories
  • Customize Existing Servers: Modify existing servers to fit your specific requirements
  • Build from Scratch: Create completely custom servers for unique use cases

Integration with Cline

Cline simplifies the building and use of MCP servers through its AI capabilities.

Building MCP Servers

  • Natural language understanding: Instruct Cline in natural language to build an MCP server by describing its functionalities. Cline will interpret your instructions and generate the necessary code.
  • Cloning and building servers: Cline can clone existing MCP server repositories from GitHub and build them automatically.
  • Configuration and dependency management: Cline handles configuration files, environment variables, and dependencies.
  • Troubleshooting and debugging: Cline helps identify and resolve errors during development.

Using MCP Servers

  • Tool execution: Cline seamlessly integrates with MCP servers, allowing you to execute their defined tools.
  • Context-aware interactions: Cline can intelligently suggest using relevant tools based on conversation context.
  • Dynamic integrations: Combine multiple MCP server capabilities for complex tasks. For example, Cline could use a GitHub server to get data and a Notion server to create a formatted report.

Security Considerations

When working with MCP servers, it’s important to follow security best practices:

  • Authentication: Always use secure authentication methods for API access
  • Environment Variables: Store sensitive information in environment variables
  • Access Control: Limit server access to authorized users only
  • Data Validation: Validate all inputs to prevent injection attacks
  • Logging: Implement secure logging practices without exposing sensitive data

Resources

There are various resources available for finding and learning about MCP servers.

Here are some links to resources for finding and learning about MCP servers:

2 - Quick Start

Think of MCP servers as special helpers that give Cline extra powers! They let Cline do cool things like fetch web pages or work with your files.

🚀 MCP Quickstart Guide

❓ What’s an MCP Server?

Think of MCP servers as special helpers that give Cline extra powers! They let Cline do cool things like fetch web pages or work with your files.

⚠️ IMPORTANT: System Requirements

STOP! Before proceeding, you MUST verify these requirements:

Required Software

  • ✅ Latest Node.js (v18 or newer)

  • ✅ Latest Python (v3.8 or newer)

  • ✅ UV Package Manager

    • After installing Python, run: pip install uv
    • Verify with: uv --version

❗ If any of these commands fail or show older versions, please install/update before continuing!

⚠️ If you run into other errors, see the “Troubleshooting” section below.

🎯 Quick Steps (Only After Requirements Are Met!)

1. 🛠️ Install Your First MCP Server

  1. From the Cline extension, click the MCP Server tab
  2. Click the Edit MCP Settings button
MCP Server Panel
  1. The MCP settings files should be display in a tab in VS Code.
  2. Replace the file’s contents with this code:

For Windows:

{
	"mcpServers": {
		"mcp-installer": {
			"command": "cmd.exe",
			"args": ["/c", "npx", "-y", "@anaisbetts/mcp-installer"]
		}
	}
}

For Mac and Linux:

{
	"mcpServers": {
		"mcp-installer": {
			"command": "npx",
			"args": ["@anaisbetts/mcp-installer"]
		}
	}
}

After saving the file:

  1. Cline will detect the change automatically
  2. The MCP installer will be downloaded and installed
  3. Cline will start the MCP installer
  4. You’ll see the server status in Cline’s MCP settings UI:
MCP Server Panel with Installer

🤔 What Next?

Now that you have the MCP installer, you can ask Cline to add more servers from:

  1. NPM Registry: https://www.npmjs.com/search?q=%40modelcontextprotocol
  2. Python Package Index: https://pypi.org/search/?q=mcp+server-&o=

For example, you can ask Cline to install the mcp-server-fetch package found on the Python Package Index:

"install the MCP server named `mcp-server-fetch`
- ensure the mcp settings are updated.
- use uvx or python to run the server."

You should witness Cline:

  1. Install the mcp-server-fetch python package
  2. Update the mcp setting json file
  3. Start the server and start the server

The mcp settings file should now look like this:

For a Windows machine:

{
	"mcpServers": {
		"mcp-installer": {
			"command": "cmd.exe",
			"args": ["/c", "npx", "-y", "@anaisbetts/mcp-installer"]
		},
		"mcp-server-fetch": {
			"command": "uvx",
			"args": ["mcp-server-fetch"]
		}
	}
}

You you can always check the status of your server by going to clients MCP server tab. See the image above

That’s it! 🎉 You’ve just given Cline some awesome new abilities!

📝 Troubleshooting

1. I’m Using asdf and Get “unknown command: npx”

There is some slightly bad news. You should still be able to get things to work, but will have to do a bit more manual work unless MCP server packaging evolves a bit. One option is to uninstall asdf , but we will assume you do not want to do that.

Instead, you will need to follow the instructions above to “Edit MCP Settings”. Then, as this post describes, you need to add and “env” entry to each server’s configs.

"env": {
        "PATH": "/Users/<user_name>/.asdf/shims:/usr/bin:/bin",
        "ASDF_DIR": "<path_to_asdf_bin_dir>",
        "ASDF_DATA_DIR": "/Users/<user_name>/.asdf",
        "ASDF_NODEJS_VERSION": "<your_node_version>"
      }

The path_to_asdf_bin_dir can often be found in your shell config (e.g. .zshrc). If you are using Homebrew, you can use echo ${HOMEBREW_PREFIX} to find the start of the directory and then append /opt/asdf/libexec.

Now for some good news. While not perfect, you can get Cline to do this for you fairly reliably for subsequent server install. Add the following to your “Custom Instructions” in the Cline settings (top-right toolbar button):

When installing MCP servers and editing the cline_mcp_settings.json, if the server requires use of npx as the command, you must copy the “env” entry from the “mcp-installer” entry and add it to the new entry. This is vital to getting the server to work properly when in use.

2. I’m Still Getting an Error When I Run the MCP Installer

If you’re getting an error when you run the MCP installer, you can try the following:

  • Check the MCP settings file for errors
  • Read the MCP server’s documentation to ensure the MCP setting file is using the correct command and arguments. 👈
  • Use a terminal and run the command with its arguments directly. This will allow you to see the same errors that Cline is seeing.

3 - Building MCP Server from GitHub

This guide provides a step-by-step walkthrough of how to use Cline to build an existing MCP server from a GitHub repository.

Building MCP Servers from GitHub Repositories

This guide provides a step-by-step walkthrough of how to use Cline to build an existing MCP server from a GitHub repository.

Finding an MCP Server

There are multiple places online to find MCP servers:

  • Cline can automatically add MCP servers to its list, which you can then edit. Cline can clone repositories directly from GitHub and build the servers for you.

  • GitHub: Two of the most common places to find MCP servers on GitHub include:

  • Online directories: Several websites list MCP servers including:

    These directories allow users to sort the servers by various criteria such as downloads, date, stars, and use case. Each entry provides information such as features, tools, and configuration instructions.

  • PulseMCP: This website has a blog post discussing how AI could use MCP servers to make websites obsolete. PulseMCP also includes an FAQ section about MCP servers: https://www.pulsemcp.com/

Building with Cline

  1. Initiate the Process: Provide Cline with the following information:

    • GitHub Repository URL: The URL of the server’s repository.
    • README.md Contents: This is optional but helpful for Cline to understand the server’s purpose and configuration. You can copy the README.md file from the GitHub repository.
  2. Example Interaction with Cline:

    User: "Cline, I want to add the MCP server for Brave browser control. Here's the GitHub link: https://github.com/modelcontextprotocol/servers/tree/main/src/brave Can you add it?"
    
    Cline: "OK. Cloning the repository to the MCP directory. It needs to be built because it has a 'package.json' file. Should I run 'npm run build'?"
    
    User: "Yes, build it."
    
    Cline: "Build complete. This server needs a browser path. Where's your Brave browser executable?"
    
    User: "It's in '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser'."
    
    Cline: "OK. I've updated the server config with that path and added it to 'cline_mcp_settings.json'. Anything else?"
    
    User: "No, that's all. Let's test it."
    
    Cline: "Great! Starting the MCP Inspector to test the server connection. After that, we can try controlling the browser from Cline."
    
  3. Cline’s Actions: Based on your instructions, Cline will perform the following:

    • Repository Cloning: Cline will clone the repository to your local machine, usually in the directory specified in your configuration.
    • Tweaking: You can guide Cline to modify the server’s configuration. For instance:
      • User: “This server requires an API key. Can you find where it should be added?”
      • Cline may automatically update the cline_mcp_settings.json file or other relevant files based on your instructions.
    • Building the Server: Cline will run the appropriate build command for the server, which is commonly npm run build.
    • Adding Server to Settings: Cline will add the server’s configuration to the cline_mcp_settings.json file.

Testing and Troubleshooting

  1. Test the Server: Once Cline finishes the build process, test the server to make sure it works as expected. Cline can assist you if you encounter any problems.
  2. MCP Inspector: You can use the MCP Inspector to test the server’s connection and functionality.

Best Practices

  • Understand the Basics: While Cline simplifies the process, it’s beneficial to have a basic understanding of the server’s code, the MCP protocol (), and how to configure the server. This allows for more effective troubleshooting and customization.
  • Clear Instructions: Provide clear and specific instructions to Cline throughout the process.
  • Testing: Thoroughly test the server after installation and configuration to ensure it functions correctly.
  • Version Control: Use a version control system (like Git) to track changes to the server’s code.
  • Stay Updated: Keep your MCP servers updated to benefit from the latest features and security patches.

4 - Building Custom MCP Server

This guide provides a comprehensive walkthrough of building a custom MCP (Model Context Protocol) server from scratch, leveraging the powerful AI capabilities of Cline. The example used will be building a “GitHub Assistant Server” to illustrate the process.

Building Custom MCP Servers From Scratch Using Cline: A Comprehensive Guide

This guide provides a comprehensive walkthrough of building a custom MCP (Model Context Protocol) server from scratch, leveraging the powerful AI capabilities of Cline. The example used will be building a “GitHub Assistant Server” to illustrate the process.

Understanding MCP and Cline’s Role in Building Servers

What is MCP?

The Model Context Protocol (MCP) acts as a bridge between large language models (LLMs) like Claude and external tools and data. MCP consists of two key components:

  • MCP Hosts: These are applications that integrate with LLMs, such as Cline, Claude Desktop, and others.
  • MCP Servers: These are small programs specifically designed to expose data or specific functionalities to the LLMs through the MCP.

This setup is beneficial when you have an MCP-compliant chat interface, like Claude Desktop, which can then leverage these servers to access information and execute actions.

Why Use Cline to Create MCP Servers?

Cline streamlines the process of building and integrating MCP servers by utilizing its AI capabilities to:

  • Understand Natural Language Instructions: You can communicate with Cline in a way that feels natural, making the development process intuitive and user-friendly.
  • Clone Repositories: Cline can directly clone existing MCP server repositories from GitHub, simplifying the process of using pre-built servers.
  • Build Servers: Once the necessary code is in place, Cline can execute commands like npm run build to compile and prepare the server for use.
  • Handle Configuration: Cline manages the configuration files required for the MCP server, including adding the new server to the cline_mcp_settings.json file.
  • Assist with Troubleshooting: If errors arise during development or testing, Cline can help identify the cause and suggest solutions, making debugging easier.

Building a GitHub Assistant Server Using Cline: A Step-by-Step Guide

This section demonstrates how to create a GitHub Assistant server using Cline. This server will be able to interact with GitHub data and perform useful actions:

1. Defining the Goal and Initial Requirements

First, you need to clearly communicate to Cline the purpose and functionalities of your server:

  • Server Goal: Inform Cline that you want to build a “GitHub Assistant Server”. Specify that this server will interact with GitHub data and potentially mention the types of data you are interested in, like issues, pull requests, and user profiles.
  • Access Requirements: Let Cline know that you need to access the GitHub API. Explain that this will likely require a personal access token (GITHUB_TOKEN) for authentication.
  • Data Specificity (Optional): You can optionally tell Cline about specific fields of data you want to extract from GitHub, but this can also be determined later as you define the server’s tools.

2. Cline Initiates the Project Setup

Based on your instructions, Cline starts the project setup process:

  • Project Structure: Cline might ask you for a name for your server. Afterward, it uses the MCP create-server tool to generate the basic project structure for your GitHub Assistant server. This usually involves creating a new directory with essential files like package.json, tsconfig.json, and a src folder for your TypeScript code. \
  • Code Generation: Cline generates starter code for your server, including:
    • File Handling Utilities: Functions to help with reading and writing files, commonly used for storing data or logs. \
    • GitHub API Client: Code to interact with the GitHub API, often using libraries like @octokit/graphql. Cline will likely ask for your GitHub username or the repositories you want to work with. \
    • Core Server Logic: The basic framework for handling requests from Cline and routing them to the appropriate functions, as defined by the MCP. \
  • Dependency Management: Cline analyzes the code and identifies necessary dependencies, adding them to the package.json file. For example, interacting with the GitHub API will likely require packages like @octokit/graphql, graphql, axios, or similar. \
  • Dependency Installation: Cline executes npm install to download and install the dependencies listed in package.json, ensuring your server has all the required libraries to function correctly. \
  • Path Corrections: During development, you might move files or directories around. Cline intelligently recognizes these changes and automatically updates file paths in your code to maintain consistency.
  • Configuration: Cline will modify the cline_mcp_settings.json file to add your new GitHub Assistant server. This will include:
    • Server Start Command: Cline will add the appropriate command to start your server (e.g., npm run start or a similar command).
    • Environment Variables: Cline will add the required GITHUB_TOKEN variable. Cline might ask you for your GitHub personal access token, or it might guide you to safely store it in a separate environment file. \
  • Progress Documentation: Throughout the process, Cline keeps the “Memory Bank” files updated. These files document the project’s progress, highlighting completed tasks, tasks in progress, and pending tasks.

3. Testing the GitHub Assistant Server

Once Cline has completed the setup and configuration, you are ready to test the server’s functionality:

  • Using Server Tools: Cline will create various “tools” within your server, representing actions or data retrieval functions. To test, you would instruct Cline to use a specific tool. Here are examples related to GitHub:
    • get_issues: To test retrieving issues, you might say to Cline, “Cline, use the get_issues tool from the GitHub Assistant Server to show me the open issues from the ‘cline/cline’ repository.” Cline would then execute this tool and present you with the results.
    • get_pull_requests: To test pull request retrieval, you could ask Cline to “use the get_pull_requests tool to show me the merged pull requests from the ‘facebook/react’ repository from the last month.” Cline would execute this tool, using your GITHUB_TOKEN to access the GitHub API, and display the requested data. \
  • Providing Necessary Information: Cline might prompt you for additional information required to execute the tool, such as the repository name, specific date ranges, or other filtering criteria.
  • Cline Executes the Tool: Cline handles the communication with the GitHub API, retrieves the requested data, and presents it in a clear and understandable format.

4. Refining the Server and Adding More Features

Development is often iterative. As you work with your GitHub Assistant Server, you’ll discover new functionalities to add, or ways to improve existing ones. Cline can assist in this ongoing process:

  • Discussions with Cline: Talk to Cline about your ideas for new tools or improvements. For example, you might want a tool to create_issue or to get_user_profile. Discuss the required inputs and outputs for these tools with Cline.
  • Code Refinement: Cline can help you write the necessary code for new features. Cline can generate code snippets, suggest best practices, and help you debug any issues that arise.
  • Testing New Functionalities: After adding new tools or functionalities, you would test them again using Cline, ensuring they work as expected and integrate well with the rest of the server.
  • Integration with Other Tools: You might want to integrate your GitHub Assistant server with other tools. For instance, in the “github-cline-mcp” source, Cline assists in integrating the server with Notion to create a dynamic dashboard that tracks GitHub activity. \

By following these steps, you can create a custom MCP server from scratch using Cline, leveraging its powerful AI capabilities to streamline the entire process. Cline not only assists with the technical aspects of building the server but also helps you think through the design, functionalities, and potential integrations.