Skip to content

Commit 9d0c435

Browse files
committed
chore: fix type issues and PR feedback
1 parent 01adb3e commit 9d0c435

File tree

8 files changed

+693
-613
lines changed

8 files changed

+693
-613
lines changed

apps/workers-bindings/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "remote-mcp-server",
2+
"name": "workers-bindings",
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
@@ -18,7 +18,6 @@
1818
"marked": "15.0.7",
1919
"typescript": "5.5.4",
2020
"vitest": "3.0.9",
21-
"workers-mcp": "^0.1.0-3",
2221
"wrangler": "4.10.0"
2322
},
2423
"dependencies": {

apps/workers-bindings/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import OAuthProvider from '@cloudflare/workers-oauth-provider'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
33
import { McpAgent } from 'agents/mcp'
4+
import { env } from 'cloudflare:workers'
45

56
import {
67
CloudflareAuthHandler,
@@ -68,7 +69,8 @@ export default new OAuthProvider({
6869
defaultHandler: CloudflareAuthHandler,
6970
authorizeEndpoint: '/oauth/authorize',
7071
tokenEndpoint: '/token',
71-
tokenExchangeCallback: handleTokenExchangeCallback,
72+
tokenExchangeCallback: (options) =>
73+
handleTokenExchangeCallback(options, env.CLOUDFLARE_CLIENT_ID, env.CLOUDFLARE_CLIENT_SECRET),
7274
// Cloudflare access token TTL
7375
accessTokenTTL: 3600,
7476
clientRegistrationEndpoint: '/register',

apps/workers-bindings/worker-configuration.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Generated by Wrangler by running `wrangler types` (hash: bcea92b4b34ff43daede463c6e9dfc75)
1+
// Generated by Wrangler by running `wrangler types` (hash: 83b65e4226fcf5092146edc626681982)
22
// Runtime types generated with [email protected] 2025-03-10 nodejs_compat
33
declare namespace Cloudflare {
44
interface Env {
55
OAUTH_KV: KVNamespace;
6-
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
6+
CLOUDFLARE_CLIENT_ID: string;
7+
CLOUDFLARE_CLIENT_SECRET: string;
78
MCP_OBJECT: DurableObjectNamespace<import("./src/index").WorkersBindingsMCP>;
8-
ASSETS: Fetcher;
99
}
1010
}
1111
interface Env extends Cloudflare.Env {}

apps/workers-observability/src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import OAuthProvider from '@cloudflare/workers-oauth-provider'
22
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
33
import { McpAgent } from 'agents/mcp'
4+
import { env } from 'cloudflare:workers'
45

56
import {
67
CloudflareAuthHandler,
@@ -12,7 +13,6 @@ import { registerWorkersTools } from '@repo/mcp-common/src/tools/worker'
1213
import { registerLogsTools } from './tools/logs'
1314

1415
import type { AccountSchema, UserSchema } from '@repo/mcp-common/src/cloudflare-oauth-handler'
15-
import type { Env } from '../worker-configuration'
1616

1717
// Context from the auth process, encrypted & stored in the auth token
1818
// and provided to the DurableMCP as this.props
@@ -29,9 +29,6 @@ export class MyMCP extends McpAgent<Env, State, Props> {
2929
name: 'Remote MCP Server with Workers Observability',
3030
version: '1.0.0',
3131
})
32-
// TOOO: Why does this type need to be declared again on MyMCP?
33-
// @ts-ignore
34-
env!: Env
3532

3633
initialState: State = {
3734
activeAccountId: null,
@@ -77,7 +74,8 @@ export default new OAuthProvider({
7774
defaultHandler: CloudflareAuthHandler,
7875
authorizeEndpoint: '/oauth/authorize',
7976
tokenEndpoint: '/token',
80-
tokenExchangeCallback: handleTokenExchangeCallback,
77+
tokenExchangeCallback: (options) =>
78+
handleTokenExchangeCallback(options, env.CLOUDFLARE_CLIENT_ID, env.CLOUDFLARE_CLIENT_SECRET),
8179
// Cloudflare access token TTL
8280
accessTokenTTL: 3600,
8381
clientRegistrationEndpoint: '/register',

apps/workers-observability/vitest.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'
22

3-
import type { Env } from './worker-configuration'
4-
53
export interface TestEnv extends Env {
64
CLOUDFLARE_MOCK_ACCOUNT_ID: string
75
CLOUDFLARE_MOCK_API_TOKEN: string

0 commit comments

Comments
 (0)