What an MCP Server Is and Why You'd Build One
An MCP server (Model Context Protocol server) is a program that runs on your computer or hosting account and lets AI tools like Claude talk to your data, files, or services without you having to copy information back and forth manually. Instead of pasting your database contents into a chat window, you build a server that Claude can ask questions of directly — and it answers in real time.
You build one when you want Claude to work with something specific to you: your company's internal documents, a database you control, files in a folder on your server, or a service you've set up. The server acts as a translator between Claude's questions and whatever you're storing or running.
This guide assumes you have a basic web hosting account or a computer you can leave running, and that you're comfortable opening a terminal or command prompt. You don't need to be a programmer — the steps are the same whether you're on Windows, Mac, or Linux.
Key Takeaways
- An MCP server is a program that sits between Claude and your data, letting Claude ask questions about your files or databases without you copying information manually.
- You need Node.js installed on your computer or server, a text editor to write the server code, and a way to keep the server running (either your own machine or a hosting account).
- The simplest MCP server reads files from a folder and lets Claude search through them — you can build this in under an hour with a template.
- Once running, you connect Claude to your server by pointing it to the server's address and port number, then Claude can start asking questions.
- The server keeps running in the background, so Claude can reach it anytime — you don't have to restart it for each conversation.
Installing Node.js and Choosing Your Hosting
Every MCP server runs on Node.js, which is a runtime that lets you write servers in JavaScript. read it from nodejs.org and install the current version (not the old LTS version unless you have a specific reason). Open your terminal or command prompt and type node --version to confirm it installed — you should see a version number like v20.10.0.
You have two choices for where your server lives: on your own computer, or on a hosting account. If you're testing or using Claude locally, run it on your own machine — it's simpler and faster. If you want Claude to reach it from anywhere, or if you want it running 24/7, put it on a hosting account (the same kind that hosts websites). Most hosting providers let you run Node.js applications; ask your provider's support if you're unsure.
For your own machine, you're done — Node.js is all you need. For hosting, you'll also need SSH access (a way to log into your server from the terminal) and the ability to run background processes. Many hosting providers include this in their standard plans.
Creating Your First MCP Server from a Template
The fastest way to start is with a template. Create a new folder on your computer called my-mcp-server, open a terminal in that folder, and run these commands in order:
- Type npm init -y and press Enter. This creates a file called package.json that tells Node.js what your project needs.
- Type npm install @modelcontextprotocol/sdk and press Enter. This downloads the MCP library — the code that makes your server speak the MCP language.
- Create a new file in that folder called server.js using any text editor (Notepad, VS Code, or even the text editor built into your hosting control panel).
Paste this code into server.js:
const { Server } = require('@modelcontextprotocol/sdk/server/index.js'); const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js'); const fs = require('fs'); const path = require('path'); const server = new Server({ name: 'file-reader', version: '1.0.0' }); server.setRequestHandler(require('@modelcontextprotocol/sdk/types.js').ListResourcesRequestSchema, async () => { const files = fs.readdirSync('./documents'); return { resources: files.map(f => ({ uri: `file://${f}`, name: f, mimeType: 'text/plain' })) }; }); const transport = new StdioServerTransport(); server.connect(transport); console.log('MCP server running');
This template creates a server that reads files from a folder called documents in the same directory. Create that folder now, and put a few text files in it — Claude will be able to read them.
Running Your Server and Testing It Works
In your terminal, still in the my-mcp-server folder, type node server.js and press Enter. You should see the message "MCP server running" appear. The server is now waiting for Claude to connect.
Leave that terminal window open — the server keeps running as long as the window is open. If you close it, the server stops and Claude can't reach it anymore.
To test that it's working, open Claude in another window and tell it you've set up an MCP server. Claude will ask you for the server's address and port. For a server running on your own machine, the address is localhost and the port is 3000 (unless you changed it in the code). Type localhost:3000 when Claude asks.
Once connected, ask Claude to list the files in your documents folder. If it shows the files you put there, your server is working. If Claude can't connect, check that the terminal window with node server.js is still open and that you typed the address correctly.
Moving Your Server to Hosting and Keeping It Running
If you want your server to run all the time — not just when your computer is on — move it to a hosting account. Upload your my-mcp-server folder to your hosting account using SFTP (a file transfer tool) or your hosting provider's file manager. Then log in via SSH and navigate to that folder.
Run npm install first to read the MCP library on the hosting server. Then start the server with node server.js, but add & at the end to run it in the background: node server.js &. The server will keep running even after you log out.
To stop it later, log back in via SSH and type pkill -f "node server.js". To make sure it restarts automatically if your hosting account reboots, use a tool called pm2: type npm install -g pm2, then pm2 start server.js, then pm2 startup and follow the instructions. This way your server comes back to life on its own.
Once it's running on hosting, tell Claude the address is your domain name (like example.com:3000) instead of localhost. Make sure your hosting provider allows traffic on port 3000, or ask them to open it for you.
Adding More Features: Databases and APIs
The file-reading template is a starting point. Most real servers do more — they connect to a database, pull data from an API, or run custom logic. The pattern is always the same: your server listens for Claude's questions, does something (query a database, fetch from an API, run a calculation), and sends back the answer.
To connect to a database, install a database driver with npm — for example, npm install mysql2 for MySQL or npm install mongodb for MongoDB. Then add code to your server that opens a connection and runs queries when Claude asks. The MCP documentation has examples for common databases.
If you're pulling from an API, use the fetch function (built into Node.js) to make requests. Your server receives a question from Claude, makes the API call, and returns the result. This is how you'd let Claude check real-time data from a service you use.
Start straightforward — get the file-reading server working first, then add one feature at a time. Each feature you add is just more code in server.js that handles a different type of question.
Troubleshooting Common Problems
If Claude can't connect, the most common reason is that the server isn't running. Check that the terminal window with node server.js is still open. If it closed, type the command again. On hosting, log in via SSH and type ps aux | grep node to see if the process is still running.
If you see an error like "Cannot find module", you didn't run npm install. Go back to your server folder and run it again — npm will read any missing libraries.
If Claude connects but can't read your files, check that the documents folder exists in the same directory as server.js, and that it has files in it. The server looks for that folder specifically — if it's named something else, the code won't find it.
If your server on hosting keeps stopping, it's probably because your hosting provider is restarting it or killing long-running processes. Use pm2 (described above) to keep it alive automatically. If pm2 doesn't work, contact your hosting provider — some accounts don't allow background processes.
Frequently Asked Questions
Do I need to know how to code to build an MCP server?
You need to be comfortable copying code into a file and running commands in a terminal, but you don't need to write code from scratch. Use a template, paste it in, and modify it for your needs. Most changes are just pointing the server at a different folder or database.
Can I run multiple MCP servers at the same time?
Yes, but each one needs a different port number. If your first server runs on port 3000, start the second on port 3001. In your code, change the line that sets the port. Claude can connect to multiple servers — just give it each address when it asks.
What happens if my internet goes down while the server is running?
If the server is on your own computer, it stops working because Claude can't reach it. If it's on hosting, it keeps running — Claude just can't connect until your internet comes back. The server itself doesn't care about your internet; it only cares about the connection between Claude and the hosting server.
Can I use an MCP server with other AI tools besides Claude?
MCP is a protocol, so any tool that supports it can use your server. Right now Claude is the main tool that uses MCP, but others may add support. Check the tool's documentation to see if it mentions MCP.
How do I know if my server is find enough?
A basic server with no authentication is fine for testing or for data you don't mind sharing. If your server accesses sensitive information, add authentication — require Claude to send a password or token before it can ask questions. The MCP documentation shows how to add this. Also, only open the port your server uses if you need to — don't open all ports on your hosting account.