Skip to content

Commit 3fe3ef3

Browse files
committed
remove mcp instructor, added solutions to repo up to 2c-add-neo4j-connection
1 parent 03cbcee commit 3fe3ef3

File tree

21 files changed

+325
-547
lines changed

21 files changed

+325
-547
lines changed

asciidoc/courses/genai-mcp-build-custom-tools-python/course.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ This course assumes that you have are familiar with the basics of Generative AI
2020
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.
2121
If you are not familiar with uv, you should also link:https://docs.astral.sh/uv/[review the uv documentation].
2222

23-
We also use the link:https://github.com/modelcontextprotocol/inspector[MCP Inspector^] to test and debug your MCP servers and tools. This tool is run through link:https://docs.npmjs.com/cli/v8/commands/npx[the `npx` command]^, so you will need Node.js to be installed. You can link:https://nodejs.org/en/download[download Node.js from the official website^].
2423

2524
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.
2625

@@ -36,14 +35,13 @@ The course features hands-on challenges using link:https://github.com/settings/c
3635
* How to create tools with context, logging, and structured outputs
3736
* How to expose resources and prompts through your server
3837
* How to implement pagination for large Neo4j datasets
39-
* How to use the MCP Inspector to test and debug
4038
* How to integrate MCP tools into development workflows
4139
* Advanced features: Sampling and Completions (optional)
4240

4341

4442
[.includes]
4543
== This course includes
4644

47-
* [lessons]#16 lessons# across 3 modules (including setup)
45+
* [lessons]#14 lessons# across 3 modules (including setup)
4846
* [challenges]#7 hands-on challenges# with Neo4j
4947
* [quizes]#Quiz questions# to check your understanding

asciidoc/courses/genai-mcp-build-custom-tools-python/modules/1-getting-started/lessons/1-mcp-python-sdk/lesson.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In the link:/courses/genai-mcp-neo4j-tools/[Developing with Neo4j MCP Tools cour
66

77
In this course, you will learn how to build your own MCP servers with graph-backed tools and resources, creating a complete GraphRAG application.
88

9-
You will learn to build these tools with the MCP Python SDK, and you will use the MCP Inspector to test your servers.
9+
You will learn to build these tools with the MCP Python SDK, and you will use an interactive Python client to test your servers.
1010

1111
[TIP]
1212
.Emerging standards
@@ -279,4 +279,4 @@ In this lesson, you learned the foundational concepts for building MCP servers w
279279
* **Decorators** - Use `@mcp.tool()`, `@mcp.resource()`, and `@mcp.prompt()` to register features
280280
* **Transport methods** - Run servers using `stdio` (default) or `http` for web deployments
281281

282-
In the next lesson, you will create your first MCP server using FastMCP and test it with the MCP Inspector.
282+
In the next lesson, you will create your first MCP server using FastMCP.

asciidoc/courses/genai-mcp-build-custom-tools-python/modules/1-getting-started/lessons/2-setup/lesson.adoc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ The repository contains a `server/` directory where you will build your MCP serv
4848
Here are the important directories:
4949
5050
* `server/` - Your MCP server code will go here
51-
* `examples/` - Example code demonstrating MCP concepts
51+
* `client/` - An interactive Python client for testing your MCP server
52+
* `solutions/` - Complete solutions for each of the challenges
5253
* `.github/` - GitHub configuration including Codespace setup
5354
5455
@@ -61,10 +62,9 @@ We have created a Neo4j Sandbox instance for you to use during this course, load
6162
To define the connection details as environment variables, create a `.env` file in the `server/` directory with the following values:
6263
6364
64-
[source,env]
65+
[source,env,subs="attributes+"]
6566
.server/.env
6667
----
67-
# Neo4j Connection Details
6868
NEO4J_URI={instance-scheme}://{instance-ip}:{instance-boltPort}
6969
NEO4J_USERNAME={instance-username}
7070
NEO4J_PASSWORD={instance-password}
@@ -88,9 +88,8 @@ NEO4J_USERNAME:: [copy]#{instance-username}#
8888
NEO4J_PASSWORD:: [copy]#{instance-password}#
8989
9090
[TIP]
91+
.Have your own Neo4j Aura database?
9192
====
92-
**Using your own Neo4j Aura database?**
93-
9493
If you have a link:https://neo4j.com/cloud/aura/[Neo4j Aura^] database with the Recommendations dataset, you can use those credentials instead in your `.env` file.
9594
====
9695

@@ -101,13 +100,18 @@ To verify your setup, run the `test_environment.py` script.
101100

102101
[source,bash]
103102
----
104-
python server/test_environment.py
103+
uv --directory client run test_environment.py
105104
----
106105

107106

108107
You should see an `OK` message if you have set up your environment correctly. If any tests fail, check the contents of the `.env` file.
109108

110-
109+
[source,role=nocopy]
110+
----
111+
...
112+
----------------------------------------------------------------------
113+
Ran 3 tests in 0.366s
114+
----
111115
112116
[TIP]
113117
.Accessing Environment Variables in Python

asciidoc/courses/genai-mcp-build-custom-tools-python/modules/1-getting-started/lessons/3c-create-first-server/lesson.adoc

Lines changed: 103 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,25 @@ You can open your existing codespaces at link:https://github.com/codespaces[gith
2222

2323
To complete this challenge, you will need to:
2424

25-
1. Create a new MCP server using the MCP Python SDK.
26-
2. Create a tool that counts the number of times a letter appears in a word.
27-
3. Configure VS Code to use the MCP server with stdio.
28-
4. Test the server using the Chat window in Agent mode.
25+
1. Create a new MCP server using the MCP Python SDK
26+
2. Create a tool that counts the number of times a letter appears in a word
27+
3. Run your MCP server with HTTP transport
28+
4. Test the server using the interactive client
29+
30+
31+
[TIP]
32+
.Solution Available
33+
====
34+
If you get stuck, you can review the complete solution in the repository at `solutions/3c-create-first-server/main.py`.
35+
36+
To see the solution in action, run:
37+
38+
[source,bash]
39+
----
40+
uv --directory solutions/3c-create-first-server run main.py
41+
----
42+
====
43+
2944

3045
== Step-by-Step Instructions
3146

@@ -34,6 +49,7 @@ To complete this challenge, you will need to:
3449
First, create a new directory for your MCP server:
3550

3651
[source,bash]
52+
.Create a new directory
3753
----
3854
mkdir strawberry
3955
cd strawberry
@@ -44,6 +60,7 @@ cd strawberry
4460
Initialize a new Python project using `uv`:
4561

4662
[source,bash]
63+
.Initialize a new UV project
4764
----
4865
uv init
4966
----
@@ -55,6 +72,7 @@ This will create a basic project structure with a `pyproject.toml` file and a `m
5572
Add the MCP Python SDK to your project:
5673

5774
[source,bash]
75+
.Add the MCP Python SDK to your project
5876
----
5977
uv add "mcp[cli]"
6078
----
@@ -70,7 +88,7 @@ Open `main.py` in your editor and add the following code to create a simple MCP
7088
from mcp.server.fastmcp import FastMCP
7189
7290
# Create an MCP server
73-
mcp = FastMCP("Strawbrerry")
91+
mcp = FastMCP("Strawberry")
7492
7593
@mcp.tool()
7694
def count_letters(text: str, search: str) -> int:
@@ -88,24 +106,23 @@ if __name__ == "__main__":
88106
This example uses the `streaming-http` transport method to run the server.
89107
This differs from `stdio` in that the client uses HTTP to communicate with the server.
90108
91-
We have made this choice to make it easier to test the server in GitHub Codespaces with the MCP Inspector.
109+
We have made this choice to make it easier to test the server in GitHub Codespaces with the interactive Python client.
92110
For local development, using `stdio` is also a valid option.
93111
94112
link:https://modelcontextprotocol.io/specification/2025-06-18/basic/transports[Learn more about transports^]
95113
====
96114

97-
=== Step 5: Configure your server in VS Code and test with Agent mode
115+
=== Step 5: Run Your Server
98116

99-
Now let's configure your server to work with VS Code's Agent mode. This will allow you to interact with your MCP server through a conversational interface.
100-
101-
First, let's run the server to make sure it works:
117+
Start your MCP server:
102118

103119
[source,bash]
120+
.Run your MCP server
104121
----
105122
uv run main.py
106123
----
107124

108-
If the server is running, you will see the following output in the terminal:
125+
If the server is running successfully, you will see output similar to:
109126

110127
[source,role=nocopy]
111128
.Console Output
@@ -118,58 +135,99 @@ INFO: Application startup complete.
118135
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
119136
----
120137

138+
Your server is now running on port 8000 and ready to accept connections from MCP clients.
121139

122-
Once the server is running, modify the `.vscode/mcp.json` file to configure VS Code to use the server.
123140

124-
[source,json]
141+
== Test with the Interactive Client
142+
143+
Now let's test your server. The course repository includes an interactive Python client in the `client/` folder that you can use to test your MCP server.
144+
145+
146+
Open a **new terminal** (keep the server running in the first one) and run the following command:
147+
148+
[source,bash]
149+
.Run the interactive client
125150
----
126-
{
127-
"servers": {
128-
"strawberry": {
129-
"type": "http",
130-
"url": "http://localhost:8000/mcp"
131-
}
132-
}
133-
}
151+
uv --directory client run main.py
134152
----
135153

136-
This configuration tells VS Code to connect to the server at `http://localhost:8000/mcp` using a HTTP connection.
154+
The client will connect to your server and display an interactive menu showing available tools:
137155

156+
[source,output,role=nocopy]
157+
.Console Output
158+
----
159+
============================================================
160+
🔧 Available Tools:
161+
============================================================
162+
163+
1. count_letters
164+
Count occurrences of a letter in the text
138165
139-
=== Step 6: Verify your implementation
166+
0. Exit
167+
============================================================
140168
169+
Select a tool, resource, or template (enter number):
170+
----
141171

142-
To test your server, open up the Chat window in **Agent** mode:
172+
Enter `1` to select the `count_letters` tool.
143173

144-
1. Open the Command Palette (`Cmd+Shift+P` or `Ctrl+Shift+P`)
145-
2. Execute the "Chat: Open Chat (Agent)" command
174+
The client will prompt you for the required parameters with type information:
146175

147-
Now try asking the following question:
176+
[source,output,role=nocopy]
177+
.Console Output
178+
----
179+
text (required)
180+
Type: string
181+
Enter value: strawberry
148182
149-
[copy]#How many times does the letter 'r' appear in the word 'strawberry'?#
183+
search (required)
184+
Type: string
185+
Enter value: r
186+
----
187+
188+
After entering the parameters, you'll see the result returned by the tool:
189+
190+
[source,output,role=nocopy]
191+
.Console Output
192+
----
193+
✨ Result:
194+
------------------------------------------------------------
195+
3
196+
------------------------------------------------------------
197+
----
150198

151-
The agent should discover the `count_letters` tool and prompt you to confirm the tool call.
152-
It should respond with the answer `3`.
199+
Try testing with different inputs to verify the tool works correctly. Press Enter to return to the menu, or `q` to quit.
153200

154201

155202
[TIP]
156-
.The agent didn't call the tool?
203+
.Other Testing Options
157204
====
158-
This is the joy of LLMs and tool calling.
159-
Depending on the underlying model, the agent may not behave as you expect.
160-
In this case, the model may feel confident in its own answer and not call the tool.
205+
**VS Code Agent Mode**: You can also test your MCP server directly in VS Code by configuring it in `.vscode/mcp.json` and using the Chat window in Agent mode. This allows you to interact with your tools conversationally.
161206
162-
Try switching to a different model, rephrasing the question, or explicitly mentioning the tool you want to use.
163-
====
207+
[%collapsible]
208+
.Configuring the server for VS Code Agent mode
209+
=====
210+
[source,json]
211+
.vscode/mcp.json
212+
----
213+
{
214+
"servers": {
215+
"strawberry": {
216+
"type": "http",
217+
"url": "http://localhost:8000/mcp"
218+
}
219+
}
220+
}
221+
----
222+
=====
164223
224+
**MCP Inspector**: For visual debugging, the link:https://github.com/modelcontextprotocol/inspector[MCP Inspector^] provides a web-based UI for exploring tools, resources, and prompts. Run it with `npx @modelcontextprotocol/inspector`.
225+
====
165226

166227

167228
== That's it!
168229

169-
You have just created your first MCP server!
170-
171-
The Chat window in VS Code is a useful way to test your server, but it isn't the most efficient way to test your MCP server.
172-
In the next lesson, you will learn about the MCP Inspector, which is a tool that allows you to inspect the MCP server and its tools.
230+
You have just created and tested your first MCP server!
173231

174232

175233
read::Mark as Completed[]
@@ -180,8 +238,9 @@ read::Mark as Completed[]
180238
In this challenge, you successfully built your first MCP server from scratch:
181239

182240
* **FastMCP setup** - Created a new MCP server using the FastMCP class with the MCP Python SDK
183-
* **Tool implementation** - Added a `count_letters` tool using the `@mcp.tool()` decorator to solve LLM counting limitations.
184-
* **Server installation** - Configured the server for VS Code using `uv run mcp install main.py`
185-
* **Agent mode testing** - Tested the server functionality through VS Code Agent mode with conversational queries
241+
* **Tool implementation** - Added a `count_letters` tool using the `@mcp.tool()` decorator to solve LLM counting limitations
242+
* **HTTP transport** - Configured the server to use streaming-HTTP transport for easy testing
243+
* **Interactive testing** - Tested the server with the Python client for immediate feedback
244+
186245

187-
In the next lesson, you will learn about context management for handling server lifecycle and resource management.
246+
In the next module, you will learn about context management for handling server lifecycle and resource management, and you'll start building tools that connect to Neo4j.

0 commit comments

Comments
 (0)