Difference between revisions of "Module6-New"
| Line 31: | Line 31: | ||
* [[Python]] | * [[Python]] | ||
* [[Regular Expressions]] | * [[Regular Expressions]] | ||
| − | * [[MCP | + | * [[MCP Fundamentals|Model Context Protocol (MCP)]] |
* [[FAQ - Mod 6]] | * [[FAQ - Mod 6]] | ||
Revision as of 15:04, 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 on the online class wiki textbook 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 a new language: Python.
Before starting this assignment, you should look over the online textbook article about Python. You should be using version 3 (or greater) of Python.
Additionally, you may find it helpful to look over the online textbook article about Regular Expressions.
Write some Regular Expressions
Please write regular expressions that do each of the following:
- Match the substring "hello world" in a string.
- Match all character strings in an input string that contain three or more consecutive vowels. The regex should match strings containing three or more consecutive vowels regardless of case.
- Match an input string that is entirely a flight code, of the format AA#### where AA is a two-letter uppercase airline code and #### is a three or four digit flight number.
Save your regexes to text files – one each.
Baseball Stats Counter
The St. Louis Cardinals are one of the most legendary baseball teams in the National League.
In this exercise, you will create a Python script that reads box scores from a file and computes the Cardinals players’ batting averages in a particular season.
Tips and Instructions
- Write a Python script file to solve this problem.
- Use a regular expression to parse players’ names, at-bats, hits, and runs from the input file.
- You may want to create a class to hold player information.
- Your script should take one command-line argument: the path to an input file.
- If no argument is given, your program should print a usage message.
Input
Sample input files may be found here:
http://classes.engineering.wustl.edu/cse330/content/cardinals/
Each game begins with a header line.
Example:
=== St.Louis Cardinals vs. Chicago Cubs, 1940-04-19 ===
Each player performance line follows the format:
XXX batted # times with # hits and # runs
Where:
- XXX is the player name
- # values are integers
Output
Your script must compute batting averages for all players.
Batting Average:
hits / at-bats
Example output format:
Johnny Hopp: 0.275
Players should be sorted by batting average.
Baseball Stats MCP Extension
In this project you will build a custom MCP server that allows Claude Desktop to explore historical St. Louis Cardinals batting data from the 1930 and 1940 seasons.
Your MCP server will read batting averages from text files generated in the previous assignment and expose tools that allow Claude to query that data.
For all parts of this assignment, feel free to use your favorite AI tools to assist you.
Goal
Your MCP server should:
- read Cardinals batting data
- provide tools to analyze player statistics
- run inside Docker
- connect to Claude Desktop
Example Prompts
After your MCP server is running, Claude should be able to answer questions such as:
Use CardinalsMCP to list the top 10 hitters from 1940.
Show Johnny Mize's batting averages for 1930 and 1940.
Search for players with "Martin" in their name.
Claude will automatically call your MCP tools and display the results.
Project Structure
Your project directory should look like this:
cardinals-mcp/
├── Dockerfile
├── cardinals_server.py
├── requirements.txt
└── data/
├── cardinals-1930.txt
└── cardinals-1940.txt
Docker Setup
Install:
- Docker Desktop
- Claude Desktop
Enable the Docker MCP Toolkit in Docker Desktop settings.
MCP Tools
Your server must implement at least two tools.
Possible examples include:
get_player_statsget_team_rosterget_top_playerssearch_players
Each tool should be registered using the @mcp.tool() decorator.
Testing
Build your Docker container:
docker build -t cardinals-mcp-server .
Run it:
docker run --rm -it cardinals-mcp-server
Then connect Claude Desktop to your MCP server and test the example prompts.
Grading
There are 50 points total.
Assignments must be committed to GitHub by the end of class on the due date.
Regular Expressions (15 Points)
- regex1.txt correct (5)
- regex2.txt correct (5)
- regex3.txt 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 successfully (5)
- At least two working MCP tools (3)
- README includes three Claude prompts (2)