Skip to main content

Get Your First MCP Server Running

This guide will walk you through setting up, building, and testing your first MCP server. We’ll use the TypeScript Game of Thrones quotes server as our example, but you can follow similar steps for Python or Go.
By the end of this guide, you’ll have a working MCP server that can fetch quotes, perform calculations, and respond to prompts.

Prerequisites

Before you begin, make sure you have:

Node.js

Version 18 or higher for TypeScript examples

Python

Version 3.10 or higher for Python examples

Git

To clone the course repository

Code Editor

VS Code, Cursor, or your preferred editor

Step-by-Step Tutorial

1

Clone the Repository

First, clone the MCP Course repository to get access to all the example code:
The repository structure looks like this:
Each server directory contains a complete, working example you can learn from and modify.
2

Navigate to the Server Directory

Let’s start with the TypeScript server that includes multiple features:
Take a look at the package.json to see the dependencies:
The key dependency is @modelcontextprotocol/sdk, which provides all the MCP functionality.
3

Install Dependencies

Install the required packages:
This will install:
  • The official MCP SDK for TypeScript
  • Zod for schema validation
  • Node-fetch for API calls
  • TypeScript compiler
Make sure you’re using Node.js 18 or higher. Check with node --version.
4

Build the Server

Compile the TypeScript code to JavaScript:
This creates a dist/ directory with the compiled JavaScript files. You should see output like:
If the build succeeds, you’re ready to run the server!
5

Understand the Server Code

Before running the server, let’s look at what it does. Open src/server.ts:
This server exposes:
  • 2 Tools: get_random_quotes and lcm (least common multiple)
  • 2 Resources: Random quotes and person properties
  • 2 Prompts: Game of Thrones analysis and code review
6

Run the Server

Start the MCP server:
The server is now running and waiting for connections via stdio (standard input/output).
MCP servers typically communicate through stdio, which means they don’t print anything to the console. They’re waiting for a client to connect and send requests.
To test the server, you’ll need to connect a client. Keep this terminal open and open a new one for the next step.
7

Connect a Client

In a new terminal, navigate to the TypeScript client:
The client code shows how to connect to the server:
Client Connection
You’ll need to update the path in the client code to point to your compiled server. Change the path in src/index.ts to match your local setup.
8

Test the Server

Run the client to test all server capabilities:
You should see output showing:Available Tools:
Tool Execution Result:
Resource Data:
The client code demonstrates all MCP operations: listing capabilities, calling tools, reading resources, and getting prompts.

Try Other Examples

Now that you have the basic server running, try the other examples:

Python Calculator Server

The Python example uses FastMCP for a simpler API:
Python Server Example
Test it with the Python client:

What’s Next?

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

Learn the Protocol

Understand how MCP works under the hood

Build Custom Tools

Create your own tools for specific use cases

Explore Examples

Deep dive into the server implementations

Integrate with LLMs

Connect your server to Ollama or Claude

Troubleshooting

Check Node.js version: Make sure you’re using Node.js 18 or higher
Check TypeScript compilation: Look for errors in the build step
Verify dependencies: Reinstall packages if needed
Update the server path: Make sure the client points to the correct server locationIn clients/basic-ts/src/index.ts, update:
Check server is running: The server must be compiled and the path must exist
Check package.json type: Make sure "type": "module" is setUse .js extensions: Import statements need .js even for TypeScript files:
This is required for ES modules in TypeScript.
Install MCP SDK: Make sure the package is installed
Check Python version: Use Python 3.10 or higher
Use virtual environment: Recommended for isolation
Still having issues? Check the GitHub repository for the latest code and examples.