How to Build Your Own MCP Server
Skillpedia team · updated 2026-12-01 · 10 min read
Short answer: An MCP server is a small program that gives Claude access to your things: a file, a spreadsheet, an API. To build your own, you install the official MCP library, write one or more "tools," and tell Claude Code where the program is. You don't need to be an experienced programmer. With the example below, your first server can be ready in a few minutes.
Imagine asking Claude to summarize this month's spending spreadsheet, find a recipe in your grandmother's file, or check the current dollar rate before you finalize a budget. Ready-made connectors don't know how to do that your way. When you build your own server, you teach Claude exactly what it can access and how.
Here you'll build a simple server that returns a motivational phrase and connect it to Claude Code. After that, you can swap the content for whatever is useful in your routine.
Table of Contents
- What is an MCP server, anyway?
- Why build a server from scratch?
- The puzzle pieces: what you need to know
- Step by step: let's get to work
- What should you put inside your server?
- Skills that help with this
- Frequently Asked Questions
- Related reading
What is an MCP server, anyway?
MCP stands for Model Context Protocol. It's an open standard that defines how an AI, like Claude, talks to outside tools and data.
Think of MCP as a USB-C port for AI apps. The port's shape is always the same. The MCP server is the adapter you plug into it. It sits between Claude and the "thing" you want to access, and it translates Claude's requests into real actions.
Two terms will come up often:
- Client: the app that uses MCP, such as Claude Code or Claude Desktop.
- Server: the program you build that offers tools or data.
For the full explanation of the protocol, see what MCP is and how an MCP server works. Here, the focus is on getting hands-on.
Why build a server from scratch?
There are already many ready-made MCP servers (on Claude.ai, they appear as "connectors"). So why build your own?
- For things only you have. A file with your grandmother's recipes, written her way. No ready-made server will understand that file. Yours will.
- To combine several tasks into one request. A server can fetch the weather forecast, check traffic on your route, and suggest whether it's worth leaving earlier. All from one sentence.
- To link different systems. If you use one app for tasks and another for notes, a server can search both and combine the information when you ask, "What are my tasks for today and their notes?"
- To learn. It's a small project with results you can see right away.
Before you start, check the list of MCP servers with real examples. Sometimes what you need already exists.
The puzzle pieces: what you need to know
You'll run into some terms along the way. Nothing scary.
- Terminal: the screen where you type text commands instead of clicking icons.
- Node.js and npm: Node runs JavaScript programs outside the browser. npm is the "package installer" that comes with it.
- API: a "waiter" between two programs. Your server asks a website's API for something, and the API returns the answer in a standard format.
- JSON: a common way to organize data as text, using braces
{}, brackets[], names, and values. - Token: the small piece of text that AI processes. The descriptions of your tools also take up space in Claude's context. More details in what tokens are.
And the parts of the server itself:
| Part | Analogy | Role |
|---|---|---|
| Claude (client) | The customer at a restaurant | Places the orders, that is, calls the tools |
| Your MCP server | The waiter | Takes the order, goes to the "kitchen" (file, internet), and brings back the result |
| Tools | The menu | The actions the server knows how to perform, such as "look up recipe" |
| Resources | The kitchen ingredients | Data the server lets Claude read, such as a text file |
5 new skills a week. 1 minute to read.
The most viewed skills of the week, explained simply. Free.
Step by step: let's get to work
We'll build a server that returns a random motivational phrase. The content is silly on purpose. What matters is the structure, which is the same for larger projects.
Prerequisites: Claude Code installed (see how to install it) and Node.js, which you can download from the official Node site.
Create a folder for the project. In the terminal, go to wherever you keep your projects (for example,
cd Documents) and runmkdir meu-primeiro-mcp. Then enter it withcd meu-primeiro-mcp.Start a Node.js project. Run
npm init -y. This createspackage.json, the project's "ingredient list." Then runnpm pkg set type=module. This command tells Node that the code uses the modernimportformat. Without it, the example will throw an error.Install the official MCP library. Run
npm install @modelcontextprotocol/sdk. This is the official kit for building servers. If you prefer Python, there is also an official kit for that language.Create the server file. Create a file named
server.jsin a text editor, such as VS Code, and paste in:// server.js import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js'; // 1. Cria o servidor com nome e versão const server = new Server( { name: 'meu-mcp-motivacional', version: '1.0.0' }, { capabilities: { tools: {} } } // avisa que o servidor oferece ferramentas ); // 2. Nossa lista de frases const frases = [ 'Você é capaz de coisas incríveis!', 'Um passo de cada vez. Você já chegou até aqui.', 'O segredo é começar. Você já começou!', 'Errar faz parte do aprendizado. Siga em frente.', 'Hoje é um ótimo dia para aprender algo novo.' ]; // 3. Mostra ao Claude quais ferramentas existem server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'dar_motivacao', description: 'Fornece uma frase motivacional aleatória para animar o usuário.', inputSchema: { type: 'object', properties: {} }, }, ], })); // 4. Diz o que fazer quando o Claude chamar a ferramenta server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name === 'dar_motivacao') { const frase = frases[Math.floor(Math.random() * frases.length)]; return { content: [{ type: 'text', text: frase }] }; } throw new Error(`Ferramenta não encontrada: ${request.params.name}`); }); // 5. Liga o servidor async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error('Servidor MCP Motivacional rodando...'); } main().catch((error) => { console.error('Algo deu errado:', error); process.exit(1); });Notice the tool's
description. Claude uses it to decide when to use the tool. Write it clearly, as if you were explaining it to a colleague.Tell Claude Code where the server is. In the same folder, create a file named
.mcp.json:{ "mcpServers": { "meu-mcp-motivacional": { "command": "node", "args": ["/CAMINHO/COMPLETO/meu-primeiro-mcp/server.js"] } } }Replace
/CAMINHO/COMPLETO/with the real path to the folder. To find it, runpwdon Mac or Linux, or runcdalone in Command Prompt on Windows.Test it. Still in the folder, type
claudein the terminal. The first time, Claude Code may ask you to approve the project's server. Approve it. Then ask: "I need some motivation, use the tool we created." Claude should calldar_motivacaoand return one of the phrases.
If nothing happens, type /mcp inside Claude Code to see whether the server shows up as connected. The most common error is a wrong path in .mcp.json. To connect the same server to Claude Desktop, follow the guide on how to connect MCP to Claude.
Done. You've built and connected your first MCP server.
What should you put inside your server?
With the structure in place, you only need to swap the tool's "filling." A few ideas:
- Read local files: open your monthly spending CSV and return totals by category, so Claude can summarize where the money went.
- Query a public API: dollar exchange rate, weather forecast, postal code lookup.
- Search your material: look for a word in your recipe file or meeting notes and return only the right passage.
- Format text: receive text from Claude and return it in the exact format you use on Instagram or in your company report.
- Control things at home (advanced): send commands to a smart light, if it has an API.
Two tips that prevent headaches:
- Start with just one tool. Did it work? Then add the second.
- Return little text. Send Claude only what it needs, not the entire file. This saves tokens and makes the answer more precise.
A common question: if all you want is to teach a way of working (a step-by-step process, a text pattern), a skill may be a better fit than a server. See the difference in skills vs MCP.
Skills that help with this
These skills teach Claude to build MCP servers with you. Install one and ask: "Help me build an MCP server that reads my spending spreadsheet."
- mcp-builder-anthropics: guides Claude through creating the server from start to finish, suggesting structure and code. A good next step after this tutorial.
- mcp-server-patterns-affaan-m: provides common code patterns, such as fetching data from an API or reading files, for you to adapt to your project.
- prepare-mcp-integration-paperclipai: helps you organize and document the server before connecting it to other systems, with good practices from the start.
If you've never installed a skill, the guide on how to install skills from GitHub shows the way.
Frequently Asked Questions
Do I need to be an experienced programmer to build an MCP server? No. Basic logic skills and a little JavaScript or Python are enough for simple projects like the one in this example. You can also ask Claude Code itself to write and adjust the code with you.
Will my MCP server use a lot of tokens? Most of the token usage comes from your conversation with Claude. But the name and description of each tool stay in the context, and so does everything the server returns. Short descriptions and lean responses help. Learn more in how to save tokens in Claude Code.
Can I share the server I built? Yes. Publish the code in a GitHub repository and explain how to set it up. If it solves a common problem, others can benefit from it too.
Is it safe to connect my server to personal data? Security is your responsibility. Never put passwords or API keys directly in the code. Use environment variables for them. And only create tools that access what they truly need, preferably read-only at first.
Are skills, connectors, and MCP servers the same thing? No. An MCP server is the program that connects AI to outside tools and data. A connector is how Claude.ai refers to the MCP servers you enable there. A skill is something else: a folder with instructions (the SKILL.md file) that teaches Claude to do a task in a specific way. The full comparison is in skills vs MCP.
Related reading
- What is MCP (Model Context Protocol): the foundation of the protocol, explained simply.
- How to connect MCP to Claude (Desktop and Code): to use your server in the Claude app too.
- MCP servers: a list with real examples: ideas for what others have already built.
- Skills vs MCP: when to build a server and when a skill is enough.
- Claude Desktop: the app where many people use MCP servers day to day.
Free MCP
Give your AI 15,000+ skills, for free
Plug the Skillpedia MCP into Claude, Cursor, Codex or any AI. Before each task, it finds the right skill on its own.
- 01Get your free key
- 02Paste one line into your AI
- 03Ask for any task
Full guide on this topic: What is MCP? The Simple Guide to the Model Context Protocol
5 new skills a week. 1 minute to read.
The most viewed skills of the week, explained simply. Free.