Skip to content

Commit 8609cc3

Browse files
committed
remove the migrate to cloudflare stuff
1 parent e38acbb commit 8609cc3

File tree

25 files changed

+48
-1053
lines changed

25 files changed

+48
-1053
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# STDIO Start
1+
# Start
File renamed without changes.
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
{
2-
"name": "exercises_01.start_01.solution",
2+
"name": "exercises_02.start_01.solution",
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"dev": "mcp-dev stdio",
7-
"dev:mcp": "tsx src/index.ts",
86
"test": "vitest run",
97
"test:watch": "vitest --watch",
8+
"pretypecheck": "wrangler types ./types/worker-configuration.d.ts",
109
"typecheck": "tsc",
10+
"build": "wrangler build",
11+
"dev": "mcp-dev",
12+
"dev:server": "cross-env wrangler dev --port ${PORT:-8787}",
1113
"inspect": "mcp-inspector"
1214
},
1315
"dependencies": {
16+
"@epic-web/epicme-db-client": "*",
1417
"@epic-web/invariant": "^1.0.0",
1518
"@modelcontextprotocol/sdk": "^1.17.2",
19+
"agents": "^0.0.111",
1620
"zod": "^3.25.67"
1721
},
1822
"devDependencies": {
@@ -21,9 +25,14 @@
2125
"@faker-js/faker": "^9.9.0",
2226
"@modelcontextprotocol/inspector": "0.16.2",
2327
"@types/node": "^24.2.1",
24-
"tsx": "^4.20.3",
28+
"cross-env": "^10.0.0",
29+
"eslint": "^9.33.0",
30+
"execa": "^9.6.0",
31+
"prettier": "^3.6.2",
2532
"typescript": "^5.9.2",
26-
"vitest": "^3.2.4"
33+
"vitest": "^3.2.4",
34+
"wrangler": "^4.28.1"
2735
},
36+
"prettier": "@epic-web/config/prettier",
2837
"license": "GPL-3.0-only"
2938
}

exercises/01.start/01.solution/src/index.test.ts

Lines changed: 0 additions & 103 deletions
This file was deleted.

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

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { type DBClient } from '@epic-web/epicme-db-client'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
3-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
4-
import { SetLevelRequestSchema } from '@modelcontextprotocol/sdk/types.js'
3+
import {
4+
SetLevelRequestSchema,
5+
type LoggingLevel,
6+
} from '@modelcontextprotocol/sdk/types.js'
7+
import { McpAgent } from 'agents/mcp'
58
import { getClient } from './client.ts'
69
import { initializePrompts } from './prompts.ts'
710
import { initializeResources } from './resources.ts'
811
import { initializeTools } from './tools.ts'
912

10-
export class EpicMeMCP {
13+
type State = { loggingLevel: LoggingLevel }
14+
export class EpicMeMCP extends McpAgent<Env, State> {
1115
db!: DBClient
12-
state = { loggingLevel: 'info' }
16+
initialState: State = { loggingLevel: 'info' }
1317
server = new McpServer(
1418
{
1519
name: 'epicme',
@@ -39,7 +43,7 @@ You can also help users add tags to their entries and get all tags for an entry.
3943
this.server.server.setRequestHandler(
4044
SetLevelRequestSchema,
4145
async (request) => {
42-
this.state.loggingLevel = request.params.level
46+
this.setState({ ...this.state, loggingLevel: request.params.level })
4347
return {}
4448
},
4549
)
@@ -49,15 +53,17 @@ You can also help users add tags to their entries and get all tags for an entry.
4953
}
5054
}
5155

52-
async function main() {
53-
const agent = new EpicMeMCP()
54-
await agent.init()
55-
const transport = new StdioServerTransport()
56-
await agent.server.connect(transport)
57-
console.error('EpicMe MCP Server running on stdio')
58-
}
56+
export default {
57+
fetch: async (request, env, ctx) => {
58+
const url = new URL(request.url)
59+
60+
if (url.pathname === '/mcp') {
61+
const mcp = EpicMeMCP.serve('/mcp', {
62+
binding: 'EPIC_ME_MCP_OBJECT',
63+
})
64+
return mcp.fetch(request, env, ctx)
65+
}
5966

60-
main().catch((error) => {
61-
console.error('Fatal error in main():', error)
62-
process.exit(1)
63-
})
67+
return new Response('Not found', { status: 404 })
68+
},
69+
} satisfies ExportedHandler<Env>
File renamed without changes.
File renamed without changes.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
22
"extends": ["@epic-web/config/typescript"],
3-
"include": ["types/**/*.d.ts", "src/**/*.ts"]
3+
"include": [
4+
"types/**/*.d.ts",
5+
"src/**/*.ts",
6+
"test/**/*.ts",
7+
"vitest.config.ts"
8+
]
49
}

exercises/02.start/01.solution/types/worker-configuration.d.ts renamed to exercises/01.start/01.solution/types/worker-configuration.d.ts

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)