66 createAuthHandlers ,
77 handleTokenExchangeCallback ,
88} from '@repo/mcp-common/src/cloudflare-oauth-handler'
9+ import { initSentry } from '@repo/mcp-common/src/sentry'
910import { CloudflareMCPServer } from '@repo/mcp-common/src/server'
1011import { registerAccountTools } from '@repo/mcp-common/src/tools/account'
1112import { registerWorkersTools } from '@repo/mcp-common/src/tools/worker'
@@ -35,7 +36,6 @@ export class ObservabilityMCP extends McpAgent<Env, State, Props> {
3536 set server ( server : CloudflareMCPServer ) {
3637 this . _server = server
3738 }
38-
3939 get server ( ) : CloudflareMCPServer {
4040 if ( ! this . _server ) {
4141 throw new Error ( 'Tried to access server before it was initialized' )
@@ -44,18 +44,19 @@ export class ObservabilityMCP extends McpAgent<Env, State, Props> {
4444 return this . _server
4545 }
4646
47- initialState : State = {
48- activeAccountId : null ,
49- }
50-
5147 constructor ( ctx : DurableObjectState , env : Env ) {
5248 super ( ctx , env )
5349 }
5450
5551 async init ( ) {
56- this . server = new CloudflareMCPServer ( this . props . user . id , this . env . MCP_METRICS , {
57- name : this . env . MCP_SERVER_NAME ,
58- version : this . env . MCP_SERVER_VERSION ,
52+ this . server = new CloudflareMCPServer ( {
53+ userId : this . props . user . id ,
54+ wae : this . env . MCP_METRICS ,
55+ serverInfo : {
56+ name : this . env . MCP_SERVER_NAME ,
57+ version : this . env . MCP_SERVER_VERSION ,
58+ } ,
59+ sentry : initSentry ( env , this . ctx , this . props . user . id ) ,
5960 } )
6061
6162 registerAccountTools ( this )
@@ -72,6 +73,7 @@ export class ObservabilityMCP extends McpAgent<Env, State, Props> {
7273 try {
7374 return this . state . activeAccountId ?? null
7475 } catch ( e ) {
76+ this . server . recordError ( e )
7577 return null
7678 }
7779 }
@@ -84,6 +86,7 @@ export class ObservabilityMCP extends McpAgent<Env, State, Props> {
8486 activeAccountId : accountId ,
8587 } )
8688 } catch ( e ) {
89+ this . server . recordError ( e )
8790 return null
8891 }
8992 }
0 commit comments