Skip to content

Commit efe130f

Browse files
authored
Building GraphRAG Python MCP tools (#368)
* course structure, module 1 * add cursor rules for course content * module 2 intro * rework * code review to 2c-add-neo4j-connection * code review to 7-resources * move core features to module 1, use context throughout examples * update module 2, remove text to cypher challenge * add illustration, banner, update flow * add illustration, update summary, update flow * restructure advanced features lesson * Fix errors in qa tests * update tests to enable a run for a single course * switch to streamable-http to enable mcp inspector * update connecting lesson * switch order of code in 2c-add-neo4j-connection * remove mcp instructor, added solutions to repo up to 2c-add-neo4j-connection * qa tests passing
1 parent 440be8d commit efe130f

File tree

37 files changed

+4070
-49
lines changed

37 files changed

+4070
-49
lines changed

.cursor/write-challenge-lesson.mdc

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
# Write a Challenge lesson
7+
8+
Write a practical challenge lesson that guides learners through implementing concepts they learned in previous theory lessons. The lesson should be hands-on, step-by-step, and focused on creating something functional. Use a encouraging but direct tone that assumes the learner has absorbed the theoretical concepts and is ready to apply them practically.
9+
10+
## Constraints
11+
12+
- Keep the lesson focused on one primary implementation goal
13+
- Provide specific, actionable steps with exact commands and code
14+
- Use simple, clear language with no motivational fluff
15+
- Include practical testing and verification steps
16+
- Ensure the challenge builds directly on previous lesson concepts
17+
- Make the outcome immediately testable and verifiable
18+
- Focus on getting something working rather than explaining theory
19+
- Use consistent naming and examples throughout
20+
- Form a checklist of instructions that users can follow step-by-step
21+
- All content should be written in AsciiDoc format
22+
- Use bullet point outlines from the lesson file to create hands-on challenges
23+
24+
## Required Structure
25+
26+
### 1. Challenge Introduction
27+
28+
- Start with a short, succinct recap of the previous lesson (read the directory alphabetically to find the previous lesson content)
29+
- Follow with a single paragraph stating what the reader will do to complete the challenge
30+
- Use format: "In this challenge, you will [action] using [method/tool]"
31+
- Clear statement of the practical goal
32+
33+
### 2. Challenge Goals
34+
35+
- Numbered list (1-5 goals maximum) of specific, measurable outcomes
36+
- Each goal should be actionable and verifiable
37+
- Goals should build logically toward the final implementation
38+
39+
### 3. Step-by-Step Instructions
40+
41+
Break implementation into logical steps (typically 4-6 steps) forming a checklist of instructions:
42+
43+
#### Step Structure:
44+
- **Step N: [Action-oriented title]** (use second-level headings like a to-do or checklist)
45+
- Brief explanation of what this step accomplishes
46+
- Exact commands to run (in code blocks)
47+
- Code to write (in code blocks with filenames)
48+
- Any important notes or explanations
49+
- Instructions should be concise and describe what the user should do
50+
51+
#### Essential Steps to Include:
52+
- Project setup and initialization
53+
- Dependency installation
54+
- Core implementation (the main code)
55+
- Configuration and integration
56+
- Testing and verification
57+
58+
### 4. Verification Section
59+
60+
- Clear checklist of what should be working
61+
- Specific tests or examples to try
62+
- Expected outcomes or behaviors
63+
- Simple troubleshooting hints if needed
64+
65+
### 5. Next Steps Section
66+
67+
- Congratulatory statement acknowledging completion
68+
- Brief summary of what was accomplished
69+
- Connection to the bigger picture or learning objectives
70+
71+
### 6. Experimentation Tips
72+
73+
- Optional "[TIP] Experiment further" section
74+
- 3-4 specific suggestions for extending the implementation
75+
- Focus on variations or enhancements, not completely new concepts
76+
77+
### 7. Summary Section
78+
79+
- Use AsciiDoc format: `[.summary]` and `== Summary`
80+
- Provide a one-paragraph summary of the actions that the user has carried out
81+
- Can use bullet points with **bold key concepts** learned for more complex challenges
82+
- Brief description of each major accomplishment
83+
- Reference to the next lesson topic
84+
85+
Example formats:
86+
```asciidoc
87+
[.summary]
88+
== Summary
89+
90+
You can now install the `neo4j` library and connect to Neo4j by creating a new driver instance.
91+
92+
In the next lesson, you will learn how to execute your first Cypher query.
93+
```
94+
95+
Or for more complex challenges:
96+
```asciidoc
97+
[.summary]
98+
== Summary
99+
100+
In this challenge, you demonstrated how to use the `neo4j` library to connect to Neo4j.
101+
```
102+
103+
## Implementation Guidelines
104+
105+
### Using Bullet Point Outlines:
106+
- If the lesson file contains bullet point outlines, use them to create hands-on challenges
107+
- Convert each bullet point into a concrete, actionable step
108+
- Maintain the logical flow and structure of the original outline
109+
- Transform abstract concepts into specific implementation tasks
110+
111+
### Code and Commands:
112+
- Always provide exact, copy-pasteable code
113+
- Use consistent file names and project structure
114+
- Include command-line instructions with proper syntax
115+
- Specify which directory to run commands from
116+
117+
### Testing:
118+
- Include real-world testing scenarios
119+
- Use actual tools and environments (VS Code, browsers, etc.)
120+
- Provide specific examples to test with
121+
- Make verification steps concrete and measurable
122+
123+
### Tone:
124+
- Encouraging but matter-of-fact
125+
- Assume competence while providing clear guidance
126+
- Celebrate success without excessive enthusiasm
127+
- Focus on practical outcomes over learning theory
128+
129+
## Instruction
130+
131+
Write the final lesson content directly using AsciiDoc format. Do not include bullet points, notes, or meta-commentary. This is the learner-facing copy that guides them through the complete implementation challenge.

.cursor/write-lesson-summary.mdc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
Add a succinct bullet point summary of the information convered in the lesson to the summary section at the bottom of the page.
7+
8+
Write the content in asciidoc, do not use markdown.
9+
10+
Here is an example of a good summary:
11+
12+
```asciidoc
13+
[.summary]
14+
== Summary
15+
16+
The Model Context Protocol (MCP) consists of several key elements:
17+
18+
* **Servers** - Provide capabilities through tools, resources, and prompt templates in a client-server architecture
19+
* **Clients** - Manage one-to-one connections to servers and request available tools, resources, and prompt templates
20+
* **Hosts** - Applications (like Claude Desktop, Amazon Q, or Cursor) that maintain session state, manage clients, and decide which tools to use
21+
22+
In the next lesson, you will learn how to install your first MCP server.
23+
24+
```
25+
26+
You can also provide a summary in paragraph form if many concepts aren't covered.
27+
28+
```asciidoc
29+
[.summary]
30+
== Lesson Summary
31+
32+
In this lesson you learned how to install the Neo4j Python Driver, create a Driver instance, verify connectivity to your database, and execute your first Cypher statement.
33+
34+
For async applications, link:https://neo4j.com/docs/python-manual/current/concurrency/[use the `AsyncGraphDatabase` method].
35+
36+
In the next lesson, you will take a quiz to test your knowledge of installing and creating a driver instance.
37+
38+
```
39+
40+
For instructions on next lesson, check the next file in the directory ordered alphabetically. If that file exists, use the content of the file to write a short summary. If the file is empty or you cannot find a file in the filesystem, feel free to suggest a next lesson and add a `// TODO:` comment above. If the lesson is a challenge, use an assertive statement like "you will open a can of worms using the can of worms extraction methodology."

.cursor/write-theory-lesson.mdc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
# Write a theory lesson
7+
8+
Write a short theory lesson that introduces one or two key concepts to a beginner. The lesson should be factual, direct, and based on consistent examples from movie recommendations. It should be written in a tone that is casual, friendly, and succinct. Avoid filler language or motivational fluff. Stick to useful, clear information. Focus on where the content and subject will be useful for a developer or data scientist in their day to day lives.
9+
10+
## Constraints
11+
12+
- Keep the lesson under 5 minutes to read.
13+
- Only introduce 1–2 new concepts per lesson.
14+
- Use simple language, assume no prior knowledge.
15+
- All examples must relate to movie recommendation systems.
16+
- Use a consistent business-world analogy appropriate for developers or data scientists.
17+
- Do not mix metaphors or use unrelated analogies.
18+
- Do not include hands-on steps or exercises in this lesson.
19+
- Break up content by level 2 and level 3 headings.
20+
- You are describing something, not selling it. Stick to facts, avoid hyperoble. Only include information that is relevant.
21+
22+
## Required Structure
23+
24+
### 1. Introduction
25+
26+
- One sentence recapping what has been learned previously where applicable.
27+
- One short paragraph explaining why this concept is relevant in the context of the course or previous lesson, using a business scenario from movie recommendations.
28+
29+
### 2. Prior Knowledge
30+
31+
- If applicable, briefly mention what was covered in the previous lesson in one sentence.
32+
33+
### 3. Concept(s)
34+
35+
For each concept:
36+
37+
- Provide a clear, plain-language definition.
38+
- Use a consistent analogy from business, relevant to a developer or data scientist.
39+
- Give a concrete example from movie recommendations.
40+
- Include a sentence that someone might say aloud to explain the concept informally.
41+
- (Optional) Include a short description of a supporting visual.
42+
43+
### 4. Practical Context
44+
45+
- One sentence applying how the concept or concepts fit into a larger system, product, or workflow.
46+
47+
### 5. Teaser
48+
49+
- One sentence describing what the learner will do or build in the next lesson, phrased as a challenge.
50+
51+
## Instruction
52+
53+
Write the final lesson content directly. Do not include bullet points, notes, or meta-commentary. This is the learner-facing copy.
56.8 KB
Loading
Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,47 @@
11
= Building GraphRAG Python MCP tools
2-
:categories: llms:99
2+
:usecase: recommendations
3+
:caption: Build your own GraphRAG MCP server with graph-backed tools and resources.
4+
:key-points: FastMCP server development, Neo4j driver lifecycle management, Context-aware tools with logging, Pagination for large datasets, Text-to-Cypher natural language queries
5+
:categories: llms:30, intermediate:20
6+
:duration: 2 hours
7+
:repository: neo4j-graphacademy/genai-mcp-build-custom-tools-python
8+
:status: active
39

4-
In this course, you will learn how to:
10+
This course follows on from the link:/courses/genai-mcp-neo4j-tools/[Developing with Neo4j MCP Tools course], which introduces the Model Context Protocol and key concepts like Servers, Clients and Tools.
511

6-
* Build your own MCP tools with Python.
7-
* Serve your MCP tools with the FastAPI MCP server.
12+
In this course, you will build on that knowledge to create your own MCP server using the link:https://github.com/modelcontextprotocol/python-sdk[MCP Python SDK^] and create server features that can be consumed by any MCP client.
13+
14+
15+
16+
== Prerequisites
17+
18+
This course assumes that you have are familiar with the basics of Generative AI and Large Language Models. If you are not, we recommend that you take the link:/courses/genai-fundamentals/[GenAI Fundamentals] and link:/courses/genai-mcp-neo4j-tools/[Developing with Neo4j MCP Tools] courses first.
19+
20+
We also assume a basic understanding of Python and command line tools. We assume that you have Python installed along with the `uv` package manager.
21+
If you are not familiar with uv, you should also link:https://docs.astral.sh/uv/[review the uv documentation].
22+
23+
24+
The course features hands-on challenges using link:https://github.com/settings/copilot[GitHub CoPilot^], you will need to enable either the free or Pro version.
25+
26+
27+
== Duration
28+
29+
{duration}
30+
31+
== What you will learn
32+
33+
* How to build MCP servers with the MCP Python SDK and FastMCP
34+
* How to connect your server to Neo4j using lifespan management
35+
* How to create tools with context, logging, and structured outputs
36+
* How to expose resources and prompts through your server
37+
* How to implement pagination for large Neo4j datasets
38+
* How to integrate MCP tools into development workflows
39+
* Advanced features: Sampling and Completions (optional)
40+
41+
42+
[.includes]
43+
== This course includes
44+
45+
* [lessons]#14 lessons# across 3 modules (including setup)
46+
* [challenges]#7 hands-on challenges# with Neo4j
47+
* [quizes]#Quiz questions# to check your understanding

0 commit comments

Comments
 (0)