You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this tutorial, we'll build a simple MCP weather server and connect it to a host, Claude for Desktop.
7
+
In this tutorial, we'll build a simple MCP weather server and connect it to a host.
8
8
9
9
## What we'll be building
10
10
11
-
We'll build a server that exposes two tools: `get-alerts` and `get-forecast`. Then we'll connect the server to an MCP host (in this case, Claude for Desktop).
12
-
13
-
> [!NOTE]
14
-
> Servers can connect to any client. We've chosen Claude for Desktop here for simplicity, but we also have a guide on [building your own client](./client.md) as well as a [list of other clients here](https://modelcontextprotocol.io/clients).
11
+
We'll build a server that exposes two tools: `get-alerts` and `get-forecast`. Then we'll connect the server to an MCP host (in this case, VS Code with GitHub Copilot).
15
12
16
13
## Core MCP Concepts
17
14
@@ -365,80 +362,49 @@ main().catch((error) => {
365
362
366
363
Make sure to run `npm run build` to build your server! This is a very important step in getting your server to connect.
367
364
368
-
Let's now test your server from an existing MCP host, Claude for Desktop.
369
-
370
-
## Testing your server with Claude for Desktop
371
-
372
-
> [!NOTE]
373
-
> Claude for Desktop is not yet available on Linux. Linux users can proceed to the [Client guide](./client.md) to build an MCP client that connects to the server we just built.
374
-
375
-
First, make sure you have Claude for Desktop installed. [You can install the latest version here.](https://claude.ai/download) If you already have Claude for Desktop, **make sure it's updated to the latest version.**
365
+
Let's now test your server from an existing MCP host.
376
366
377
-
We'll need to configure Claude for Desktop for whichever MCP servers you want to use. To do this, open your Claude for Desktop App configuration at `~/Library/Application Support/Claude/claude_desktop_config.json`in a text editor. Make sure to create the file if it doesn't exist.
367
+
## Testing your server in VS Code
378
368
379
-
For example, if you have [VS Code](https://code.visualstudio.com/)installed:
369
+
[VS Code](https://code.visualstudio.com/)with [GitHub Copilot](https://github.com/features/copilot) can discover and invoke MCP tools via agent mode. [Copilot Free](https://github.com/features/copilot/plans) is sufficient to follow along.
> Servers can connect to any client. We've chosen VS Code here for simplicity, but we also have a guide on [building your own client](./client-quickstart.md) as well as a [list of other clients here](https://modelcontextprotocol.io/clients).
You'll then add your servers in the `mcpServers` key. The MCP UI elements will only show up in Claude for Desktop if at least one server is properly configured.
376
+
1. Install [VS Code](https://code.visualstudio.com/) (version 1.99 or later).
377
+
2. Install the **GitHub Copilot** extension from the VS Code Extensions marketplace.
378
+
3. Sign in to your GitHub account when prompted.
394
379
395
-
In this case, we'll add our single weather server like so:
380
+
### Configure the MCP server
396
381
397
-
**macOS/Linux:**
382
+
Create a `.vscode/mcp.json` file in your `weather` project root:
2. Launch it by running `node /ABSOLUTE/PATH/TO/PARENT/FOLDER/weather/build/index.js`
427
-
428
-
Save the file, and restart **Claude for Desktop**.
429
-
430
-
### Test with commands
398
+
To verify, run **MCP: List Servers** from the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`). The `weather` server should show a running status.
431
399
432
-
Let's make sure Claude for Desktop is picking up the two tools we've exposed in our `weather` server. You can do this by looking for the "Add files, connectors, and more /" icon.
400
+
### Use the tools
433
401
434
-
After clicking on the plus icon, hover over the "Connectors" menu. You should see the `weather` server listed.
435
-
436
-
If your server isn't being picked up by Claude for Desktop, proceed to the [Troubleshooting](#troubleshooting) section for debugging tips.
437
-
438
-
If the server has shown up in the "Connectors" menu, you can now test your server by running the following commands in Claude for Desktop:
439
-
440
-
- What's the weather in Sacramento?
441
-
- What are the active weather alerts in Texas?
402
+
1. Open **Copilot Chat** (`Ctrl+Alt+I` / `Ctrl+Cmd+I`).
403
+
2. Select **Agent** mode from the mode selector at the top of the chat panel.
404
+
3. Click the **Tools** button to confirm `get-alerts` and `get-forecast` appear.
405
+
4. Try these prompts:
406
+
- "What's the weather in Sacramento?"
407
+
- "What are the active weather alerts in Texas?"
442
408
443
409
> [!NOTE]
444
410
> Since this is the US National Weather Service, the queries will only work for US locations.
@@ -447,57 +413,30 @@ If the server has shown up in the "Connectors" menu, you can now test your serve
447
413
448
414
When you ask a question:
449
415
450
-
1. The client sends your question to Claude
451
-
2.Claude analyzes the available tools and decides which one(s) to use
416
+
1. The client sends your question to the LLM
417
+
2.The LLM analyzes the available tools and decides which one(s) to use
452
418
3. The client executes the chosen tool(s) through the MCP server
453
-
4. The results are sent back to Claude
454
-
5.Claude formulates a natural language response
455
-
6. The response is displayed to you!
419
+
4. The results are sent back to the LLM
420
+
5.The LLM formulates a natural language response
421
+
6. The response is displayed to you
456
422
457
423
## Troubleshooting
458
424
459
425
<details>
460
-
<summary>Claude for Desktop integration issues</summary>
461
-
462
-
**Getting logs from Claude for Desktop**
463
-
464
-
Claude.app logging related to MCP is written to log files in `~/Library/Logs/Claude`:
426
+
<summary>VS Code integration issues</summary>
465
427
466
-
-`mcp.log` will contain general logging about MCP connections and connection failures.
467
-
- Files named `mcp-server-SERVERNAME.log` will contain error (stderr) logging from the named server.
428
+
**Server not appearing or fails to start**
468
429
469
-
You can run the following command to list recent logs and follow along with any new ones:
430
+
1. Verify you have VS Code 1.99 or later (`Help > About`) and that GitHub Copilot is installed.
431
+
2. Verify the server builds without errors: run `npm run build` in the `weather` directory.
432
+
3. Test it manually: run `node build/index.js` — the process should start and wait for input. Press `Ctrl+C` to exit.
433
+
4. Check the server logs: in **MCP: List Servers**, select the server and choose **Show Output**.
434
+
5. If the `node` command is not found, use the full path to the Node binary.
470
435
471
-
```bash
472
-
# Check Claude's logs for errors
473
-
tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
474
-
```
475
-
476
-
**Server not showing up in Claude**
477
-
478
-
1. Check your `claude_desktop_config.json` file syntax
479
-
2. Make sure the path to your project is absolute and not relative
480
-
3. Restart Claude for Desktop completely
481
-
482
-
> [!WARNING]
483
-
> To properly restart Claude for Desktop, you must fully quit the application:
484
-
>
485
-
> -**Windows**: Right-click the Claude icon in the system tray (which may be hidden in the "hidden icons" menu) and select "Quit" or "Exit".
486
-
> -**macOS**: Use Cmd+Q or select "Quit Claude" from the menu bar.
487
-
>
488
-
> Simply closing the window does not fully quit the application, and your MCP server configuration changes will not take effect.
489
-
490
-
**Tool calls failing silently**
436
+
**Tools don't appear in Copilot Chat**
491
437
492
-
If Claude attempts to use the tools but they fail:
493
-
494
-
1. Check Claude's logs for errors
495
-
2. Verify your server builds and runs without errors
496
-
3. Try restarting Claude for Desktop
497
-
498
-
**None of this is working. What do I do?**
499
-
500
-
Please refer to our [debugging guide](https://modelcontextprotocol.io/legacy/tools/debugging) for better debugging tools and more detailed guidance.
438
+
1. Confirm you're in **Agent** mode (not Ask or Edit mode).
439
+
2. Run **MCP: Reset Cached Tools** from the Command Palette, then recheck the **Tools** list.
501
440
502
441
</details>
503
442
@@ -524,9 +463,6 @@ This isn't an error - it just means there are no current weather alerts for that
524
463
525
464
</details>
526
465
527
-
> [!NOTE]
528
-
> For more advanced troubleshooting, check out our guide on [Debugging MCP](https://modelcontextprotocol.io/legacy/tools/debugging).
529
-
530
466
## Next steps
531
467
532
468
Now that your server is running locally, here are some ways to go further:
0 commit comments