Skip to content

Commit 015579e

Browse files
committed
add in line quizzes
1 parent 983a761 commit 015579e

File tree

3 files changed

+326
-0
lines changed

3 files changed

+326
-0
lines changed

units/en/_toctree.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@
4949
title: Setting up the Project
5050
- local: unit3_1/creating-the-mcp-server
5151
title: Creating the MCP Server
52+
- local: unit3_1/quiz1
53+
title: Quiz 1 - MCP Server Implementation
5254
- local: unit3_1/mcp-client
5355
title: MCP Client
5456
- local: unit3_1/webhook-listener
5557
title: Webhook Listener
58+
- local: unit3_1/quiz2
59+
title: Quiz 2 - Pull Request Agent Integration
5660
- local: unit3_1/conclusion
5761
title: Conclusion

units/en/unit3_1/quiz1.mdx

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Quiz 1: MCP Server Implementation
2+
3+
Test your knowledge of MCP server concepts and implementation for the Pull Request Agent.
4+
5+
### Q1: What is the primary role of an MCP Server in the Pull Request Agent architecture?
6+
7+
<Question
8+
choices={[
9+
{
10+
text: "To host the user interface for the application",
11+
explain: "The MCP Server provides backend capabilities, not the user interface."
12+
},
13+
{
14+
text: "To expose tools and resources that the AI agent can use to interact with GitHub",
15+
explain: "Close, but this project focuses on the Hugging Face Hub, not GitHub."
16+
},
17+
{
18+
text: "To expose tools for reading and updating model repository tags on the Hugging Face Hub",
19+
explain: "Correct! The MCP Server provides get_current_tags and add_new_tag tools for Hub interactions.",
20+
correct: true
21+
},
22+
{
23+
text: "To train the AI model on pull request data",
24+
explain: "MCP Servers provide runtime capabilities, not model training functionality."
25+
}
26+
]}
27+
/>
28+
29+
### Q2: In the FastMCP implementation, why must all MCP tool functions return strings instead of Python objects?
30+
31+
<Question
32+
choices={[
33+
{
34+
text: "To improve performance by reducing memory usage",
35+
explain: "While strings might be more memory efficient, this is not the primary reason."
36+
},
37+
{
38+
text: "To ensure reliable data exchange between the MCP server and client",
39+
explain: "Correct! MCP protocol requires string responses, so we use json.dumps() to serialize data.",
40+
correct: true
41+
},
42+
{
43+
text: "To make the code easier to debug",
44+
explain: "While JSON strings are readable, this is not the primary technical requirement."
45+
},
46+
{
47+
text: "To comply with Hugging Face Hub API requirements",
48+
explain: "This is an MCP protocol requirement, not specific to the Hub API."
49+
}
50+
]}
51+
/>
52+
53+
### Q3: When implementing the `add_new_tag` tool, what is the purpose of checking if a tag already exists before creating a pull request?
54+
55+
<Question
56+
choices={[
57+
{
58+
text: "To reduce API calls and improve performance",
59+
explain: "While this helps performance, it's not the primary reason for the check."
60+
},
61+
{
62+
text: "To prevent creating duplicate pull requests and provide better user feedback",
63+
explain: "Correct! This validation prevents unnecessary PRs and returns meaningful status messages.",
64+
correct: true
65+
},
66+
{
67+
text: "To comply with Hugging Face Hub rate limits",
68+
explain: "While avoiding unnecessary calls helps with rate limits, this is not the primary purpose."
69+
},
70+
{
71+
text: "To ensure the tag format is valid",
72+
explain: "Tag validation is separate from checking if it already exists."
73+
}
74+
]}
75+
/>
76+
77+
### Q4: In the MCP server implementation, what happens when a model repository doesn't have an existing README.md file?
78+
79+
<Question
80+
choices={[
81+
{
82+
text: "The add_new_tag tool will fail with an error",
83+
explain: "The implementation handles this case gracefully."
84+
},
85+
{
86+
text: "The tool creates a new ModelCard with ModelCardData and proceeds with the tag addition",
87+
explain: "Correct! The code handles HfHubHTTPError and creates a new model card when none exists.",
88+
correct: true
89+
},
90+
{
91+
text: "The tool skips adding the tag and returns a warning",
92+
explain: "The tool doesn't skip the operation - it creates what's needed."
93+
},
94+
{
95+
text: "The tool automatically creates a default README with placeholder content",
96+
explain: "It creates a minimal model card structure, not placeholder content."
97+
}
98+
]}
99+
/>
100+
101+
### Q5: What is the significance of using `create_pr=True` in the `hf_api.create_commit()` function call?
102+
103+
<Question
104+
choices={[
105+
{
106+
text: "It makes the commit directly to the main branch",
107+
explain: "Setting create_pr=True creates a pull request, not a direct commit to main."
108+
},
109+
{
110+
text: "It automatically creates a pull request instead of committing directly to the main branch",
111+
explain: "Correct! This enables the review workflow and follows repository governance practices.",
112+
correct: true
113+
},
114+
{
115+
text: "It creates a private branch that only the repository owner can see",
116+
explain: "Pull requests are visible to repository collaborators and can be public."
117+
},
118+
{
119+
text: "It validates the commit before creating it",
120+
explain: "Validation happens regardless of the create_pr parameter."
121+
}
122+
]}
123+
/>
124+
125+
### Q6: Why does the MCP server implementation use extensive logging with emojis throughout the code?
126+
127+
<Question
128+
choices={[
129+
{
130+
text: "To make the code more fun and engaging for developers",
131+
explain: "While emojis are visually appealing, there's a more practical reason."
132+
},
133+
{
134+
text: "To help with debugging and monitoring when the server runs autonomously in response to Hub events",
135+
explain: "Correct! Since the agent responds to webhooks automatically, detailed logs are crucial for troubleshooting.",
136+
correct: true
137+
},
138+
{
139+
text: "To comply with FastMCP logging requirements",
140+
explain: "FastMCP doesn't require specific logging formats or emojis."
141+
},
142+
{
143+
text: "To reduce the amount of text in log files",
144+
explain: "Emojis don't significantly reduce log file size and this isn't the primary goal."
145+
}
146+
]}
147+
/>
148+
149+
Congrats on finishing this Quiz 🥳! If you need to review any elements, take the time to revisit the chapter to reinforce your knowledge.

units/en/unit3_1/quiz2.mdx

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Quiz 2: Pull Request Agent Integration
2+
3+
Test your knowledge of the complete Pull Request Agent system including MCP client integration and webhook handling.
4+
5+
### Q1: What is the primary purpose of the webhook listener in the Pull Request Agent architecture?
6+
7+
<Question
8+
choices={[
9+
{
10+
text: "To provide a user interface for managing pull requests",
11+
explain: "The webhook listener handles GitHub events, not user interfaces."
12+
},
13+
{
14+
text: "To receive and process Hugging Face Hub discussion comment events in real-time",
15+
explain: "Correct! The webhook listener responds to Hub discussion events to trigger agent actions.",
16+
correct: true
17+
},
18+
{
19+
text: "To store pull request data permanently in a database",
20+
explain: "While it may process PR data, its primary role is event handling, not storage."
21+
},
22+
{
23+
text: "To authenticate users with the Hugging Face Hub",
24+
explain: "Webhook listeners handle events, not user authentication."
25+
}
26+
]}
27+
/>
28+
29+
### Q2: In the Agent-based MCP client implementation, how does the client connect to the MCP server?
30+
31+
<Question
32+
choices={[
33+
{
34+
text: "Through direct function calls in the same process",
35+
explain: "The Agent uses subprocess communication, not direct function calls."
36+
},
37+
{
38+
text: "Using stdio connection type to communicate with the MCP server as a subprocess",
39+
explain: "Correct! The Agent starts the MCP server with 'python mcp_server.py' and communicates via stdin/stdout.",
40+
correct: true
41+
},
42+
{
43+
text: "By writing files to a shared directory",
44+
explain: "MCP uses real-time communication, not file-based communication."
45+
},
46+
{
47+
text: "Through HTTP REST API calls",
48+
explain: "The stdio connection type doesn't use HTTP - it uses standard input/output streams."
49+
}
50+
]}
51+
/>
52+
53+
### Q3: Why does the webhook handler use FastAPI's `background_tasks.add_task()` instead of processing requests synchronously?
54+
55+
<Question
56+
choices={[
57+
{
58+
text: "To reduce server memory usage",
59+
explain: "Background tasks don't necessarily reduce memory usage."
60+
},
61+
{
62+
text: "To comply with Hugging Face Hub requirements",
63+
explain: "While Hub expects timely responses, this isn't a specific Hub requirement."
64+
},
65+
{
66+
text: "To return responses quickly (within 10 seconds) while allowing complex tag processing in the background",
67+
explain: "Correct! Webhook endpoints must respond quickly or be considered failed by the sending platform.",
68+
correct: true
69+
},
70+
{
71+
text: "To enable multiple webhook requests to be processed in parallel",
72+
explain: "While this enables parallelism, the primary reason is response time requirements."
73+
}
74+
]}
75+
/>
76+
77+
### Q4: What is the purpose of validating the `X-Webhook-Secret` header in the webhook handler?
78+
79+
<Question
80+
choices={[
81+
{
82+
text: "To identify which repository sent the webhook",
83+
explain: "Repository information comes from the webhook payload, not the secret header."
84+
},
85+
{
86+
text: "To prevent unauthorized requests and ensure the webhook is legitimate from Hugging Face",
87+
explain: "Correct! The shared secret acts as authentication between Hugging Face and your application.",
88+
correct: true
89+
},
90+
{
91+
text: "To decode the webhook payload data",
92+
explain: "The secret is for authentication, not for decoding payload data."
93+
},
94+
{
95+
text: "To determine which MCP tools to use",
96+
explain: "Tool selection is based on the webhook content, not the secret header."
97+
}
98+
]}
99+
/>
100+
101+
### Q5: In the Agent implementation, what happens when `await agent_instance.load_tools()` is called?
102+
103+
<Question
104+
choices={[
105+
{
106+
text: "It downloads tools from the Hugging Face Hub",
107+
explain: "The tools are local MCP server tools, not downloaded from the Hub."
108+
},
109+
{
110+
text: "It discovers and makes available the MCP tools from the connected server (get_current_tags and add_new_tag)",
111+
explain: "Correct! This discovers what tools the MCP server provides and makes them available to the agent's reasoning engine.",
112+
correct: true
113+
},
114+
{
115+
text: "It starts the FastAPI webhook server",
116+
explain: "load_tools() is specific to MCP tool discovery, not starting web servers."
117+
},
118+
{
119+
text: "It authenticates with the Hugging Face API",
120+
explain: "Authentication happens during agent creation, not during tool loading."
121+
}
122+
]}
123+
/>
124+
125+
### Q6: How does the Agent intelligently use MCP tools when processing a natural language instruction?
126+
127+
<Question
128+
choices={[
129+
{
130+
text: "It randomly calls available tools until one works",
131+
explain: "The Agent uses reasoning to determine which tools to call and in what order."
132+
},
133+
{
134+
text: "It always calls get_current_tags first, then add_new_tag second",
135+
explain: "While this might be a common pattern, the Agent reasons about which tools to use based on the instruction."
136+
},
137+
{
138+
text: "It reasons about the instruction and determines which tools to call and in what sequence",
139+
explain: "Correct! The Agent can understand complex instructions and create tool execution plans automatically.",
140+
correct: true
141+
},
142+
{
143+
text: "It requires explicit function calls to be specified in the instruction",
144+
explain: "The Agent can work with natural language instructions without explicit function specifications."
145+
}
146+
]}
147+
/>
148+
149+
### Q7: What filtering logic determines whether a webhook event should trigger tag processing?
150+
151+
<Question
152+
choices={[
153+
{
154+
text: "All webhook events are processed regardless of type",
155+
explain: "The handler filters events to only process relevant ones."
156+
},
157+
{
158+
text: "Only events where action='create' and scope='discussion.comment'",
159+
explain: "Correct! This ensures we only process new discussion comments, ignoring other Hub events.",
160+
correct: true
161+
},
162+
{
163+
text: "Only events from verified repository owners",
164+
explain: "The filtering is based on event type, not user verification status."
165+
},
166+
{
167+
text: "Only events that contain the word 'tag' in the comment",
168+
explain: "Event filtering happens before content analysis - we filter by event type first."
169+
}
170+
]}
171+
/>
172+
173+
Congrats on finishing this Quiz 🥳! If you need to review any elements, take the time to revisit the chapter to reinforce your knowledge.

0 commit comments

Comments
 (0)