
Oleg Blokhin - Getty Images
MCP server tutorial: How to build and manage servers
There's no standard approach to set up and manage MCP servers. This example tutorial teaches you the basics with Claude Desktop and Docker, then examines security and management.
The Model Context Protocol connects AI assistants to data sources and software utilities. An essential part of MCP is servers. MCP servers are interfaces that act as the connection point between an AI model and the external services it accesses to complete tasks.
Because there are so many ways to configure and deploy MCP servers, managing them can get tedious. There are also no standardized ways to package and monitor servers. Additionally, servers come with many security concerns that AI and machine learning engineers must protect against.
You need a strategy for building and managing MCP servers to use MCP effectively. Read on for an example tutorial on setting up an MCP server, along with top challenges and best practices to consider.
MCP and the need for servers
MCP standardizes the process of building AI assistant models like AI agents -- software applications capable of completing tasks that require access to custom data or software utilities.
MCP servers connect to the data sources, software commands or APIs necessary to support a specific use case. For instance, a server could connect to a user's Gmail account and perform actions like reading or writing emails. Or, a server could open files on a local file system. Users can deploy and use multiple MCP servers at the same time.
An MCP server is controlled by a client that facilitates interactions between the server and an LLM. The LLM determines when to use an available MCP server to respond to a user prompt. It then instructs the server to run the appropriate commands.
Setting up an MCP server: A step-by-step guide
To illustrate MCP in action, let's look at the steps to deploy an MCP server, then use it to complete tasks through an LLM. This example uses the filesystem server, which can perform file operations -- such as reading and writing files -- from a computer's local file system.
1. Build the MCP server
The code for this MCP server is available from the official GitHub repository in source form only. To use the server, build a binary by creating a Docker container image.
Start by downloading the source for the MCP server from GitHub using git:
git clone https://github.com/modelcontextprotocol/servers.git
Then, cd into the directory you just downloaded and create a container image using the docker build command with this Dockerfile:
cd servers
docker build -t mcp/filesystem -f src/filesystem/Dockerfile .
2. Configure Claude Desktop
Now, you've built a container image to host the MCP server. To use the server with an LLM, you need to connect it to a client. This tutorial will use Claude Desktop, an application that connects to Anthropic's LLMs.
To make MCP servers available to Claude Desktop, modify the Claude Desktop configuration file called claude_desktop_config.json. The location of the file varies between OSes:
- On Windows. %APPDATA%\Claude\claude_desktop_config.json
- On macOS. ~/Library/Application Support/Claude/claude_desktop_config.json
- On Linux. ~/.config/Claude/claude_desktop_config.json
Claude Desktop doesn't officially support Linux, but you can install it on Ubuntu 25.04 using an unofficial build from GitHub user aaddrick.
Once you locate the claude_desktop_config.json file, open it in a text editor and add a section like the following:
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v", "/home/chris:/home/chris",
"mcp/filesystem",
"/home"
]
}
}
}
This tutorial uses "chris" as the home directory, but your directory will have its own name.
This code tells Claude Desktop to execute the following command at startup:
docker run -i --rm -v /home/chris:/home/chris mcp/filesystem /home
This command starts a container that exposes the directory /home/chris on the host system to the MCP server. It does this by mounting a volume in the container that maps /home/chris on the host to a directory named /home/chris inside the container. If you don't mount this volume, the MCP server can only access files inside the container's file system, not on the host.
After modifying the claude_desktop_config.json file, restart Claude Desktop for changes to take effect.
3. Use the MCP client and server
After restarting Claude Desktop, verify that the server is available by clicking the configuration button in the lower-left corner of the chat box. This button will display -- among other things -- a list of connected MCP servers.

As Figure 1 indicates, the filesystem server is available.
To use the server, ask a question in Claude Desktop that will prompt the LLM to use the MCP server to complete a task.
For example, I submitted the following query: "list the contents of the directory /home/chris".
This generated a pop-up, shown in Figure 2, requesting permission to use the filesystem MCP server to complete the request.

After I granted permission, the model used the server to fulfill the request. Figure 3 shows the resulting output.

I then submitted a prompt asking the model to write a new file named hey.txt to my desktop folder at /home/chris/Desktop. Again, it fulfilled the request using the MCP server.

I verified that the file was created and available directly from the host system.

4. Try a more complex prompt
So far, this tutorial has covered MCP server use that could also be easily accomplished using basic CLI commands (like ls and touch) -- so the operations above are perhaps not especially impressive. To demonstrate what makes an MCP server so powerful, let's try a more complex prompt:
"On my computer, there is a folder named christozzi.com that contains PHP files. Convert those PHP files to HTML. Leave the original PHP files in place."
Claude Desktop completed the task with help from the MCP server. It used the filesystem tool to locate the directory specified in the prompt and identify PHP files within it. The model then converted PHP code to HTML. This part of the task doesn't require help from an MCP server, as most major LLMs can convert code independently.

The traditional way to convert a directory of files from one file type to another is to write a script. Scripting tasks require considerable time, effort and programming skills. With help from an MCP server and an AI agent, I only had to formulate a simple prompt in natural language.
Managing files on a computer is just one use case for MCP servers. To understand everything MCP does, explore the MCP project's list of servers on GitHub. You can also develop your own MCP server from scratch.
MCP server management challenges
Running a single MCP server and connecting it with a client for testing purposes is simple enough. But when you want to use MCP servers for more complex real-world use cases, managing them can quickly become challenging due to the following factors:
- Server deployment. To configure and deploy servers, the user must manually modify configuration data in a client application like Claude Desktop. With dozens of MCP client applications, each with its own approach to server configuration, deployment can get tedious.
- Server binary management. Currently, there is no standardized way to package MCP servers. If you deploy MCP servers on a local computer, you must keep track of the various binaries running on each server. These could be container images, Python scripts, Node executables or other formats.
- Monitoring. MCP servers do not have a standardized way to generate log files or metrics. An MCP server's ability to generate logs or record error events depends on whether the server includes internal logic for these tasks. As a result, if something goes wrong with the server, it's not always easy to figure out why.
- Security. To prevent MCP servers from carrying out malicious actions -- such as exposing sensitive data to an LLM or deleting files -- you must restrict their capabilities on a case-by-case basis. Always ensure that you obtain MCP server code from a trusted source.
Best practices for managing MCP servers
These best practices can streamline MCP server management:
- Deploy MCP servers consistently. Choose a single approach to run all MCP servers, such as deploying them as container images.
- Store MCP server binaries in a central place. Store all MCP servers in a single location, like a container registry. It ensures you keep track of the assets, and can help mitigate security risks, provided you enforce appropriate access controls on the storage location.
- Be wary of servers from unknown sources. Don't download MCP server code from obscure GitHub repositories. Stick with servers provided by or officially endorsed by a trusted source.
- Restrict MCP server permissions. When configuring MCP server capabilities, follow the principle of least privilege by allowing each server to access only the specific commands and data sources necessary to support a desired use case.
- Use MCP server management tools. Look into tools such as GetMCP, which automates MCP server configuration and deployment for certain clients, and Inspector, a debugging tool that can troubleshoot servers. While these tools help make MCP servers more suitable for use, Inspector is designed more for debugging code during development than for troubleshooting errors or optimizing performance.
Chris Tozzi is a freelance writer, research adviser and professor of IT and society. He has previously worked as a journalist and Linux systems administrator.