Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
07425ab
docs: add advanced MCP units from Anthropic
zealoushacker May 20, 2025
07b32f0
docs: add Unit 3 implementation plan for team review
zealoushacker May 21, 2025
72703c2
feat: implement Unit 3 - Building Custom MCP Servers
zealoushacker May 26, 2025
7357b9b
move project to projects dir
burtenshaw May 27, 2025
c700277
flatten unit3 written material structure
burtenshaw May 27, 2025
1efae10
Merge pull request #1 from huggingface/restructure-anthropic-unit3
zealoushacker May 27, 2025
7c860d6
fix(docs): Updates dir refs in unit3 build mcp server
zealoushacker May 27, 2025
6b45e64
fix(docs): Updates paths to files
zealoushacker May 27, 2025
0c29dfd
refactor: Restructure unit3 project directory to use descriptive naming
zealoushacker May 27, 2025
9f88871
feat: Add Module 2 - Smart File Analysis with MCP Resources
zealoushacker May 27, 2025
5914dc4
refactor: Remove Claude Desktop references in favor of Claude Code
zealoushacker May 27, 2025
087b1b2
fix: Correct claude mcp add command syntax
zealoushacker May 27, 2025
680f23a
first draft commit of content
burtenshaw May 29, 2025
817f166
refactor: Remove Module 2 Resources content while preserving work
zealoushacker May 29, 2025
937d1f3
feat: Add Module 2 - GitHub Actions Integration with MCP Prompts
zealoushacker May 30, 2025
89d5ac5
rename as 3.1 and add conclusion
burtenshaw May 30, 2025
761564b
update paths in toc
burtenshaw May 30, 2025
a317493
feat: Complete Unit 3 Module 3 - Slack Notification Integration
zealoushacker May 30, 2025
82bc5fa
delete extra tip
burtenshaw Jun 2, 2025
67c165d
expand introduction
burtenshaw Jun 2, 2025
2096edb
expand project setup
burtenshaw Jun 2, 2025
983a761
expand client with tip
burtenshaw Jun 2, 2025
b01e276
feat: Comprehensively address @burtenshaw PR feedback for Unit 3
zealoushacker Jun 2, 2025
39e1c9c
add git clone and uv tip
burtenshaw Jun 3, 2025
59dab07
add returns to all tips
burtenshaw Jun 3, 2025
015579e
add in line quizzes
burtenshaw Jun 3, 2025
05c9a75
Merge branch 'main' into pr/50
burtenshaw Jun 3, 2025
0b0c754
fix: Add output limiting to prevent MCP token limit errors
zealoushacker Jun 3, 2025
bd15457
fix: Handle MCP server working directory issue using roots
zealoushacker Jun 5, 2025
751e1c3
Merge branch 'feature/anthropic-course-units' of https://github.com/z…
burtenshaw Jun 5, 2025
983e8f1
Merge pull request #50 from zealoushacker/feature/anthropic-course-units
burtenshaw Jun 5, 2025
2cc3ef8
Merge branch 'release/unit3' into add-unit3-hfprbot
burtenshaw Jun 5, 2025
f4f5ace
Merge branch 'add-unit3-hfprbot' into release/unit3
burtenshaw Jun 5, 2025
e0c84da
finalise table of contents
burtenshaw Jun 5, 2025
586068a
docs: add screencasts demonstrating MCP server functionality in Unit 3
zealoushacker Jun 8, 2025
7c5356d
replace hub links with youtube embedded content
burtenshaw Jun 10, 2025
fcdd02a
Merge pull request #90 from zealoushacker/docs/add-screencasts
burtenshaw Jun 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,6 @@ cython_debug/
# PyPI configuration file
.pypirc

.DS_Store
.DS_Store

videos/
73 changes: 73 additions & 0 deletions projects/unit3/build-mcp-server/solution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Module 1: Basic MCP Server with PR Template Tools

This module implements a basic MCP server that provides tools for analyzing git changes and suggesting appropriate PR templates.

## Setup

### 1. Install uv

Follow the official installation instructions at: https://docs.astral.sh/uv/getting-started/installation/

### 2. Install dependencies

```bash
# Install all dependencies
uv sync

# Or install with dev dependencies for testing
uv sync --all-extras
```

### 3. Configure the MCP Server

Add the server to Claude Code:

```bash
# Add the MCP server
claude mcp add pr-agent -- uv --directory /absolute/path/to/module1/solution run server.py

# Verify it's configured
claude mcp list
```

## Tools Available

1. **analyze_file_changes** - Get the full diff and list of changed files
2. **get_pr_templates** - List available PR templates with their content
3. **suggest_template** - Let Claude analyze changes and suggest a template

## Usage Example

1. Make some changes in a git repository
2. Ask Claude: "Can you analyze my changes and suggest a PR template?"
3. Claude will:
- Use `analyze_file_changes` to see what changed
- Analyze the diff to understand the nature of changes
- Use `suggest_template` to recommend the most appropriate template
- Help you fill out the template based on the specific changes

## How It Works

Unlike traditional template systems that rely on file extensions or simple patterns, this MCP server provides Claude with raw git data and lets Claude's intelligence determine:
- What type of change is being made (bug fix, feature, refactor, etc.)
- Which template is most appropriate
- How to fill out the template based on the actual code changes

This approach leverages Claude's understanding of code and context rather than rigid rules.

## Running Tests

```bash
# Run the validation script
uv run python validate_solution.py

# Run unit tests
uv run pytest test_server.py -v
```

## Running the Server Directly

```bash
# Start the MCP server
uv run server.py
```
115 changes: 115 additions & 0 deletions projects/unit3/build-mcp-server/solution/manual_test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Manual Testing Guide for Module 1 Solution

## Prerequisites

1. Ensure you're in a git repository with some changes
2. Install uv following instructions at: https://docs.astral.sh/uv/getting-started/installation/
3. Install dependencies:
```bash
uv sync --all-extras
```

## Test 1: Validate the Solution

Run the automated validation script:
```bash
uv run python validate_solution.py
```

This will check:
- Git environment
- Python imports
- Server creation
- Tool registration
- Tool execution
- Template creation

## Test 2: Run Unit Tests

```bash
uv run pytest test_server.py -v
```

## Test 3: Test with Claude Code

1. **Configure MCP Server**

Add the server to Claude Code:
```bash
# Add the MCP server
claude mcp add pr-agent -- uv --directory /absolute/path/to/module1/solution run server.py

# Verify it's configured
claude mcp list
```

2. **Restart Claude Code** to pick up the new server

3. **Make Some Git Changes**

In any git repository:
```bash
echo "test change" >> README.md
git add README.md
```

4. **Test with Claude**

Ask Claude:
- "Can you analyze my git changes?"
- "What PR templates are available?"
- "Based on my changes, which PR template should I use?"

## Test 4: Direct Server Testing

You can also test the server directly:

```python
import asyncio
from server import analyze_file_changes, get_pr_templates, suggest_template

async def test():
# Test analyze_file_changes
changes = await analyze_file_changes("main", True)
print("Changes:", changes[:200] + "...")

# Test get_pr_templates
templates = await get_pr_templates()
print("Templates available:", len(json.loads(templates)))

# Test suggest_template
suggestion = await suggest_template(
"Fixed authentication bug",
"bug"
)
print("Suggestion:", json.loads(suggestion)["recommended_template"]["type"])

asyncio.run(test())
```

## Expected Behavior

1. **analyze_file_changes** should return JSON with:
- base_branch
- files_changed
- statistics
- commits
- diff (if include_diff=True)

2. **get_pr_templates** should return JSON array of templates with:
- filename
- type
- content

3. **suggest_template** should return JSON with:
- recommended_template
- reasoning
- template_content
- usage_hint

## Troubleshooting

- **"Git not found"**: Ensure you're in a git repository
- **Import errors**: Check virtual environment is activated
- **MCP connection failed**: Verify the path in the claude mcp add command is absolute
- **No tools showing**: Restart Claude Code after adding the server
28 changes: 28 additions & 0 deletions projects/unit3/build-mcp-server/solution/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[project]
name = "pr-agent"
version = "1.0.0"
description = "MCP server for PR template suggestions"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"mcp[cli]>=1.0.0",
]

[project.optional-dependencies]
dev = [
"pytest>=8.3.0",
"pytest-asyncio>=0.21.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["."]

[tool.uv]
dev-dependencies = [
"pytest>=8.3.0",
"pytest-asyncio>=0.21.0",
]
Loading