11import { type DBClient } from '@epic-web/epicme-db-client'
22import { invariant } from '@epic-web/invariant'
33import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
4+ import {
5+ SetLevelRequestSchema ,
6+ type LoggingLevel ,
7+ } from '@modelcontextprotocol/sdk/types.js'
48import { McpAgent } from 'agents/mcp'
59import {
610 type AuthInfo ,
@@ -15,8 +19,12 @@ import { initializeResources } from './resources.ts'
1519import { initializeTools } from './tools.ts'
1620import { withCors } from './utils.ts'
1721
18- export class EpicMeMCP extends McpAgent < Env , { } , { authInfo : AuthInfo } > {
22+ type State = { loggingLevel : LoggingLevel }
23+ type Props = { authInfo : AuthInfo }
24+
25+ export class EpicMeMCP extends McpAgent < Env , State , Props > {
1926 db ! : DBClient
27+ initialState : State = { loggingLevel : 'info' }
2028 server = new McpServer (
2129 {
2230 name : 'epicme' ,
@@ -45,6 +53,15 @@ You can also help users add tags to their entries and get all tags for an entry.
4553 const authInfo = this . props . authInfo
4654 invariant ( authInfo , 'Auth info not found' )
4755 this . db = getClient ( authInfo . token )
56+
57+ this . server . server . setRequestHandler (
58+ SetLevelRequestSchema ,
59+ async ( request ) => {
60+ this . setState ( { ...this . state , loggingLevel : request . params . level } )
61+ return { }
62+ } ,
63+ )
64+
4865 await initializeTools ( this )
4966 await initializeResources ( this )
5067 await initializePrompts ( this )
0 commit comments