Skip to content

Commit 5827f18

Browse files
Frank MeszarosFrank Meszaros
authored andcommitted
Working MCP Inspector CF1 CASB Toolchain
1 parent b476309 commit 5827f18

File tree

10 files changed

+4245
-5514
lines changed

10 files changed

+4245
-5514
lines changed

.cursor/mcp.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"mcpServers": {
3+
"cloudflare-one-casb-local": {
4+
"url": "http://localhost:8976/sse"
5+
}
6+
}
7+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
CLOUDFLARE_CLIENT_ID=
2-
CLOUDFLARE_CLIENT_SECRET=
2+
CLOUDFLARE_CLIENT_SECRET=

apps/cloudflare-one-casb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"@cloudflare/workers-oauth-provider": "0.0.2",
1616
"@hono/zod-validator": "0.4.3",
17-
"@modelcontextprotocol/sdk": "1.8.0",
17+
"@modelcontextprotocol/sdk": "1.9.0",
1818
"@repo/mcp-common": "workspace:*",
1919
"agents": "0.0.49",
2020
"cloudflare": "4.2.0",

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { McpAgent } from 'agents/mcp'
44
import { env } from 'cloudflare:workers'
55

66
import {
7-
CloudflareAuthHandler,
7+
createAuthHandlers,
88
handleTokenExchangeCallback,
99
} from '@repo/mcp-common/src/cloudflare-oauth-handler'
1010
import { registerAccountTools } from '@repo/mcp-common/src/tools/account'
1111

1212
import { registerIntegrationsTools } from './tools/integrations'
1313

14+
15+
1416
import type { AccountSchema, UserSchema } from '@repo/mcp-common/src/cloudflare-oauth-handler'
1517

1618
// Context from the auth process, encrypted & stored in the auth token
@@ -22,8 +24,8 @@ export type Props = {
2224
}
2325

2426
export type State = { activeAccountId: string | null }
25-
2627
export class MyMCP extends McpAgent<Env, State, Props> {
28+
// @ts-ignore
2729
server = new McpServer({
2830
name: 'Remote MCP Server with Workers Observability',
2931
version: '1.0.0',
@@ -34,11 +36,9 @@ export class MyMCP extends McpAgent<Env, State, Props> {
3436
}
3537

3638
async init() {
39+
// @ts-ignore
3740
registerAccountTools(this)
38-
39-
registerIntegrationsTools(this, env.CLOUDFLARE_GLOBAL_API_KEY)
40-
41-
// TODO: registerFindingsTools @mleslie
41+
registerIntegrationsTools(this)
4242
}
4343

4444
getActiveAccountId() {
@@ -64,13 +64,22 @@ export class MyMCP extends McpAgent<Env, State, Props> {
6464
}
6565
}
6666
}
67+
const CloudflareOneCasbScopes = {
68+
'account:read': 'See your account info such as account details, analytics, and memberships.',
69+
'user:read': 'See your user info such as name, email address, and account memberships.',
70+
'workers:write':
71+
'See and change Cloudflare Workers data such as zones, KV storage, namespaces, scripts, and routes.',
72+
'workers_observability:read': 'See observability logs for your account',
73+
'teams:read': 'See Cloudflare One Resources',
74+
offline_access: 'Grants refresh tokens for long-lived access.',
75+
} as const
6776

6877
export default new OAuthProvider({
6978
apiRoute: '/sse',
7079
// @ts-ignore
7180
apiHandler: MyMCP.mount('/sse'),
7281
// @ts-ignore
73-
defaultHandler: CloudflareAuthHandler,
82+
defaultHandler: createAuthHandlers({ scopes: CloudflareOneCasbScopes }),
7483
authorizeEndpoint: '/oauth/authorize',
7584
tokenEndpoint: '/token',
7685
tokenExchangeCallback: (options) =>

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

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)