Published March 25, 2026

How to Build Your First MCP Server: A Complete Beginner's Guide

The Model Context Protocol (MCP) is becoming the standard for connecting AI assistants to external tools and data sources. In this guide, you'll build your first MCP server from scratch.

mcpmodel context protocoltutorialdevelopmentmcpize

What You'll Need

  • Node.js 18+ installed
  • A text editor (Cursor, VS Code, or any editor you prefer)
  • Basic JavaScript/TypeScript knowledge

Step 1: Install MCPize

The fastest way to create an MCP server is using MCPize, a tool that scaffolds MCP servers automatically:

npm install -g @modelcontextprotocol/mcpize

Step 2: Scaffold Your Server

mcpize create my-first-server --template typescript
cd my-first-server
npm install

This creates a TypeScript project with the MCP SDK pre-configured.

Step 3: Define Your Tools

Open `src/index.ts` and add your first tool:

import { mcp } from '@modelcontextprotocol/sdk';

export const server = mcp.server({
  name: 'my-first-server',
  version: '1.0.0',
});

server.tool(
  'get_weather',
  'Get the current weather for a city',
  {
    city: { type: 'string', description: 'City name' }
  },
  async ({ city }) => {
    // Your tool logic here
    return { content: `The weather in ${city} is sunny.` };
  }
);

Step 4: Test Locally

npm run build
npm start

You should see output indicating your MCP server is running and ready to accept connections.

Step 5: Connect to an AI Client

Once running, you can connect to clients that support MCP (like Cursor or Claude Desktop) by adding this to your client config:

{
  "mcpServers": {
    "my-first-server": {
      "command": "node",
      "args": ["/path/to/your/server/dist/index.js"]
    }
  }
}

Next Steps

Now that you have a working MCP server, you can:

  1. Add more tools — Each tool you add extends what AI assistants can do
  2. Deploy it — Use a hosting platform to make your server accessible
  3. Share it — Publish to GitHub or npm for others to use

Recommended Hosting

For development testing, localhost works fine. For production MCP servers, consider platforms with good uptime and easy deployment. Check out our MCP hosting comparison guide for detailed recommendations.

Affiliate note:

Using our MCPize referral link supports this guide at no extra cost:

MCPize → (mcpize.com?ref=A7RDJ)