ML 133: MCP with Claude (15 pts extra)

What You Need

Purpose

To create a local agent which automatically performs actions, using Claude and MCP (Model Context Protocol)

Installing Claude for Desktop

You need a local agent to forward requests to Claude in the cloud.

In a Web browser, go to: https://claude.ai/download. Download and install the version of Claude for Desktop appropriate for your OS.

Launch the Claude app, as shown below.

In the Claude window, click "Get started".

Log in with a Google account.

Skip the "Quick entry" demonstration and click through the introductry screens.

At the "Meet Sonnet 4.5--Claude at its best" box, click "Start chatting".

Ask this question:

What's the weather in Sacramento?
Claude answers the question with information it found somewhere on the Web, as shown below.

Preparing your MCP Server

Go to this page: Build an MCP server

Follow the instructions in this section:

Set up your environment
Use the "ls -l" or "dir" command to view the files you created. You should see a "weather.py" file, with size 0, as shown below.

Edit that file using nano or Notepad, and insert the code from the Build an MCP server page in the "Building your server" section.

The code is in four blocks on that page:

Save the file.

Use the "ls -l" or "dir" command to view the files you created. The "weather.py" file is now several kilobytes in size, as shown below.

Starting the MCP Server

Execute this command:
uv run weather.py
The server runs, but has no output.

Press Ctrl+C twice to stop the server.

Finding Absolute Paths

You need two paths:

Path to uv

Execute which uv on macOS/Linux or where uv on Windows.

The path you need is highlighted in the image below.

Path to weather.py

Use the "ls -l" or "dir" command to view files, and make sure you can see the weather.py file.

Then execute pwd on macOS/Linux or cd on Windows.

The path you need is highlighted in the image below.

Connecting Claude to your MCP Server

Follow the instructions from the Build an MCP server page in the "Testing your server with Claude for Desktop" section.

On a Mac, you'll execute this command to create the file you need:

nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
Put the full path to the uv executable in the command field, and the absolute path to your server in the line after the line containing "--directory", as shown below.

Save the claude_desktop_config.json fie.

Close Claude for Desktop and restart it.

Click the "Search and tools" button, outlined in red in the image below.

Then click the right-arrow icon next to "weather", outlined in green in the image below.

You see the two tools "Get forecast" and "Get alerts", as shown below.

Ask this question:
What's the weather in Sacramento?
Claude asks whether it's allowed to use the weather tool, as shown below.

Click "Allow once".

You get the official weather report, as shown below.

Flag ML 133.1: Alerts (15 pts)

Ask this question:
What are the active weather alerts in Texas?
Claude asks whether it's allowed to use the weather tool.

Click "Allow once".

The flag is covered by a rectangle in the image below.

References

Build an MCP server

Posted 10-16-25