Skip to content

Commit 9843f72

Browse files
committed
yay
1 parent 1c475a1 commit 9843f72

File tree

48 files changed

+241
-612
lines changed

Some content is hidden

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

48 files changed

+241
-612
lines changed

exercises/01.discovery/01.problem.cors/src/index.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { type DBClient } from '@epic-web/epicme-db-client'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
3-
import {
4-
SetLevelRequestSchema,
5-
type LoggingLevel,
6-
} from '@modelcontextprotocol/sdk/types.js'
73
import { McpAgent } from 'agents/mcp'
84
import { getClient } from './client.ts'
95
import { initializePrompts } from './prompts.ts'
@@ -12,11 +8,8 @@ import { initializeTools } from './tools.ts'
128
// 💰 you'll need this:
139
// import { withCors } from './utils.ts'
1410

15-
type State = { loggingLevel: LoggingLevel }
16-
17-
export class EpicMeMCP extends McpAgent<Env, State> {
11+
export class EpicMeMCP extends McpAgent<Env> {
1812
db!: DBClient
19-
initialState: State = { loggingLevel: 'info' }
2013
server = new McpServer(
2114
{
2215
name: 'epicme',
@@ -43,13 +36,6 @@ You can also help users add tags to their entries and get all tags for an entry.
4336

4437
async init() {
4538
this.db = getClient()
46-
this.server.server.setRequestHandler(
47-
SetLevelRequestSchema,
48-
async (request) => {
49-
this.setState({ ...this.state, loggingLevel: request.params.level })
50-
return {}
51-
},
52-
)
5339
await initializeTools(this)
5440
await initializeResources(this)
5541
await initializePrompts(this)

exercises/01.discovery/01.problem.cors/src/sampling.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,15 @@ If you have some suggestions, respond with an array of tag objects. Existing tag
8585
.map((id) => allTags.find((t) => t.id === id))
8686
.filter(Boolean)
8787

88-
if (['debug', 'info'].includes(agent.state.loggingLevel)) {
89-
void agent.server.server.sendLoggingMessage({
90-
level: 'info',
91-
logger: 'tag-generator',
92-
data: {
93-
message: 'Added tags to entry',
94-
addedTags,
95-
entry: updatedEntry,
96-
},
97-
})
98-
}
88+
void agent.server.server.sendLoggingMessage({
89+
level: 'info',
90+
logger: 'tag-generator',
91+
data: {
92+
message: 'Added tags to entry',
93+
addedTags,
94+
entry: updatedEntry,
95+
},
96+
})
9997
}
10098

10199
const existingTagSchema = z.object({ id: z.number() })

exercises/01.discovery/01.solution.cors/src/index.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
import { type DBClient } from '@epic-web/epicme-db-client'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
3-
import {
4-
SetLevelRequestSchema,
5-
type LoggingLevel,
6-
} from '@modelcontextprotocol/sdk/types.js'
73
import { McpAgent } from 'agents/mcp'
84
import { getClient } from './client.ts'
95
import { initializePrompts } from './prompts.ts'
106
import { initializeResources } from './resources.ts'
117
import { initializeTools } from './tools.ts'
128
import { withCors } from './utils.ts'
139

14-
type State = { loggingLevel: LoggingLevel }
15-
16-
export class EpicMeMCP extends McpAgent<Env, State> {
10+
export class EpicMeMCP extends McpAgent<Env> {
1711
db!: DBClient
18-
initialState: State = { loggingLevel: 'info' }
1912
server = new McpServer(
2013
{
2114
name: 'epicme',
@@ -42,13 +35,6 @@ You can also help users add tags to their entries and get all tags for an entry.
4235

4336
async init() {
4437
this.db = getClient()
45-
this.server.server.setRequestHandler(
46-
SetLevelRequestSchema,
47-
async (request) => {
48-
this.setState({ ...this.state, loggingLevel: request.params.level })
49-
return {}
50-
},
51-
)
5238
await initializeTools(this)
5339
await initializeResources(this)
5440
await initializePrompts(this)

exercises/01.discovery/01.solution.cors/src/sampling.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,15 @@ If you have some suggestions, respond with an array of tag objects. Existing tag
8585
.map((id) => allTags.find((t) => t.id === id))
8686
.filter(Boolean)
8787

88-
if (['debug', 'info'].includes(agent.state.loggingLevel)) {
89-
void agent.server.server.sendLoggingMessage({
90-
level: 'info',
91-
logger: 'tag-generator',
92-
data: {
93-
message: 'Added tags to entry',
94-
addedTags,
95-
entry: updatedEntry,
96-
},
97-
})
98-
}
88+
void agent.server.server.sendLoggingMessage({
89+
level: 'info',
90+
logger: 'tag-generator',
91+
data: {
92+
message: 'Added tags to entry',
93+
addedTags,
94+
entry: updatedEntry,
95+
},
96+
})
9997
}
10098

10199
const existingTagSchema = z.object({ id: z.number() })

exercises/01.discovery/02.problem.as/src/index.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { type DBClient } from '@epic-web/epicme-db-client'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
3-
import {
4-
SetLevelRequestSchema,
5-
type LoggingLevel,
6-
} from '@modelcontextprotocol/sdk/types.js'
73
import { McpAgent } from 'agents/mcp'
84
// 💰 you'll need this:
95
// import { handleOAuthAuthorizationServerRequest } from './auth.ts'
@@ -13,11 +9,8 @@ import { initializeResources } from './resources.ts'
139
import { initializeTools } from './tools.ts'
1410
import { withCors } from './utils.ts'
1511

16-
type State = { loggingLevel: LoggingLevel }
17-
18-
export class EpicMeMCP extends McpAgent<Env, State> {
12+
export class EpicMeMCP extends McpAgent<Env> {
1913
db!: DBClient
20-
initialState: State = { loggingLevel: 'info' }
2114
server = new McpServer(
2215
{
2316
name: 'epicme',
@@ -44,13 +37,6 @@ You can also help users add tags to their entries and get all tags for an entry.
4437

4538
async init() {
4639
this.db = getClient()
47-
this.server.server.setRequestHandler(
48-
SetLevelRequestSchema,
49-
async (request) => {
50-
this.setState({ ...this.state, loggingLevel: request.params.level })
51-
return {}
52-
},
53-
)
5440
await initializeTools(this)
5541
await initializeResources(this)
5642
await initializePrompts(this)

exercises/01.discovery/02.problem.as/src/sampling.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,15 @@ If you have some suggestions, respond with an array of tag objects. Existing tag
8585
.map((id) => allTags.find((t) => t.id === id))
8686
.filter(Boolean)
8787

88-
if (['debug', 'info'].includes(agent.state.loggingLevel)) {
89-
void agent.server.server.sendLoggingMessage({
90-
level: 'info',
91-
logger: 'tag-generator',
92-
data: {
93-
message: 'Added tags to entry',
94-
addedTags,
95-
entry: updatedEntry,
96-
},
97-
})
98-
}
88+
void agent.server.server.sendLoggingMessage({
89+
level: 'info',
90+
logger: 'tag-generator',
91+
data: {
92+
message: 'Added tags to entry',
93+
addedTags,
94+
entry: updatedEntry,
95+
},
96+
})
9997
}
10098

10199
const existingTagSchema = z.object({ id: z.number() })

exercises/01.discovery/02.solution.as/src/index.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { type DBClient } from '@epic-web/epicme-db-client'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
3-
import {
4-
SetLevelRequestSchema,
5-
type LoggingLevel,
6-
} from '@modelcontextprotocol/sdk/types.js'
73
import { McpAgent } from 'agents/mcp'
84
import { handleOAuthAuthorizationServerRequest } from './auth.ts'
95
import { getClient } from './client.ts'
@@ -12,11 +8,8 @@ import { initializeResources } from './resources.ts'
128
import { initializeTools } from './tools.ts'
139
import { withCors } from './utils.ts'
1410

15-
type State = { loggingLevel: LoggingLevel }
16-
17-
export class EpicMeMCP extends McpAgent<Env, State> {
11+
export class EpicMeMCP extends McpAgent<Env> {
1812
db!: DBClient
19-
initialState: State = { loggingLevel: 'info' }
2013
server = new McpServer(
2114
{
2215
name: 'epicme',
@@ -43,13 +36,6 @@ You can also help users add tags to their entries and get all tags for an entry.
4336

4437
async init() {
4538
this.db = getClient()
46-
this.server.server.setRequestHandler(
47-
SetLevelRequestSchema,
48-
async (request) => {
49-
this.setState({ ...this.state, loggingLevel: request.params.level })
50-
return {}
51-
},
52-
)
5339
await initializeTools(this)
5440
await initializeResources(this)
5541
await initializePrompts(this)

exercises/01.discovery/02.solution.as/src/sampling.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,15 @@ If you have some suggestions, respond with an array of tag objects. Existing tag
8585
.map((id) => allTags.find((t) => t.id === id))
8686
.filter(Boolean)
8787

88-
if (['debug', 'info'].includes(agent.state.loggingLevel)) {
89-
void agent.server.server.sendLoggingMessage({
90-
level: 'info',
91-
logger: 'tag-generator',
92-
data: {
93-
message: 'Added tags to entry',
94-
addedTags,
95-
entry: updatedEntry,
96-
},
97-
})
98-
}
88+
void agent.server.server.sendLoggingMessage({
89+
level: 'info',
90+
logger: 'tag-generator',
91+
data: {
92+
message: 'Added tags to entry',
93+
addedTags,
94+
entry: updatedEntry,
95+
},
96+
})
9997
}
10098

10199
const existingTagSchema = z.object({ id: z.number() })

exercises/01.discovery/03.problem.pr/src/index.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { type DBClient } from '@epic-web/epicme-db-client'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
3-
import {
4-
SetLevelRequestSchema,
5-
type LoggingLevel,
6-
} from '@modelcontextprotocol/sdk/types.js'
73
import { McpAgent } from 'agents/mcp'
84
import {
95
handleOAuthAuthorizationServerRequest,
@@ -16,11 +12,8 @@ import { initializeResources } from './resources.ts'
1612
import { initializeTools } from './tools.ts'
1713
import { withCors } from './utils.ts'
1814

19-
type State = { loggingLevel: LoggingLevel }
20-
21-
export class EpicMeMCP extends McpAgent<Env, State> {
15+
export class EpicMeMCP extends McpAgent<Env> {
2216
db!: DBClient
23-
initialState: State = { loggingLevel: 'info' }
2417
server = new McpServer(
2518
{
2619
name: 'epicme',
@@ -47,13 +40,6 @@ You can also help users add tags to their entries and get all tags for an entry.
4740

4841
async init() {
4942
this.db = getClient()
50-
this.server.server.setRequestHandler(
51-
SetLevelRequestSchema,
52-
async (request) => {
53-
this.setState({ ...this.state, loggingLevel: request.params.level })
54-
return {}
55-
},
56-
)
5743
await initializeTools(this)
5844
await initializeResources(this)
5945
await initializePrompts(this)

exercises/01.discovery/03.problem.pr/src/sampling.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,15 @@ If you have some suggestions, respond with an array of tag objects. Existing tag
8585
.map((id) => allTags.find((t) => t.id === id))
8686
.filter(Boolean)
8787

88-
if (['debug', 'info'].includes(agent.state.loggingLevel)) {
89-
void agent.server.server.sendLoggingMessage({
90-
level: 'info',
91-
logger: 'tag-generator',
92-
data: {
93-
message: 'Added tags to entry',
94-
addedTags,
95-
entry: updatedEntry,
96-
},
97-
})
98-
}
88+
void agent.server.server.sendLoggingMessage({
89+
level: 'info',
90+
logger: 'tag-generator',
91+
data: {
92+
message: 'Added tags to entry',
93+
addedTags,
94+
entry: updatedEntry,
95+
},
96+
})
9997
}
10098

10199
const existingTagSchema = z.object({ id: z.number() })

0 commit comments

Comments
 (0)