Difference between revisions of "Module6-New"
| (3 intermediate revisions by the same user not shown) | |||
| Line 11: | Line 11: | ||
== Using the Wiki == | == Using the Wiki == | ||
| + | |||
{{RequiredInstructions|content= | {{RequiredInstructions|content= | ||
Text enclosed by <syntaxhighlight lang="bash" inline><</syntaxhighlight> and <syntaxhighlight lang="bash" inline>></syntaxhighlight> should be replaced by content unique to you. | Text enclosed by <syntaxhighlight lang="bash" inline><</syntaxhighlight> and <syntaxhighlight lang="bash" inline>></syntaxhighlight> should be replaced by content unique to you. | ||
| − | + | Example | |
<source lang="bash"> | <source lang="bash"> | ||
$ sudo useradd -r -m -c "<My Full Name>" <usernameHere> | $ sudo useradd -r -m -c "<My Full Name>" <usernameHere> | ||
</source> | </source> | ||
| + | |||
becomes | becomes | ||
| + | |||
<source lang="bash"> | <source lang="bash"> | ||
$ sudo useradd -r -m -c "Zach Cohn" zcohn | $ sudo useradd -r -m -c "Zach Cohn" zcohn | ||
| Line 27: | Line 30: | ||
== Reading == | == Reading == | ||
| − | The following articles | + | The following articles contain information that will help you complete the assignments. |
* [[Python]] | * [[Python]] | ||
* [[Regular Expressions]] | * [[Regular Expressions]] | ||
| − | * [[MCP Fundamentals]] | + | * [[MCP Fundamentals|Model Context Protocol (MCP)]] |
* [[FAQ - Mod 6]] | * [[FAQ - Mod 6]] | ||
| Line 38: | Line 41: | ||
=== Learn Python and Regular Expressions === | === Learn Python and Regular Expressions === | ||
| − | Up to this point in CSE 330 | + | 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: | |
| − | + | * [[Python]] | |
| + | * [[Regular Expressions]] | ||
| − | + | You should use Python 3. | |
| − | + | === Write some Regular Expressions === | |
| − | |||
| − | |||
| − | + | Write regular expressions that do the following: | |
| − | + | # Match the substring "hello world" | |
| + | # Match strings containing three or more consecutive vowels | ||
| + | # Match a flight code of format AA#### | ||
| − | + | Save them as: | |
| − | + | <code>regex1.txt</code> | |
| + | <code>regex2.txt</code> | ||
| + | <code>regex3.txt</code> | ||
| − | === | + | === Baseball Stats Counter === |
| − | + | You will write a Python script that reads box score data and computes batting averages. | |
| − | |||
| − | |||
| − | |||
| − | |||
==== Input ==== | ==== Input ==== | ||
| − | Sample | + | Sample files: |
http://classes.engineering.wustl.edu/cse330/content/cardinals/ | http://classes.engineering.wustl.edu/cse330/content/cardinals/ | ||
| − | Each game begins with a header | + | Each game begins with a header: |
| − | |||
| − | |||
<pre> | <pre> | ||
| Line 84: | Line 82: | ||
</pre> | </pre> | ||
| − | Each player | + | Each player line follows: |
<pre> | <pre> | ||
XXX batted # times with # hits and # runs | XXX batted # times with # hits and # runs | ||
</pre> | </pre> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==== Output ==== | ==== Output ==== | ||
| − | + | Compute batting average: | |
| − | |||
| − | |||
<pre> | <pre> | ||
| Line 105: | Line 96: | ||
</pre> | </pre> | ||
| − | Example | + | Example: |
<pre> | <pre> | ||
| Line 111: | Line 102: | ||
</pre> | </pre> | ||
| − | + | Sort players by batting average. | |
=== Baseball Stats MCP Extension === | === Baseball Stats MCP Extension === | ||
| − | In this project you will build a '''custom MCP server''' that allows Claude Desktop to explore historical | + | 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 ==== | ==== Goal ==== | ||
| Line 125: | Line 114: | ||
Your MCP server should: | Your MCP server should: | ||
| − | * read Cardinals batting | + | * read Cardinals batting averages |
| − | * | + | * expose tools to analyze the data |
* run inside Docker | * run inside Docker | ||
* connect to Claude Desktop | * connect to Claude Desktop | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==== Project Structure ==== | ==== Project Structure ==== | ||
| − | |||
| − | |||
<source lang="text"> | <source lang="text"> | ||
| Line 162: | Line 131: | ||
</source> | </source> | ||
| − | ==== | + | ==== Verify Your MCP Server Works ==== |
| + | |||
| + | Before connecting Claude Desktop verify the container runs. | ||
| + | |||
| + | <source lang="bash"> | ||
| + | docker run --rm -it cardinals-mcp-server | ||
| + | </source> | ||
| + | |||
| + | You should see a startup message. | ||
| − | + | If this fails fix the error before continuing. | |
| − | + | ==== Common Setup Mistakes ==== | |
| − | |||
| − | + | '''Docker image not built''' | |
| − | = | + | <source lang="bash"> |
| + | docker build -t cardinals-mcp-server . | ||
| + | </source> | ||
| + | |||
| + | '''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: | |
| − | < | + | <pre> |
| − | + | Use CardinalsMCP to list the top hitters from 1940 | |
| − | </ | + | </pre> |
| + | |||
| + | the system behaves like this: | ||
| + | |||
| + | <pre> | ||
| + | User prompt | ||
| + | ↓ | ||
| + | Claude reads prompt | ||
| + | ↓ | ||
| + | Claude decides tool | ||
| + | ↓ | ||
| + | Claude calls MCP server | ||
| + | ↓ | ||
| + | Docker launches container | ||
| + | ↓ | ||
| + | Python tool runs | ||
| + | ↓ | ||
| + | Results returned | ||
| + | </pre> | ||
| + | |||
| + | 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 ==== | ||
| − | + | <pre> | |
| + | Use the CardinalsMCP tool to list the 1940 roster | ||
| + | </pre> | ||
| − | < | + | <pre> |
| − | + | Use the CardinalsMCP tool to show Johnny Mize batting averages | |
| − | </ | + | </pre> |
| − | + | <pre> | |
| + | Search for players with Martin in their name | ||
| + | </pre> | ||
== Grading == | == Grading == | ||
| − | + | Total: 50 points. | |
| − | |||
| − | |||
| − | === Regular Expressions (15 | + | === Regular Expressions (15 points) === |
| − | * regex1 | + | * regex1 correct (5) |
| − | * regex2 | + | * regex2 correct (5) |
| − | * regex3 | + | * regex3 correct (5) |
| − | === Baseball Stats Counter (25 | + | === Baseball Stats Counter (25 points) === |
* Python implementation (5) | * Python implementation (5) | ||
| Line 219: | Line 231: | ||
* Correct output (12) | * Correct output (12) | ||
| − | === Baseball Stats MCP Extension (10 | + | === Baseball Stats MCP Extension (10 points) === |
| − | * Docker image builds | + | * Docker image builds (5) |
| − | * | + | * Two MCP tools implemented (3) |
| − | * README | + | * README with example prompts (2) |
[[Category:Module 6]] | [[Category:Module 6]] | ||
[[Category:Modules]] | [[Category:Modules]] | ||
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:
- Match the substring "hello world"
- Match strings containing three or more consecutive vowels
- 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)