File tree Expand file tree Collapse file tree 2 files changed +23
-10
lines changed
apps/cloudflare-one-casb/src
packages/mcp-common/src/api Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,29 @@ export type Props = {
2828
2929export type State = { activeAccountId : string | null }
3030export class CASBMCP extends McpAgent < Env , State , Props > {
31- server = new CloudflareMCPServer ( undefined , env . MCP_METRICS , {
32- name : env . MCP_SERVER_NAME ,
33- version : env . MCP_SERVER_VERSION ,
34- } )
31+ _server : CloudflareMCPServer | undefined
32+ set server ( server : CloudflareMCPServer ) {
33+ this . _server = server
34+ }
35+
36+ get server ( ) : CloudflareMCPServer {
37+ if ( ! this . _server ) {
38+ throw new Error ( 'Tried to access server before it was initialized' )
39+ }
40+
41+ return this . _server
42+ }
43+
44+ constructor ( ctx : DurableObjectState , env : Env ) {
45+ super ( ctx , env )
46+ }
3547
3648 async init ( ) {
49+ this . server = new CloudflareMCPServer ( this . props . user . id , this . env . MCP_METRICS , {
50+ name : this . env . MCP_SERVER_NAME ,
51+ version : this . env . MCP_SERVER_VERSION ,
52+ } )
53+
3754 registerAccountTools ( this as unknown as CloudflareMcpAgent )
3855 registerIntegrationsTools ( this )
3956 }
Original file line number Diff line number Diff line change 1- import type { McpAgent } from 'agents/mcp'
21import type { Cloudflare } from 'cloudflare'
32import type { Account } from 'cloudflare/resources/accounts/accounts.mjs'
3+ import type { CloudflareMcpAgent } from '../types/cloudflare-mcp-agent'
44import type { ToolHandler } from '../types/tools'
55
66export async function handleAccountsList ( { client } : { client : Cloudflare } ) : Promise < Account [ ] > {
@@ -9,12 +9,8 @@ export async function handleAccountsList({ client }: { client: Cloudflare }): Pr
99 return response . result
1010}
1111
12- export interface McpAgentWithAccount extends McpAgent {
13- getActiveAccountId : ( ) => string
14- }
15-
1612export const withAccountCheck = < T extends Record < string , any > > (
17- agent : McpAgentWithAccount ,
13+ agent : CloudflareMcpAgent ,
1814 handler : ToolHandler < T >
1915) => {
2016 return async ( params : T ) => {
You can’t perform that action at this time.
0 commit comments