Skip to content

Commit 8d1dc72

Browse files
committed
refactor: update JSON code blocks with filenames in advanced tools and elicitation exercises
1 parent 147c03f commit 8d1dc72

File tree

10 files changed

+41
-21
lines changed

10 files changed

+41
-21
lines changed

exercises/01.advanced-tools/01.problem.annotations/README.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ To support this, each tool should include an `annotations` property that describ
4343
}
4444
```
4545

46-
📜 Please check [the table in the MCP docs](https://modelcontextprotocol.io/docs/concepts/tools#available-tool-annotations) for the default values and when each annotation is useful.
46+
📜 Please check [the MCP docs](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations) for the default values and when each annotation is useful.
4747

4848
The goal is to make tool behavior obvious to both users and the UI. The more clearly this is communicated, the more empowered and comfortable users will feel using the mcp server's advanced features.
4949

exercises/01.advanced-tools/02.problem.structured/README.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async (input) => {
2727

2828
Here's what a structured output response looks like:
2929

30-
```json nocopy
30+
```json filename="server-response.json" nocopy
3131
{
3232
"content": [
3333
{

exercises/01.advanced-tools/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Suppose we have a tool that generates a random fantasy character profile:
158158

159159
#### Request
160160

161-
```json
161+
```json filename="client-request.json" nocopy
162162
{
163163
"jsonrpc": "2.0",
164164
"id": 99,
@@ -174,7 +174,7 @@ Suppose we have a tool that generates a random fantasy character profile:
174174

175175
#### Response
176176

177-
```json
177+
```json filename="server-response.json" nocopy
178178
{
179179
"jsonrpc": "2.0",
180180
"id": 99,

exercises/02.elicitation/01.solution/README.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Elicite Confirmation
1+
# Elicit Confirmation
22

33
👨‍💼 Fantastic progress! We've just introduced a robust confirmation step for destructive actions, such as deleting a tag. Now, whenever a user initiates an action that could have significant consequences, the system pauses and asks for explicit confirmation using a structured elicitation prompt. This ensures that users are always in control and never accidentally lose important data.
44

exercises/02.elicitation/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Imagine an online pizza ordering system. After a user selects their pizza and to
5151
1. The user submits their pizza order.
5252
2. The server sends an `elicitation/create` request:
5353

54-
```json
54+
```json filename="server-request.json" nocopy
5555
{
5656
"jsonrpc": "2.0",
5757
"id": 1,
@@ -83,7 +83,7 @@ The client presents this to the user, who can:
8383

8484
Here's what the response from the client might look like:
8585

86-
```json
86+
```json filename="client-response.json" nocopy
8787
{
8888
"jsonrpc": "2.0",
8989
"id": 1,

exercises/03.sampling/01.problem.simple/README.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ if (!capabilities?.sampling) {
4141
// Proceed with sampling request here
4242
```
4343

44+
And here's an example of how to send a sampling request:
45+
46+
```ts
47+
const result = await agent.server.server.createMessage({
48+
// the system prompt is used to explain to the LLM it's purpose
49+
systemPrompt: '...',
50+
messages: [
51+
{
52+
role: 'user',
53+
content: {
54+
type: 'text',
55+
// the user message is the input to the LLM
56+
text: '...',
57+
},
58+
},
59+
],
60+
maxTokens: 100,
61+
})
62+
```
63+
4464
The `maxTokens` option references the max tokens the model should return.
4565

4666
<callout-warning>
@@ -60,7 +80,7 @@ To test this in the MCP inspector:
6080
- check the "Sampling" navigation tab and you should have a sampling request
6181
- at this point, YOU are the LLM. You can copy paste this into your response:
6282

63-
```json
83+
```json filename="example-sampling-client-response.json"
6484
{
6585
"model": "stub-model",
6686
"stopReason": "endTurn",

exercises/03.sampling/02.problem.advanced/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ for a new journal entry.
3030
4. Evaluate the response (make sure it's in the right format)
3131
5. Repeat in new chats until you're happy with the prompt/response
3232

33-
```json
33+
```json filename="example-user-message.json"
3434
{
3535
"entry": {
3636
"id": 6,
@@ -100,7 +100,7 @@ To test this in the MCP inspector:
100100
- check the "Sampling" navigation tab and you should have a sampling request
101101
- at this point, YOU are the LLM. You can copy paste this into your response:
102102

103-
```json
103+
```json filename="example-sampling-client-response.json"
104104
{
105105
"model": "stub-model",
106106
"stopReason": "endTurn",

exercises/03.sampling/README.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ sequenceDiagram
4848

4949
Here's a simple example of a sampling request and response using MCP:
5050

51-
```json
52-
// Request
51+
```json filename="server-request.json" nocopy
5352
{
5453
"jsonrpc": "2.0",
5554
"id": 1,
@@ -70,8 +69,7 @@ Here's a simple example of a sampling request and response using MCP:
7069
}
7170
```
7271

73-
```json
74-
// Response
72+
```json filename="client-response.json" nocopy
7573
{
7674
"jsonrpc": "2.0",
7775
"id": 1,

exercises/04.long-running-tasks/README.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ sequenceDiagram
3737

3838
**Client Request with Progress Token:**
3939

40-
```json
40+
```json filename="client-request.json" nocopy
4141
{
4242
"jsonrpc": "2.0",
4343
"id": 5,
44-
"method": "play_fetch",
44+
"method": "tools/call",
4545
"params": {
46+
"name": "play_fetch",
47+
"arguments": {},
4648
"_meta": {
4749
"progressToken": "abc123"
4850
}
@@ -52,7 +54,7 @@ sequenceDiagram
5254

5355
**Server Progress Notification:**
5456

55-
```json
57+
```json filename="server-progress-notification-request.json" nocopy
5658
{
5759
"jsonrpc": "2.0",
5860
"method": "notifications/progress",
@@ -67,7 +69,7 @@ sequenceDiagram
6769

6870
**Server Final Response:**
6971

70-
```json
72+
```json filename="server-response.json" nocopy
7173
{
7274
"jsonrpc": "2.0",
7375
"id": 5,
@@ -113,7 +115,7 @@ sequenceDiagram
113115

114116
**Client Cancellation Notification:**
115117

116-
```json
118+
```json filename="client-cancelled-notification-request.json" nocopy
117119
{
118120
"jsonrpc": "2.0",
119121
"method": "notifications/cancelled",

exercises/05.changes/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ While `list_changed` tells clients about changes in what resources are available
9898

9999
A client wants to stay updated on a specific space station module:
100100

101-
```json
101+
```json filename="client-request.json" nocopy
102102
{
103103
"jsonrpc": "2.0",
104104
"id": 1,
@@ -109,7 +109,7 @@ A client wants to stay updated on a specific space station module:
109109

110110
When the module's status changes (e.g., a new experiment starts, or the module is undocked), the server sends:
111111

112-
```json
112+
```json filename="server-response.json" nocopy
113113
{
114114
"jsonrpc": "2.0",
115115
"method": "notifications/resources/updated",

0 commit comments

Comments
 (0)