In this post, I will explain what MCP is and how to connect Claude Desktop to your local server for testing. I will keep the explanation simple, with pictures and diagrams to make it easy to follow.
In Part 2, we will see how to add OAuth 2.1 security so other users can connect safely over the internet.
What is MCP?
Model Context Protocol (MCP) is an open standard created by Anthropic. It lets AI models like Claude, ChatGPT, and Cursor talk to external tools, databases, and APIs in a clean and standard way.
Think of MCP like USB-C for AI. Before USB-C, every device had a different charging cable. With MCP, instead of every AI app creating its own custom plugin format, there is one common standard that every app can use to find and run your tools.
MCP defines three main concepts:
| Concept | What it is |
|---|---|
| Tools | Functions the AI can run (for example: send_email, get_weather, create_expense) |
| Resources | Data the AI can read (files, database rows, documents) |
| Prompts | Reusable prompt templates that help the AI perform specific tasks |
What Problem Does MCP Solve?
Imagine you have a toy robot.
This robot is very smart and can help you with many things. But to do real work, it needs to talk to other machines — like a light switch, a database, a weather app, and an online store. The problem is that every machine speaks a different language.
This is difficult because the robot has to learn 100 different languages.
MCP solves this problem. MCP is one common language that everyone agrees to use. The AI speaks MCP, and your server speaks MCP. Because they use the same protocol, they can talk without extra custom code.
What is a "Tool"?
A tool is simply a function that the AI can call. You write the function once in code, and the AI calls it when the user asks for it.
| Tool Name | What it does |
|---|---|
send_email |
Sends an email to someone |
search_web |
Searches the web and returns results |
get_weather |
Gets current weather for a city |
create_note |
Saves a new note in your app |
delete_file |
Deletes a file from storage |
For example, you can tell Claude:
"Send an email to john@example.com and tell him our meeting is at 3:00 PM tomorrow."
Claude sees the send_email tool in your server, fills in the email address and message, and calls the tool. The email gets sent. You do not need to write extra logic during the chat — Claude handles it automatically.
Writing Your First MCP Tool
Writing a tool is straightforward. Every tool has three simple parts:
- Name and Description: Helps Claude understand when to call the tool.
- Input Schema (Zod): Tells Claude what parameters are needed.
- Handler Function: The actual code that runs and talks to your API or database.
Step 1 - Create the Tool File
Here is an example of a simple tool that gets weather data using the MCP SDK and Zod:
Step 2 - Register Your Tool in the Server
Next, register this tool inside your main server file (createMcpServer). This ensures that both your local test server and your future production server can use the same tools:
| Rule | Why it helps |
|---|---|
| One tool = one job | Keep each tool focused on one task so Claude chooses the right one easily. |
| Clear description | Write clear descriptions for the AI so it knows exactly when to trigger the tool. |
| Throw errors on failure | Always use throw new Error() when something fails so Claude knows there was an error. |
Two Ways to Connect: stdio vs HTTP
There are two ways an AI client can talk to your MCP server:
| Feature | stdio (Local) | HTTP (Remote) |
|---|---|---|
| Where it runs | On your own computer only | On a server over the internet |
| Setup | Very easy | Needs HTTPS and authentication setup |
| Security | No auth needed (runs locally) | Requires OAuth 2.1 tokens |
| Best for | Fast local development and testing | Production with real users |
| Speed | Instant | Depends on internet speed |
Simple Rule:
Use stdio while you are coding and testing tools on your computer.
Use HTTP when you deploy your MCP server for production users.
How to Run Your Server
A typical MCP project has two main server files:
| File | Purpose |
|---|---|
src/server.js |
Production HTTP server for web requests |
src/stdio-server.js |
Local stdio server for Claude Desktop |
Here is what the stdio server does when it starts up:
To test the server manually, open your terminal in the project directory (for example D:\MCP Server\MYMCPTEST) and run:
When the server starts successfully, you will see a confirmation message in your terminal:
Note: You do not need to run this command manually every time. Once Claude Desktop is configured, it will start the server automatically.
How to Connect to Claude Desktop
Claude Desktop makes it simple to connect your server. Follow these steps:
Step 1 - Open Claude Desktop and go to Settings
Open Claude Desktop, click the menu in the top left, and select Settings.
Step 2 - Click the Developer Tab
Inside Settings, click the Developer tab on the left sidebar.
Step 3 - Click "Edit Config"
Click the Edit Config button. This will open your claude_desktop_config.json file in your default text editor.
Step 4 - Add Your Server Configuration
Paste your server details inside mcpServers. Use the full path to your build file:
- args: The absolute path to your built file (for example
D:/MCP Server/MYMCPTEST/build/index.js). - env: The environment variables and credentials passed directly to your server.
- NODE_TLS_REJECT_UNAUTHORIZED: "0": Useful if you are using local self-signed SSL certificates for testing.
Save the file after editing.
Step 5 - Close and Reopen Claude Desktop
You must fully close Claude Desktop so it loads the new configuration file:
- Mac: Right-click Claude in your dock and select Quit.
- Windows: Right-click Claude in the system tray (bottom right) and select Exit.
Then open Claude Desktop again.
Step 6 - Verify Your Connected Tools
Open Claude Desktop and go back to Settings → Developer. You will see your server listed and running:
Click on your server to see the full list of tools Claude loaded from it:
Once your tools are visible, your setup is complete and ready to test.
You can now ask Claude to run tasks using plain English in the chat:
"What is the weather in Tokyo?"
"Create a new expense: Office Rent, $500, paid by credit card today."
Claude will choose the right tool, validate the arguments, call your local server, and give you the final answer.
What's Next?
Now that your MCP server is running locally and connected to Claude Desktop, you can easily build and test custom tools on your machine.
In Part 2, we will take this setup to production. We will see how to host the MCP server over HTTP and secure it with OAuth 2.1 — including Dynamic Client Registration (RFC 7591), PKCE verification, and RS256 JWT tokens.
If you have questions or run into any problems while setting up your local server, feel free to leave a comment below.

0 Comments