Skip to content

Commit 37402a0

Browse files
committed
fix messages
1 parent fd3215a commit 37402a0

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

β€Žexercises/04.prompts/01.problem.prompts/src/index.test.tsβ€Ž

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,24 @@ test('Prompts List', async () => {
118118
) {
119119
console.error('🚨 Prompts capability not implemented!')
120120
console.error(
121-
'🚨 This exercise teaches you how to add prompts to your MCP server',
121+
"🚨 This exercise requires you to add support for MCP's prompt capability to your server.",
122122
)
123123
console.error('🚨 You need to:')
124-
console.error('🚨 1. Add "prompts" to your server capabilities')
124+
console.error('🚨 1. Add "prompts" to your server capabilities.')
125125
console.error(
126-
'🚨 2. Create an initializePrompts function in a prompts.ts file',
126+
'🚨 2. Create an initializePrompts function in prompts.ts.',
127127
)
128128
console.error(
129-
'🚨 3. Use server.registerPrompt() to register prompts',
129+
'🚨 3. Use server.registerPrompt() to register prompts (e.g., for suggesting tags).',
130130
)
131131
console.error(
132-
'🚨 4. Call initializePrompts() in your main init() method',
132+
'🚨 4. Call initializePrompts() in your main init() method.',
133133
)
134134
console.error(
135-
'🚨 5. Register prompts that can help users analyze their journal entries',
135+
'🚨 5. Implement prompt handlers that return meaningful, parameterized prompt messages.',
136136
)
137137
console.error(
138-
'🚨 In src/index.ts, add prompts capability and request handlers',
138+
'🚨 In src/index.ts, add prompts capability and request handlers.',
139139
)
140140
throw new Error(
141141
`🚨 Prompts capability not declared - add "prompts" to server capabilities and implement prompt handlers. ${error}`,
@@ -194,22 +194,24 @@ test('Prompt Get', async () => {
194194
) {
195195
console.error('🚨 Prompts capability not implemented!')
196196
console.error(
197-
'🚨 This exercise teaches you how to create and serve prompts via MCP',
197+
'🚨 This exercise requires you to create and serve prompts via MCP.',
198198
)
199199
console.error('🚨 You need to:')
200-
console.error('🚨 1. Add "prompts" to your server capabilities')
201-
console.error('🚨 2. Handle GetPromptRequestSchema requests')
200+
console.error('🚨 1. Add "prompts" to your server capabilities.')
202201
console.error(
203-
'🚨 3. Create prompt templates that help analyze journal entries',
202+
'🚨 2. Handle prompt requests by returning prompt messages.',
204203
)
205204
console.error(
206-
'🚨 4. Return prompt messages with proper role and content',
205+
'🚨 3. Create prompt templates that help analyze journal entries.',
207206
)
208207
console.error(
209-
'🚨 In src/index.ts, implement GetPromptRequestSchema handler to return formatted prompts',
208+
'🚨 4. Return prompt messages with proper role and content.',
209+
)
210+
console.error(
211+
'🚨 In src/index.ts, implement a prompt handler to return formatted prompts.',
210212
)
211213
throw new Error(
212-
`🚨 Prompt get functionality not implemented - add prompts capability and GetPromptRequestSchema handler. ${error}`,
214+
`🚨 Prompt get functionality not implemented - add prompts capability and a prompt handler. ${error}`,
213215
)
214216
}
215217
throw error

β€Žexercises/04.prompts/02.problem.optimized-prompt/src/index.test.tsβ€Ž

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,20 @@ test('Optimized Prompt with Embedded Resources', async () => {
214214
} catch (error) {
215215
console.error('🚨 Prompt optimization not properly implemented!')
216216
console.error(
217-
'🚨 This exercise teaches you how to optimize prompts by embedding resources',
218-
)
219-
console.error(
220-
'🚨 OPTIMIZATION CONCEPT: Instead of telling the LLM to call get_entry/list_tags,',
217+
'🚨 This exercise requires you to optimize prompts by embedding resource data directly in the prompt messages, instead of instructing the LLM to call get_entry or list_tags.',
221218
)
219+
console.error('🚨 You need to:')
222220
console.error(
223-
'🚨 embed the data directly in the prompt as resource content',
221+
'🚨 1. Fetch the entry and tag data in your prompt handler.',
224222
)
225-
console.error('🚨 You need to:')
226223
console.error(
227-
'🚨 1. Fetch the entry and tag data in your GetPromptRequestSchema handler',
224+
'🚨 2. Create multiple messages: one with instructions, others with embedded resource content (type: "resource", mimeType: "application/json").',
228225
)
229226
console.error(
230-
'🚨 2. Create multiple messages: text instructions + resource content',
227+
'🚨 3. DO NOT tell the LLM to call get_entry or list_tags - provide the data directly.',
231228
)
232-
console.error('🚨 3. Use content.type = "resource" with embedded data')
233229
console.error(
234-
'🚨 4. DO NOT tell LLM to call get_entry - provide the data directly',
230+
'🚨 4. Ensure at least one message is a resource, and that the resource contains valid JSON.',
235231
)
236232
console.error('🚨 This reduces LLM tool calls and improves performance!')
237233
throw new Error(

β€Žexercises/05.sampling/01.problem.simple/src/index.test.tsβ€Ž

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,23 @@ test('Sampling', async () => {
167167
) {
168168
console.error('🚨 Sampling capability not implemented!')
169169
console.error(
170-
'🚨 This exercise requires implementing sampling requests to interact with LLMs',
170+
'🚨 This exercise requires you to trigger a sampling (completion) request to the LLM when a new journal entry is created.',
171171
)
172+
console.error('🚨 You need to:')
172173
console.error(
173-
'🚨 You need to: 1) Connect the client to your server, 2) Use client.createMessage() after tool calls',
174+
'🚨 1. Implement a function that sends a sampling request using agent.server.server.createMessage after creating a journal entry.',
174175
)
175176
console.error(
176-
"🚨 The create_entry tool should trigger a sampling request to celebrate the user's accomplishment",
177+
'🚨 2. Use a simple system prompt (e.g., "You are a helpful assistant.") and a user message referencing the new entry\'s ID.',
177178
)
178179
console.error(
179-
'🚨 Check that your tool implementation includes a client.createMessage() call',
180+
'🚨 3. Set a reasonable maxTokens value for the response.',
181+
)
182+
console.error(
183+
"🚨 4. Log the result to the console so you can inspect the model's output.",
184+
)
185+
console.error(
186+
'🚨 Check that your tool implementation includes a call to agent.server.server.createMessage after creating an entry.',
180187
)
181188
const enhancedError = new Error(
182189
'🚨 Sampling capability required. Tool should send LLM requests after creating entries. ' +

β€Žexercises/05.sampling/02.problem.advanced/src/index.test.tsβ€Ž

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,29 +205,29 @@ test('Sampling', async () => {
205205
} catch (error) {
206206
console.error('🚨 Advanced sampling features not properly implemented!')
207207
console.error(
208-
'🚨 This exercise teaches you advanced sampling with structured data and proper configuration',
208+
'🚨 This exercise requires you to send a structured sampling request to the LLM with the new entry, its current tags, and all existing tags, as JSON (application/json).',
209209
)
210210
console.error('🚨 You need to:')
211211
console.error(
212-
'🚨 1. Increase maxTokens to a reasonable value (e.g., 150) for longer responses',
212+
'🚨 1. Increase maxTokens to a reasonable value (e.g., 100+) for longer responses.',
213213
)
214214
console.error(
215-
'🚨 2. Create a meaningful systemPrompt with examples of expected output format',
215+
'🚨 2. Create a meaningful systemPrompt that includes examples of the expected output format (array of tag objects, with examples for existing and new tags).',
216216
)
217217
console.error(
218-
'🚨 3. Structure the user message as JSON with mimeType: "application/json"',
218+
'🚨 3. Structure the user message as JSON with mimeType: "application/json".',
219219
)
220220
console.error(
221-
'🚨 4. Include both entry data AND existingTags context in the JSON',
221+
'🚨 4. Include both entry data AND existingTags context in the JSON (e.g., { entry: {...}, existingTags: [...] }).',
222222
)
223223
console.error(
224-
'🚨 5. Use structured data format: { entry: {...}, existingTags: [...] }',
224+
'🚨 5. Test your prompt in an LLM playground and refine as needed.',
225225
)
226226
console.error(
227-
'🚨 EXAMPLE: systemPrompt should include examples of expected tag suggestions',
227+
'🚨 EXAMPLE: systemPrompt should include examples of expected tag suggestions.',
228228
)
229229
console.error(
230-
'🚨 EXAMPLE: user message should be structured JSON, not plain text',
230+
'🚨 EXAMPLE: user message should be structured JSON, not plain text.',
231231
)
232232

233233
const params = request.params

0 commit comments

Comments
Β (0)