Connecting MCP Servers: The Basics

Connecting MCP Servers: The Basics

MCP Servers Connection

Introduction

Installing an AI tool is only half the battle. To make it truly powerful, you need to connect it to MCP servers that give it real capabilities. This lesson covers how MCP servers are configured and how they communicate with your AI clients.

How MCP Servers Communicate

MCP servers talk to AI clients using a standardized protocol based on JSON-RPC. This works over one of two transports:

  • stdio — the server runs as a local process, communicating over standard input/output
  • WebSocket/HTTP — the server runs remotely and communicates over the network
The most common setup for local development is stdio: your AI tool launches the server process and exchanges messages with it.

Configuration Basics

To connect an MCP server, you typically provide a configuration that includes:

  • The server's name
  • The command to launch it (the path to the binary or script)
  • Arguments, if any
  • The environment variables it needs

Example Configuration (JSON)

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/path/to/allowed/project"
      ]
    }
  }
}

Here the filesystem server grants access to a single project directory /path/to/allowed/project — not the whole machine.

The Recommended First Server

For most developers, the filesystem server is the recommended first MCP server to install. It:

  • Lets the AI read and write files within a scoped directory
  • Is simple and low-risk
  • Immediately makes the AI useful for real project work

Step-by-Step: Adding a Server

1. Open your AI tool's MCP configuration 2. Add a new server entry with its command and args 3. Restart or reload the client 4. Verify the server appears and its tools are listed 5. Test with a simple request

Security First

Before connecting any server, always:

  • Review what tools and permissions it requests
  • Scope its access to only what's needed
  • Avoid granting it more rights than necessary
  • Never share API keys stored in its config

Real-World Example

You want your AI assistant to work directly in your project. You connect the filesystem server scoped to your project directory. Now you can ask the assistant to refactor code across multiple files, and it can do so within that directory — without touching the rest of your system.

AI Client
   |
   | stdio JSON-RPC
   v
filesystem MCP Server
   |
   | scoped ops only
   v
/project/directory

Summary

  • MCP servers communicate via JSON-RPC over stdio or WebSocket
  • Configuration includes command, args, and scoped permissions
  • The filesystem server is a great first choice
  • Always review and scope server permissions before use

Next Lesson

Time to build your own. Let's create your first custom MCP server for file operations.

Quiz - Quiz - MCP Basics

1. What is the recommended first MCP server to install for most developers?

2. MCP servers communicate with AI clients via...

3. Before using an MCP server, you should always...