You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: asciidoc/courses/genai-mcp-build-custom-tools-python/course.adoc
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,6 @@ This course assumes that you have are familiar with the basics of Generative AI
20
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
21
If you are not familiar with uv, you should also link:https://docs.astral.sh/uv/[review the uv documentation].
22
22
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^].
24
23
25
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.
26
25
@@ -36,14 +35,13 @@ The course features hands-on challenges using link:https://github.com/settings/c
36
35
* How to create tools with context, logging, and structured outputs
37
36
* How to expose resources and prompts through your server
38
37
* How to implement pagination for large Neo4j datasets
39
-
* How to use the MCP Inspector to test and debug
40
38
* How to integrate MCP tools into development workflows
41
39
* Advanced features: Sampling and Completions (optional)
42
40
43
41
44
42
[.includes]
45
43
== This course includes
46
44
47
-
* [lessons]#16 lessons# across 3 modules (including setup)
45
+
* [lessons]#14 lessons# across 3 modules (including setup)
48
46
* [challenges]#7 hands-on challenges# with Neo4j
49
47
* [quizes]#Quiz questions# to check your understanding
Copy file name to clipboardExpand all lines: asciidoc/courses/genai-mcp-build-custom-tools-python/modules/1-getting-started/lessons/1-mcp-python-sdk/lesson.adoc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ In the link:/courses/genai-mcp-neo4j-tools/[Developing with Neo4j MCP Tools cour
6
6
7
7
In this course, you will learn how to build your own MCP servers with graph-backed tools and resources, creating a complete GraphRAG application.
8
8
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.
10
10
11
11
[TIP]
12
12
.Emerging standards
@@ -279,4 +279,4 @@ In this lesson, you learned the foundational concepts for building MCP servers w
279
279
* **Decorators** - Use `@mcp.tool()`, `@mcp.resource()`, and `@mcp.prompt()` to register features
280
280
* **Transport methods** - Run servers using `stdio` (default) or `http` for web deployments
281
281
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.
Copy file name to clipboardExpand all lines: asciidoc/courses/genai-mcp-build-custom-tools-python/modules/1-getting-started/lessons/2-setup/lesson.adoc
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,8 @@ The repository contains a `server/` directory where you will build your MCP serv
48
48
Here are the important directories:
49
49
50
50
* `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
52
53
* `.github/` - GitHub configuration including Codespace setup
53
54
54
55
@@ -61,10 +62,9 @@ We have created a Neo4j Sandbox instance for you to use during this course, load
61
62
To define the connection details as environment variables, create a `.env` file in the `server/` directory with the following values:
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.
95
94
====
96
95
@@ -101,13 +100,18 @@ To verify your setup, run the `test_environment.py` script.
101
100
102
101
[source,bash]
103
102
----
104
-
python server/test_environment.py
103
+
uv --directory client run test_environment.py
105
104
----
106
105
107
106
108
107
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.
Copy file name to clipboardExpand all lines: asciidoc/courses/genai-mcp-build-custom-tools-python/modules/1-getting-started/lessons/3c-create-first-server/lesson.adoc
@@ -22,10 +22,25 @@ You can open your existing codespaces at link:https://github.com/codespaces[gith
22
22
23
23
To complete this challenge, you will need to:
24
24
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
+
29
44
30
45
== Step-by-Step Instructions
31
46
@@ -34,6 +49,7 @@ To complete this challenge, you will need to:
34
49
First, create a new directory for your MCP server:
35
50
36
51
[source,bash]
52
+
.Create a new directory
37
53
----
38
54
mkdir strawberry
39
55
cd strawberry
@@ -44,6 +60,7 @@ cd strawberry
44
60
Initialize a new Python project using `uv`:
45
61
46
62
[source,bash]
63
+
.Initialize a new UV project
47
64
----
48
65
uv init
49
66
----
@@ -55,6 +72,7 @@ This will create a basic project structure with a `pyproject.toml` file and a `m
55
72
Add the MCP Python SDK to your project:
56
73
57
74
[source,bash]
75
+
.Add the MCP Python SDK to your project
58
76
----
59
77
uv add "mcp[cli]"
60
78
----
@@ -70,7 +88,7 @@ Open `main.py` in your editor and add the following code to create a simple MCP
70
88
from mcp.server.fastmcp import FastMCP
71
89
72
90
# Create an MCP server
73
-
mcp = FastMCP("Strawbrerry")
91
+
mcp = FastMCP("Strawberry")
74
92
75
93
@mcp.tool()
76
94
def count_letters(text: str, search: str) -> int:
@@ -88,24 +106,23 @@ if __name__ == "__main__":
88
106
This example uses the `streaming-http` transport method to run the server.
89
107
This differs from `stdio` in that the client uses HTTP to communicate with the server.
90
108
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.
92
110
For local development, using `stdio` is also a valid option.
93
111
94
112
link:https://modelcontextprotocol.io/specification/2025-06-18/basic/transports[Learn more about transports^]
95
113
====
96
114
97
-
=== Step 5: Configure your server in VS Code and test with Agent mode
115
+
=== Step 5: Run Your Server
98
116
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:
102
118
103
119
[source,bash]
120
+
.Run your MCP server
104
121
----
105
122
uv run main.py
106
123
----
107
124
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:
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
119
136
----
120
137
138
+
Your server is now running on port 8000 and ready to accept connections from MCP clients.
121
139
122
-
Once the server is running, modify the `.vscode/mcp.json` file to configure VS Code to use the server.
123
140
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
125
150
----
126
-
{
127
-
"servers": {
128
-
"strawberry": {
129
-
"type": "http",
130
-
"url": "http://localhost:8000/mcp"
131
-
}
132
-
}
133
-
}
151
+
uv --directory client run main.py
134
152
----
135
153
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:
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.
153
200
154
201
155
202
[TIP]
156
-
.The agent didn't call the tool?
203
+
.Other Testing Options
157
204
====
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.
161
206
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
+
=====
164
223
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
+
====
165
226
166
227
167
228
== That's it!
168
229
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!
173
231
174
232
175
233
read::Mark as Completed[]
@@ -180,8 +238,9 @@ read::Mark as Completed[]
180
238
In this challenge, you successfully built your first MCP server from scratch:
181
239
182
240
* **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
+
186
245
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