Skip to content

Commit e4f48a7

Browse files
committed
progress and node version
1 parent e36a465 commit e4f48a7

File tree

163 files changed

+8573
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+8573
-307
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ speed on some of the tools and concepts we'll be covering:
4848
## System Requirements
4949

5050
- [git][git] v2.18 or greater
51-
- [NodeJS][node] v18 or greater
52-
- [npm][npm] v8 or greater
51+
- [NodeJS][node] v22.5.0 or greater
52+
- [npm][npm] v8.16.0 or greater
5353

5454
All of these must be available in your `PATH`. To verify things are set up
5555
properly, you can run this:

exercises/01.ping/01.problem/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// 🐨 create a new McpServer
66
// - it should have a name of 'EpicMe' and a version of '1.0.0'
7-
// - it should have instructions for the LLM to know what this server can be used to do
7+
// - it should have instructions for the LLM to know what this server can be used to do (we'll start out by saying it can solve math problems)
88

99
async function main() {
1010
// 🐨 create a new StdioServerTransport

exercises/01.ping/01.solution/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ const server = new McpServer(
77
version: '1.0.0',
88
},
99
{
10-
instructions: `
11-
EpicMe is a journaling app that allows users to write about and review their experiences, thoughts, and reflections.
12-
13-
These tools are the user's window into their journal. With these tools and your help, they can create, read, and manage their journal entries and associated tags.
14-
15-
You can also help users add tags to their entries and get all tags for an entry.
16-
`.trim(),
10+
instructions: 'This lets you solve math problems.',
1711
},
1812
)
1913

exercises/02.tools/01.problem.simple/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ const server = new McpServer(
88
},
99
{
1010
// 🐨 add a capabilities object with a tools property that is an empty object
11-
instructions: `
12-
EpicMe is a journaling app that allows users to write about and review their experiences, thoughts, and reflections.
13-
14-
These tools are the user's window into their journal. With these tools and your help, they can create, read, and manage their journal entries and associated tags.
15-
16-
You can also help users add tags to their entries and get all tags for an entry.
17-
`.trim(),
11+
instructions: 'This lets you solve math problems.',
1812
},
1913
)
2014

exercises/02.tools/02.problem.args/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ server.tool(
1919
// 🐨 update the description to indicate this adds any two numbers
2020
'Add one and two',
2121
// 🐨 add an object with a firstNumber and secondNumber property
22-
// These should be zod schemas
22+
// 📜 These should be zod schemas https://zod.dev/
2323
async () => {
2424
// 🐨 accept an object parameter with a firstNumber and secondNumber property
2525
return {

exercises/03.advanced-tools/01.problem.db/src/db/schema.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,50 @@ export const entryTagSchema = z.object({
5656
updatedAt: timestampSchema,
5757
})
5858

59+
export const createEntryInputSchema = {
60+
title: z.string().describe('The title of the entry'),
61+
content: z.string().describe('The content of the entry'),
62+
mood: z
63+
.string()
64+
.optional()
65+
.describe(
66+
'The mood of the entry (for example: "happy", "sad", "anxious", "excited")',
67+
),
68+
location: z
69+
.string()
70+
.optional()
71+
.describe(
72+
'The location of the entry (for example: "home", "work", "school", "park")',
73+
),
74+
weather: z
75+
.string()
76+
.optional()
77+
.describe(
78+
'The weather of the entry (for example: "sunny", "cloudy", "rainy", "snowy")',
79+
),
80+
isPrivate: z
81+
.number()
82+
.optional()
83+
.default(1)
84+
.describe('Whether the entry is private (1 for private, 0 for public)'),
85+
isFavorite: z
86+
.number()
87+
.optional()
88+
.default(0)
89+
.describe(
90+
'Whether the entry is a favorite (1 for favorite, 0 for not favorite)',
91+
),
92+
tags: z
93+
.array(z.number())
94+
.optional()
95+
.describe('The IDs of the tags to add to the entry'),
96+
}
97+
98+
export const createTagInputSchema = {
99+
name: z.string().describe('The name of the tag'),
100+
description: z.string().optional().describe('The description of the tag'),
101+
}
102+
59103
export type Entry = z.infer<typeof entrySchema>
60104
export type NewEntry = z.infer<typeof newEntrySchema>
61105
export type Tag = z.infer<typeof tagSchema>

exercises/03.advanced-tools/01.solution.db/src/db/schema.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,50 @@ export const entryTagSchema = z.object({
5656
updatedAt: timestampSchema,
5757
})
5858

59+
export const createEntryInputSchema = {
60+
title: z.string().describe('The title of the entry'),
61+
content: z.string().describe('The content of the entry'),
62+
mood: z
63+
.string()
64+
.optional()
65+
.describe(
66+
'The mood of the entry (for example: "happy", "sad", "anxious", "excited")',
67+
),
68+
location: z
69+
.string()
70+
.optional()
71+
.describe(
72+
'The location of the entry (for example: "home", "work", "school", "park")',
73+
),
74+
weather: z
75+
.string()
76+
.optional()
77+
.describe(
78+
'The weather of the entry (for example: "sunny", "cloudy", "rainy", "snowy")',
79+
),
80+
isPrivate: z
81+
.number()
82+
.optional()
83+
.default(1)
84+
.describe('Whether the entry is private (1 for private, 0 for public)'),
85+
isFavorite: z
86+
.number()
87+
.optional()
88+
.default(0)
89+
.describe(
90+
'Whether the entry is a favorite (1 for favorite, 0 for not favorite)',
91+
),
92+
tags: z
93+
.array(z.number())
94+
.optional()
95+
.describe('The IDs of the tags to add to the entry'),
96+
}
97+
98+
export const createTagInputSchema = {
99+
name: z.string().describe('The name of the tag'),
100+
description: z.string().optional().describe('The description of the tag'),
101+
}
102+
59103
export type Entry = z.infer<typeof entrySchema>
60104
export type NewEntry = z.infer<typeof newEntrySchema>
61105
export type Tag = z.infer<typeof tagSchema>

exercises/03.advanced-tools/02.problem.organization/src/db/schema.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,50 @@ export const entryTagSchema = z.object({
5656
updatedAt: timestampSchema,
5757
})
5858

59+
export const createEntryInputSchema = {
60+
title: z.string().describe('The title of the entry'),
61+
content: z.string().describe('The content of the entry'),
62+
mood: z
63+
.string()
64+
.optional()
65+
.describe(
66+
'The mood of the entry (for example: "happy", "sad", "anxious", "excited")',
67+
),
68+
location: z
69+
.string()
70+
.optional()
71+
.describe(
72+
'The location of the entry (for example: "home", "work", "school", "park")',
73+
),
74+
weather: z
75+
.string()
76+
.optional()
77+
.describe(
78+
'The weather of the entry (for example: "sunny", "cloudy", "rainy", "snowy")',
79+
),
80+
isPrivate: z
81+
.number()
82+
.optional()
83+
.default(1)
84+
.describe('Whether the entry is private (1 for private, 0 for public)'),
85+
isFavorite: z
86+
.number()
87+
.optional()
88+
.default(0)
89+
.describe(
90+
'Whether the entry is a favorite (1 for favorite, 0 for not favorite)',
91+
),
92+
tags: z
93+
.array(z.number())
94+
.optional()
95+
.describe('The IDs of the tags to add to the entry'),
96+
}
97+
98+
export const createTagInputSchema = {
99+
name: z.string().describe('The name of the tag'),
100+
description: z.string().optional().describe('The description of the tag'),
101+
}
102+
59103
export type Entry = z.infer<typeof entrySchema>
60104
export type NewEntry = z.infer<typeof newEntrySchema>
61105
export type Tag = z.infer<typeof tagSchema>

exercises/03.advanced-tools/02.problem.organization/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
22
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
33
import { z } from 'zod'
44
import { DB } from './db/index.ts'
5+
// 🐨 Make tools.ts and you'll export a function called initializeTools:
6+
// import { initializeTools } from './tools.ts'
57

68
const db = DB.getInstance('./db.sqlite')
79

@@ -24,6 +26,7 @@ You can also help users add tags to their entries and get all tags for an entry.
2426
},
2527
)
2628

29+
// 🐨 move this tool to a function called `initializeTools` in a separate file ./tools.ts
2730
server.tool(
2831
'create_tag',
2932
'Create a new tag',
@@ -43,6 +46,7 @@ server.tool(
4346
}
4447
},
4548
)
49+
// 🐨 call initializeTools with the server and db
4650

4751
async function main() {
4852
const transport = new StdioServerTransport()

exercises/03.advanced-tools/02.solution.organization/src/db/schema.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,50 @@ export const entryTagSchema = z.object({
5656
updatedAt: timestampSchema,
5757
})
5858

59+
export const createEntryInputSchema = {
60+
title: z.string().describe('The title of the entry'),
61+
content: z.string().describe('The content of the entry'),
62+
mood: z
63+
.string()
64+
.optional()
65+
.describe(
66+
'The mood of the entry (for example: "happy", "sad", "anxious", "excited")',
67+
),
68+
location: z
69+
.string()
70+
.optional()
71+
.describe(
72+
'The location of the entry (for example: "home", "work", "school", "park")',
73+
),
74+
weather: z
75+
.string()
76+
.optional()
77+
.describe(
78+
'The weather of the entry (for example: "sunny", "cloudy", "rainy", "snowy")',
79+
),
80+
isPrivate: z
81+
.number()
82+
.optional()
83+
.default(1)
84+
.describe('Whether the entry is private (1 for private, 0 for public)'),
85+
isFavorite: z
86+
.number()
87+
.optional()
88+
.default(0)
89+
.describe(
90+
'Whether the entry is a favorite (1 for favorite, 0 for not favorite)',
91+
),
92+
tags: z
93+
.array(z.number())
94+
.optional()
95+
.describe('The IDs of the tags to add to the entry'),
96+
}
97+
98+
export const createTagInputSchema = {
99+
name: z.string().describe('The name of the tag'),
100+
description: z.string().optional().describe('The description of the tag'),
101+
}
102+
59103
export type Entry = z.infer<typeof entrySchema>
60104
export type NewEntry = z.infer<typeof newEntrySchema>
61105
export type Tag = z.infer<typeof tagSchema>

exercises/03.advanced-tools/02.solution.organization/src/index.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,34 @@
11
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
22
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
3-
import { DB } from './db'
3+
import { DB } from './db/index.ts'
44
import { initializeTools } from './tools.ts'
55

6-
export class EpicMeMCP {
7-
db: DB
8-
server = new McpServer(
9-
{
10-
name: 'EpicMe',
11-
version: '1.0.0',
6+
const db = DB.getInstance('./db.sqlite')
7+
8+
const server = new McpServer(
9+
{
10+
name: 'EpicMe',
11+
version: '1.0.0',
12+
},
13+
{
14+
capabilities: {
15+
tools: {},
1216
},
13-
{
14-
capabilities: {
15-
tools: {},
16-
},
17-
instructions: `
17+
instructions: `
1818
EpicMe is a journaling app that allows users to write about and review their experiences, thoughts, and reflections.
1919
2020
These tools are the user's window into their journal. With these tools and your help, they can create, read, and manage their journal entries and associated tags.
2121
2222
You can also help users add tags to their entries and get all tags for an entry.
23-
`.trim(),
24-
},
25-
)
23+
`.trim(),
24+
},
25+
)
2626

27-
constructor(path: string) {
28-
this.db = DB.getInstance(path)
29-
}
30-
async init() {
31-
await initializeTools(this)
32-
}
33-
}
27+
await initializeTools(server, db)
3428

3529
async function main() {
36-
const agent = new EpicMeMCP('./db.sqlite')
37-
await agent.init()
3830
const transport = new StdioServerTransport()
39-
await agent.server.connect(transport)
31+
await server.connect(transport)
4032
console.error('EpicMe MCP Server running on stdio')
4133
}
4234

exercises/03.advanced-tools/02.solution.organization/src/tools.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
12
import { z } from 'zod'
2-
import { type EpicMeMCP } from './index.ts'
3+
import { type DB } from './db/index.ts'
34

4-
export async function initializeTools(agent: EpicMeMCP) {
5-
agent.server.tool(
5+
export async function initializeTools(server: McpServer, db: DB) {
6+
server.tool(
67
'create_tag',
78
'Create a new tag',
89
{
910
name: z.string().describe('The name of the tag'),
1011
description: z.string().optional().describe('The description of the tag'),
1112
},
1213
async (tag) => {
13-
const createdTag = await agent.db.createTag(tag)
14+
const createdTag = await db.createTag(tag)
1415
return {
1516
content: [
1617
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Class

exercises/03.advanced-tools/03.problem.errors/package.json renamed to exercises/03.advanced-tools/03.problem.class/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "exercises_03.advanced-tools_03.problem.errors",
2+
"name": "exercises_03.advanced-tools_03.problem.class",
33
"private": true,
44
"type": "module",
55
"scripts": {

0 commit comments

Comments
 (0)