Difference between revisions of "Module6-New"

From CSE330 Wiki
Jump to navigationJump to search
 
Line 34: Line 34:
 
* [[Python]]
 
* [[Python]]
 
* [[Regular Expressions]]
 
* [[Regular Expressions]]
−
* [[MCP-Fundamentals|Model Context Protocol (MCP)]]
+
* [[MCP Fundamentals|Model Context Protocol (MCP)]]
 
* [[FAQ - Mod 6]]
 
* [[FAQ - Mod 6]]
  

Latest revision as of 15:39, 11 March 2026


In Module 6, you will learn the fundamentals of Python, Regular Expressions, and the Model Context Protocol (MCP).

This article contains your assignments for Module 6.

Learning Goals

  • Regular Expressions
  • Python
  • MCP Fundamentals

Using the Wiki

Text enclosed by < and > should be replaced by content unique to you.

Example

$ sudo useradd -r -m -c "<My Full Name>" <usernameHere>

becomes

$ sudo useradd -r -m -c "Zach Cohn" zcohn

Reading

The following articles contain information that will help you complete the assignments.

Individual Assignments

Learn Python and Regular Expressions

Up to this point in CSE 330 you have used only one programming language: PHP.

In this module you will learn Python.

Before starting this assignment review:

You should use Python 3.

Write some Regular Expressions

Write regular expressions that do the following:

  1. Match the substring "hello world"
  2. Match strings containing three or more consecutive vowels
  3. Match a flight code of format AA####

Save them as:

regex1.txt regex2.txt regex3.txt

Baseball Stats Counter

You will write a Python script that reads box score data and computes batting averages.

Input

Sample files:

http://classes.engineering.wustl.edu/cse330/content/cardinals/

Each game begins with a header:

=== St.Louis Cardinals vs. Chicago Cubs, 1940-04-19 ===

Each player line follows:

XXX batted # times with # hits and # runs

Output

Compute batting average:

hits / at-bats

Example:

Johnny Hopp: 0.275

Sort players by batting average.

Baseball Stats MCP Extension

In this project you will build a custom MCP server that allows Claude Desktop to explore historical Cardinals batting data from the 1930 and 1940 seasons.

Your server will expose tools that Claude can use to query the dataset.

Goal

Your MCP server should:

  • read Cardinals batting averages
  • expose tools to analyze the data
  • run inside Docker
  • connect to Claude Desktop

Project Structure

cardinals-mcp/
├── Dockerfile
├── cardinals_server.py
├── requirements.txt
└── data/
    ├── cardinals-1930.txt
    └── cardinals-1940.txt

Verify Your MCP Server Works

Before connecting Claude Desktop verify the container runs.

docker run --rm -it cardinals-mcp-server

You should see a startup message.

If this fails fix the error before continuing.

Common Setup Mistakes

Docker image not built

docker build -t cardinals-mcp-server .

Container name mismatch

The Docker name must match the name in Claude config.

Claude not restarted

Restart Claude Desktop after editing the config.

Container exits immediately

Run the container manually to view the error.

What Claude Is Actually Doing

When you ask Claude:

Use CardinalsMCP to list the top hitters from 1940

the system behaves like this:

User prompt
      ↓
Claude reads prompt
      ↓
Claude decides tool
      ↓
Claude calls MCP server
      ↓
Docker launches container
      ↓
Python tool runs
      ↓
Results returned

Claude does not execute Python directly.

Debugging Your MCP Server

If Claude cannot return results:

1. Verify container runs 2. Verify Python script loads 3. Verify Claude configuration 4. Restart Claude Desktop

Example Prompts

Use the CardinalsMCP tool to list the 1940 roster
Use the CardinalsMCP tool to show Johnny Mize batting averages
Search for players with Martin in their name

Grading

Total: 50 points.

Regular Expressions (15 points)

  • regex1 correct (5)
  • regex2 correct (5)
  • regex3 correct (5)

Baseball Stats Counter (25 points)

  • Python implementation (5)
  • Correct regex parsing (5)
  • Usage message (3)
  • Correct output (12)

Baseball Stats MCP Extension (10 points)

  • Docker image builds (5)
  • Two MCP tools implemented (3)
  • README with example prompts (2)