Skip to content

Commit f9e6923

Browse files
committed
wip
1 parent 2d2350c commit f9e6923

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

apps/cloudflare-one-casb/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export type Props = {
2222
}
2323

2424
export type State = { activeAccountId: string | null }
25-
export class MyMCP extends McpAgent<Env, State, Props> {
25+
export class CASBMCP extends McpAgent<Env, State, Props> {
2626
// @ts-ignore
2727
server = new McpServer({
28-
name: 'Remote MCP Server with Workers Observability',
28+
name: "Remote MCP Server with Cloudflare One's Cloud Access Security Broker (CASB)",
2929
version: '1.0.0',
3030
})
3131

@@ -34,7 +34,6 @@ export class MyMCP extends McpAgent<Env, State, Props> {
3434
}
3535

3636
async init() {
37-
// @ts-ignore
3837
registerAccountTools(this)
3938
registerIntegrationsTools(this)
4039
}
@@ -72,7 +71,7 @@ const CloudflareOneCasbScopes = {
7271
export default new OAuthProvider({
7372
apiRoute: '/sse',
7473
// @ts-ignore
75-
apiHandler: MyMCP.mount('/sse'),
74+
apiHandler: CASBMCP.mount('/sse'),
7675
// @ts-ignore
7776
defaultHandler: createAuthHandlers({ scopes: CloudflareOneCasbScopes }),
7877
authorizeEndpoint: '/oauth/authorize',

apps/cloudflare-one-casb/src/tools/integrations.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
assetCategoryVendorParam,
1616
} from '@repo/mcp-common/src/schemas/cf1-integrations'
1717

18-
import type { MyMCP } from '../index'
18+
import type { CASBMCP } from '../index'
1919

2020
const PAGE_SIZE = 3
2121

@@ -40,7 +40,10 @@ interface ToolDefinition<T extends Record<string, any>> {
4040
}
4141

4242
// Helper function to handle common error cases and account ID checks
43-
const withAccountCheck = <T extends Record<string, any>>(agent: MyMCP, handler: ToolHandler<T>) => {
43+
const withAccountCheck = <T extends Record<string, any>>(
44+
agent: CASBMCP,
45+
handler: ToolHandler<T>
46+
) => {
4447
return async (params: T) => {
4548
const accountId = agent.getActiveAccountId()
4649
if (!accountId) {
@@ -295,7 +298,7 @@ const toolDefinitions: Array<ToolDefinition<any>> = [
295298
* Registers the logs analysis tool with the MCP server
296299
* @param agent The MCP server instance
297300
*/
298-
export function registerIntegrationsTools(agent: MyMCP) {
301+
export function registerIntegrationsTools(agent: CASBMCP) {
299302
toolDefinitions.forEach(({ name, description, params, handler }) => {
300303
agent.server.tool(name, description, params, withAccountCheck(agent, handler))
301304
})

apps/cloudflare-one-casb/worker-configuration.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ declare namespace Cloudflare {
55
OAUTH_KV: KVNamespace;
66
CLOUDFLARE_CLIENT_ID: string;
77
CLOUDFLARE_CLIENT_SECRET: string;
8-
MCP_OBJECT: DurableObjectNamespace<import("./src/index").MyMCP>;
8+
MCP_OBJECT: DurableObjectNamespace<import("./src/index").CASBMCP>;
99
}
1010
}
1111
interface Env extends Cloudflare.Env {}

apps/cloudflare-one-casb/wrangler.jsonc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"compatibility_flags": ["nodejs_compat"],
1010
"migrations": [
1111
{
12-
"new_sqlite_classes": ["MyMCP"],
12+
"new_sqlite_classes": ["CASBMCP"],
1313
"tag": "v1"
1414
}
1515
],
@@ -22,7 +22,7 @@
2222
"durable_objects": {
2323
"bindings": [
2424
{
25-
"class_name": "MyMCP",
25+
"class_name": "CASBMCP",
2626
"name": "MCP_OBJECT"
2727
}
2828
]
@@ -43,7 +43,7 @@
4343
"durable_objects": {
4444
"bindings": [
4545
{
46-
"class_name": "MyMCP",
46+
"class_name": "CASBMCP",
4747
"name": "MCP_OBJECT"
4848
}
4949
]
@@ -62,7 +62,7 @@
6262
"durable_objects": {
6363
"bindings": [
6464
{
65-
"class_name": "MyMCP",
65+
"class_name": "CASBMCP",
6666
"name": "MCP_OBJECT"
6767
}
6868
]

packages/mcp-common/src/cloudflare-oauth-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export function createAuthHandlers({ scopes }: { scopes: Record<string, string>
222222
label: user.email,
223223
},
224224
scope: oauthReqInfo.scope,
225-
// This will be available on this.props inside MyMCP
225+
// This will be available on this.props inside CASBMCP
226226
props: {
227227
user,
228228
accounts,

0 commit comments

Comments
 (0)