Skip to content

Commit d542f9a

Browse files
committed
refactor: standardize JSON code block filenames across multiple exercises
1 parent 432a054 commit d542f9a

File tree

8 files changed

+44
-33
lines changed

8 files changed

+44
-33
lines changed

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 filename="server-response.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 filename="client-request.json" nocopy
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 filename="server-response.json" nocopy
177+
```json filename=server-response.json nocopy
178178
{
179179
"jsonrpc": "2.0",
180180
"id": 99,

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 filename="server-request.json" nocopy
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 filename="client-response.json" nocopy
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ To test this in the MCP inspector:
8080
- check the "Sampling" navigation tab and you should have a sampling request
8181
- at this point, YOU are the LLM. You can copy paste this into your response:
8282

83-
```json filename="example-sampling-client-response.json"
83+
```json filename=example-sampling-client-response.json
8484
{
8585
"model": "stub-model",
8686
"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 filename="example-user-message.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 filename="example-sampling-client-response.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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ sequenceDiagram
4848

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

51-
```json filename="server-request.json" nocopy
51+
```json filename=server-request.json nocopy
5252
{
5353
"jsonrpc": "2.0",
5454
"id": 1,
@@ -69,7 +69,7 @@ Here's a simple example of a sampling request and response using MCP:
6969
}
7070
```
7171

72-
```json filename="client-response.json" nocopy
72+
```json filename=client-response.json nocopy
7373
{
7474
"jsonrpc": "2.0",
7575
"id": 1,

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

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

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

40-
```json filename="client-request.json" nocopy
40+
```json filename=client-request.json nocopy
4141
{
4242
"jsonrpc": "2.0",
4343
"id": 5,
@@ -54,7 +54,7 @@ sequenceDiagram
5454

5555
**Server Progress Notification:**
5656

57-
```json filename="server-progress-notification-request.json" nocopy
57+
```json filename=server-progress-notification-request.json nocopy
5858
{
5959
"jsonrpc": "2.0",
6060
"method": "notifications/progress",
@@ -69,7 +69,7 @@ sequenceDiagram
6969

7070
**Server Final Response:**
7171

72-
```json filename="server-response.json" nocopy
72+
```json filename=server-response.json nocopy
7373
{
7474
"jsonrpc": "2.0",
7575
"id": 5,
@@ -115,7 +115,7 @@ sequenceDiagram
115115

116116
**Client Cancellation Notification:**
117117

118-
```json filename="client-cancelled-notification-request.json" nocopy
118+
```json filename=client-cancelled-notification-request.json nocopy
119119
{
120120
"jsonrpc": "2.0",
121121
"method": "notifications/cancelled",

exercises/05.changes/README.mdx

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ if (freeDockingPorts.length > 0 && !dockModuleTool.enabled) {
4646

4747
The TypeScript SDK automatically sends `list_changed` notifications when tools are enabled or disabled. To avoid over-sending notifications, you should check whether the tool is already enabled or disabled before enabling or disabling it.
4848

49-
<callout-info>
50-
[In the
51-
future](https://github.com/modelcontextprotocol/typescript-sdk/pull/746),
52-
`list_changed` will be batched to avoid sending too many notifications.
53-
</callout-info>
49+
#### Example: Resource List Change Notification
50+
51+
When new experiment logs become available in the space station's research database:
52+
53+
```json filename=server-notification.json nocopy
54+
{
55+
"jsonrpc": "2.0",
56+
"method": "notifications/resources/list_changed"
57+
}
58+
```
59+
60+
This tells the client that the available resources have changed, prompting it to refresh its resource list and discover new experiment logs.
5461

5562
## 2. Resource List Change (Templates and Expansions)
5663

@@ -81,7 +88,7 @@ ingredientsResource.enable() // or disable()
8188

8289
Resources in MCP can be either static (a single file, a database record) or dynamic via **resource templates** (e.g., a directory of files, a database table, or even a set of modules on a space station 🚀). Resource templates allow the server to expose a pattern or collection of resources that can change over time.
8390

84-
A `notifications/resources/list_changed` notification is sent when:
91+
A `notifications/resources/list_changed` notification (like the one in the example above) is sent when:
8592

8693
- A new resource template is enabled/disabled
8794
- The set of expansions for a template changes (e.g., a new module docks, a new experiment log appears, or a file is added to a directory)
@@ -98,7 +105,7 @@ While `list_changed` tells clients about changes in what resources are available
98105

99106
A client wants to stay updated on a specific space station module:
100107

101-
```json filename="client-request.json" nocopy
108+
```json filename=client-request.json nocopy
102109
{
103110
"jsonrpc": "2.0",
104111
"id": 1,
@@ -109,7 +116,7 @@ A client wants to stay updated on a specific space station module:
109116

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

112-
```json filename="server-response.json" nocopy
119+
```json filename=server-notification-request.json nocopy
113120
{
114121
"jsonrpc": "2.0",
115122
"method": "notifications/resources/updated",
@@ -135,36 +142,40 @@ This all might work a little bit like this:
135142
```mermaid
136143
sequenceDiagram
137144
participant User
138-
participant HostApp
145+
participant App
139146
participant Client
140147
participant Server
141148
142-
User->>HostApp: Start application
143-
HostApp->>Client: Initialize client
149+
User->>App: Start application
150+
App->>Client: Initialize client
144151
Client->>Server: Initialization request
145152
Server-->>Client: Capabilities response
146153
%% ---
147154
Note over User,Server: (Later, when things change...)
148155
Server-->>Client: notifications/tools/list_changed
149156
Server-->>Client: notifications/resources/list_changed
150157
Server-->>Client: notifications/prompts/list_changed
151-
Client-->>HostApp: Forward list_changed notification
152-
HostApp->>Client: Fetch updated definitions
158+
Client-->>App: Forward list_changed notification
159+
App->>Client: Fetch updated definitions
153160
Client->>Server: Fetch updated definitions
154161
Server-->>Client: Updated definitions
155-
Client-->>HostApp: Forward updated definitions
156-
HostApp->>User: Update UI
162+
Client-->>App: Forward updated definitions
163+
App->>User: Update UI
157164
%% ---
158165
Note over User,Server: (Subscription flow)
159-
HostApp->>Client: Subscribe to resource
166+
App->>Client: Subscribe to resource
160167
Client->>Server: Subscribe to resource
161168
Server-->>Client: Subscription confirmed
162-
Client-->>HostApp: Subscription confirmed
169+
Client-->>App: Subscription confirmed
163170
%% ---
164171
Note over User,Server: (Later, when resource changes...)
165172
Server-->>Client: notifications/resources/updated
166-
Client-->>HostApp: Forward resource update
167-
HostApp->>User: Update UI
173+
Client-->>App: Forward resource update
174+
App->>Client: Request updated resource
175+
Client->>Server: resources/read
176+
Server-->>Client: Return updated resource
177+
Client-->>App: Forward resource data
178+
App->>User: Update UI with resource data
168179
```
169180

170181
## References

0 commit comments

Comments
 (0)