Skip to content

Commit 89f0a37

Browse files
committed
improve method name
1 parent 7b736f9 commit 89f0a37

File tree

21 files changed

+486
-537
lines changed

21 files changed

+486
-537
lines changed

exercises/01.advanced-tools/01.problem.annotations/src/tools.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function initializeTools(agent: EpicMeMCP) {
3636

3737
return {
3838
content: [
39-
createTextContent(
39+
createText(
4040
`Entry "${createdEntry.title}" created successfully with ID "${createdEntry.id}"`,
4141
),
4242
createEntryEmbeddedResource(createdEntry),
@@ -76,7 +76,7 @@ export async function initializeTools(agent: EpicMeMCP) {
7676
const entryLinks = entries.map(createEntryResourceLink)
7777
return {
7878
content: [
79-
createTextContent(`Found ${entries.length} entries.`),
79+
createText(`Found ${entries.length} entries.`),
8080
...entryLinks,
8181
],
8282
}
@@ -99,7 +99,7 @@ export async function initializeTools(agent: EpicMeMCP) {
9999
const updatedEntry = await agent.db.updateEntry(id, updates)
100100
return {
101101
content: [
102-
createTextContent(
102+
createText(
103103
`Entry "${updatedEntry.title}" (ID: ${id}) updated successfully`,
104104
),
105105
createEntryEmbeddedResource(updatedEntry),
@@ -124,7 +124,7 @@ export async function initializeTools(agent: EpicMeMCP) {
124124

125125
return {
126126
content: [
127-
createTextContent(
127+
createText(
128128
`Entry "${existingEntry.title}" (ID: ${id}) deleted successfully`,
129129
),
130130
createEntryEmbeddedResource(existingEntry),
@@ -146,7 +146,7 @@ export async function initializeTools(agent: EpicMeMCP) {
146146
const createdTag = await agent.db.createTag(tag)
147147
return {
148148
content: [
149-
createTextContent(
149+
createText(
150150
`Tag "${createdTag.name}" created successfully with ID "${createdTag.id}"`,
151151
),
152152
createTagEmbeddedResource(createdTag),
@@ -185,7 +185,7 @@ export async function initializeTools(agent: EpicMeMCP) {
185185
const tags = await agent.db.getTags()
186186
const tagLinks = tags.map(createTagResourceLink)
187187
return {
188-
content: [createTextContent(`Found ${tags.length} tags.`), ...tagLinks],
188+
content: [createText(`Found ${tags.length} tags.`), ...tagLinks],
189189
}
190190
},
191191
)
@@ -203,7 +203,7 @@ export async function initializeTools(agent: EpicMeMCP) {
203203
const updatedTag = await agent.db.updateTag(id, updates)
204204
return {
205205
content: [
206-
createTextContent(
206+
createText(
207207
`Tag "${updatedTag.name}" (ID: ${id}) updated successfully`,
208208
),
209209
createTagEmbeddedResource(updatedTag),
@@ -227,7 +227,7 @@ export async function initializeTools(agent: EpicMeMCP) {
227227
await agent.db.deleteTag(id)
228228
return {
229229
content: [
230-
createTextContent(
230+
createText(
231231
`Tag "${existingTag.name}" (ID: ${id}) deleted successfully`,
232232
),
233233
createTagEmbeddedResource(existingTag),
@@ -256,7 +256,7 @@ export async function initializeTools(agent: EpicMeMCP) {
256256
})
257257
return {
258258
content: [
259-
createTextContent(
259+
createText(
260260
`Tag "${tag.name}" (ID: ${entryTag.tagId}) added to entry "${entry.title}" (ID: ${entryTag.entryId}) successfully`,
261261
),
262262
createTagEmbeddedResource(tag),
@@ -306,7 +306,7 @@ export async function initializeTools(agent: EpicMeMCP) {
306306
})
307307
return {
308308
content: [
309-
createTextContent('Video created successfully'),
309+
createText('Video created successfully'),
310310
{
311311
type: 'resource_link',
312312
uri: videoUri,
@@ -320,7 +320,7 @@ export async function initializeTools(agent: EpicMeMCP) {
320320
)
321321
}
322322

323-
function createTextContent(text: unknown): CallToolResult['content'][number] {
323+
function createText(text: unknown): CallToolResult['content'][number] {
324324
if (typeof text === 'string') {
325325
return { type: 'text', text }
326326
} else {

exercises/01.advanced-tools/01.solution.annotations/src/tools.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function initializeTools(agent: EpicMeMCP) {
3838

3939
return {
4040
content: [
41-
createTextContent(
41+
createText(
4242
`Entry "${createdEntry.title}" created successfully with ID "${createdEntry.id}"`,
4343
),
4444
createEntryEmbeddedResource(createdEntry),
@@ -82,7 +82,7 @@ export async function initializeTools(agent: EpicMeMCP) {
8282
const entryLinks = entries.map(createEntryResourceLink)
8383
return {
8484
content: [
85-
createTextContent(`Found ${entries.length} entries.`),
85+
createText(`Found ${entries.length} entries.`),
8686
...entryLinks,
8787
],
8888
}
@@ -108,7 +108,7 @@ export async function initializeTools(agent: EpicMeMCP) {
108108
const updatedEntry = await agent.db.updateEntry(id, updates)
109109
return {
110110
content: [
111-
createTextContent(
111+
createText(
112112
`Entry "${updatedEntry.title}" (ID: ${id}) updated successfully`,
113113
),
114114
createEntryEmbeddedResource(updatedEntry),
@@ -135,7 +135,7 @@ export async function initializeTools(agent: EpicMeMCP) {
135135

136136
return {
137137
content: [
138-
createTextContent(
138+
createText(
139139
`Entry "${existingEntry.title}" (ID: ${id}) deleted successfully`,
140140
),
141141
createEntryEmbeddedResource(existingEntry),
@@ -159,7 +159,7 @@ export async function initializeTools(agent: EpicMeMCP) {
159159
const createdTag = await agent.db.createTag(tag)
160160
return {
161161
content: [
162-
createTextContent(
162+
createText(
163163
`Tag "${createdTag.name}" created successfully with ID "${createdTag.id}"`,
164164
),
165165
createTagEmbeddedResource(createdTag),
@@ -202,7 +202,7 @@ export async function initializeTools(agent: EpicMeMCP) {
202202
const tags = await agent.db.getTags()
203203
const tagLinks = tags.map(createTagResourceLink)
204204
return {
205-
content: [createTextContent(`Found ${tags.length} tags.`), ...tagLinks],
205+
content: [createText(`Found ${tags.length} tags.`), ...tagLinks],
206206
}
207207
},
208208
)
@@ -223,7 +223,7 @@ export async function initializeTools(agent: EpicMeMCP) {
223223
const updatedTag = await agent.db.updateTag(id, updates)
224224
return {
225225
content: [
226-
createTextContent(
226+
createText(
227227
`Tag "${updatedTag.name}" (ID: ${id}) updated successfully`,
228228
),
229229
createTagEmbeddedResource(updatedTag),
@@ -249,7 +249,7 @@ export async function initializeTools(agent: EpicMeMCP) {
249249
await agent.db.deleteTag(id)
250250
return {
251251
content: [
252-
createTextContent(
252+
createText(
253253
`Tag "${existingTag.name}" (ID: ${id}) deleted successfully`,
254254
),
255255
createTagEmbeddedResource(existingTag),
@@ -281,7 +281,7 @@ export async function initializeTools(agent: EpicMeMCP) {
281281
})
282282
return {
283283
content: [
284-
createTextContent(
284+
createText(
285285
`Tag "${tag.name}" (ID: ${entryTag.tagId}) added to entry "${entry.title}" (ID: ${entryTag.entryId}) successfully`,
286286
),
287287
createTagEmbeddedResource(tag),
@@ -333,7 +333,7 @@ export async function initializeTools(agent: EpicMeMCP) {
333333
})
334334
return {
335335
content: [
336-
createTextContent('Video created successfully'),
336+
createText('Video created successfully'),
337337
{
338338
type: 'resource_link',
339339
uri: videoUri,
@@ -347,7 +347,7 @@ export async function initializeTools(agent: EpicMeMCP) {
347347
)
348348
}
349349

350-
function createTextContent(text: unknown): CallToolResult['content'][number] {
350+
function createText(text: unknown): CallToolResult['content'][number] {
351351
if (typeof text === 'string') {
352352
return { type: 'text', text }
353353
} else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ async (input) => {
1717
return {
1818
structuredContent,
1919
content: [
20-
createTextContent(`Creature "${creature.name}" added to your stable!`),
20+
createText(`Creature "${creature.name}" added to your stable!`),
2121
createCreatureResourceLink(creature),
22-
createTextContent(structuredContent),
22+
createText(structuredContent),
2323
],
2424
}
2525
}

exercises/01.advanced-tools/02.problem.structured/src/tools.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ export async function initializeTools(agent: EpicMeMCP) {
4545
return {
4646
// 🐨 add structuredContent here
4747
content: [
48-
createTextContent(
48+
createText(
4949
`Entry "${createdEntry.title}" created successfully with ID "${createdEntry.id}"`,
5050
),
5151
// 🐨 reduce duplication by switching this to a resource link
5252
// 💰 createEntryResourceLink(createdEntry),
5353
createEntryEmbeddedResource(createdEntry),
5454

5555
// 🐨 add the structuredContent as a text block
56-
// 💰 createTextContent(structuredContent),
56+
// 💰 createText(structuredContent),
5757
],
5858
}
5959
},
@@ -104,7 +104,7 @@ export async function initializeTools(agent: EpicMeMCP) {
104104
return {
105105
// 🐨 add structuredContent here
106106
content: [
107-
createTextContent(`Found ${entries.length} entries.`),
107+
createText(`Found ${entries.length} entries.`),
108108
...entryLinks,
109109
// 🐨 add the structuredContent as a text block
110110
],
@@ -134,7 +134,7 @@ export async function initializeTools(agent: EpicMeMCP) {
134134
return {
135135
// 🐨 add structuredContent here
136136
content: [
137-
createTextContent(
137+
createText(
138138
`Entry "${updatedEntry.title}" (ID: ${id}) updated successfully`,
139139
),
140140
// 🐨 reduce duplication by switching this to a resource link
@@ -166,7 +166,7 @@ export async function initializeTools(agent: EpicMeMCP) {
166166
return {
167167
// 🐨 add structuredContent here
168168
content: [
169-
createTextContent(
169+
createText(
170170
`Entry "${existingEntry.title}" (ID: ${id}) deleted successfully`,
171171
),
172172
// 🐨 reduce duplication by switching this to a resource link
@@ -195,7 +195,7 @@ export async function initializeTools(agent: EpicMeMCP) {
195195
return {
196196
// 🐨 add structuredContent here
197197
content: [
198-
createTextContent(
198+
createText(
199199
`Tag "${createdTag.name}" created successfully with ID "${createdTag.id}"`,
200200
),
201201
// 🐨 reduce duplication by switching this to a resource link
@@ -225,7 +225,7 @@ export async function initializeTools(agent: EpicMeMCP) {
225225
return {
226226
// 🐨 add structuredContent here
227227
content: [
228-
createTextContent(tag),
228+
createText(tag),
229229
// 🐨 reduce duplication by switching this to a resource link
230230
createTagEmbeddedResource(tag),
231231
// 🐨 add the structuredContent as a text block
@@ -252,7 +252,7 @@ export async function initializeTools(agent: EpicMeMCP) {
252252
return {
253253
// 🐨 add structuredContent here
254254
content: [
255-
createTextContent(`Found ${tags.length} tags.`),
255+
createText(`Found ${tags.length} tags.`),
256256
...tagLinks,
257257
// 🐨 add the structuredContent as a text block
258258
],
@@ -279,7 +279,7 @@ export async function initializeTools(agent: EpicMeMCP) {
279279
return {
280280
// 🐨 add structuredContent here
281281
content: [
282-
createTextContent(
282+
createText(
283283
`Tag "${updatedTag.name}" (ID: ${id}) updated successfully`,
284284
),
285285
// 🐨 reduce duplication by switching this to a resource link
@@ -310,7 +310,7 @@ export async function initializeTools(agent: EpicMeMCP) {
310310
return {
311311
// 🐨 add structuredContent here
312312
content: [
313-
createTextContent(
313+
createText(
314314
`Tag "${existingTag.name}" (ID: ${id}) deleted successfully`,
315315
),
316316
// 🐨 reduce duplication by switching this to a resource link
@@ -347,7 +347,7 @@ export async function initializeTools(agent: EpicMeMCP) {
347347
return {
348348
// 🐨 add structuredContent here
349349
content: [
350-
createTextContent(
350+
createText(
351351
`Tag "${tag.name}" (ID: ${entryTag.tagId}) added to entry "${entry.title}" (ID: ${entryTag.entryId}) successfully`,
352352
),
353353
// 🐨 reduce duplication by switching this to a resource link
@@ -405,7 +405,7 @@ export async function initializeTools(agent: EpicMeMCP) {
405405
return {
406406
// 🐨 add structuredContent here
407407
content: [
408-
createTextContent('Video created successfully'),
408+
createText('Video created successfully'),
409409
// 🦉 keep the resource link here. Even though the structuredContent
410410
// has the URI, clients may not look for it and instead look for resource links
411411
{
@@ -422,7 +422,7 @@ export async function initializeTools(agent: EpicMeMCP) {
422422
)
423423
}
424424

425-
function createTextContent(text: unknown): CallToolResult['content'][number] {
425+
function createText(text: unknown): CallToolResult['content'][number] {
426426
if (typeof text === 'string') {
427427
return { type: 'text', text }
428428
} else {

0 commit comments

Comments
 (0)