Skip to content

Commit 8308712

Browse files
committed
chore: fix formatting issues
1 parent 001cb7e commit 8308712

File tree

4 files changed

+127
-182
lines changed

4 files changed

+127
-182
lines changed

apps/workers-bindings/README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,12 @@ Open the file in your text editor and replace it with this configuration:
4343

4444
```json
4545
{
46-
"mcpServers": {
47-
"math": {
48-
"command": "npx",
49-
"args": [
50-
"mcp-remote",
51-
"http://localhost:8787/sse"
52-
]
53-
}
54-
}
46+
"mcpServers": {
47+
"math": {
48+
"command": "npx",
49+
"args": ["mcp-remote", "http://localhost:8787/sse"]
50+
}
51+
}
5552
}
5653
```
5754

@@ -85,19 +82,16 @@ You've now connected to your MCP server from a remote MCP client.
8582

8683
## Connect Claude Desktop to your remote MCP server
8784

88-
Update the Claude configuration file to point to your `workers.dev` URL (ex: `worker-name.account-name.workers.dev/sse`) and restart Claude
85+
Update the Claude configuration file to point to your `workers.dev` URL (ex: `worker-name.account-name.workers.dev/sse`) and restart Claude
8986

9087
```json
9188
{
92-
"mcpServers": {
93-
"math": {
94-
"command": "npx",
95-
"args": [
96-
"mcp-remote",
97-
"https://worker-name.account-name.workers.dev/sse"
98-
]
99-
}
100-
}
89+
"mcpServers": {
90+
"math": {
91+
"command": "npx",
92+
"args": ["mcp-remote", "https://worker-name.account-name.workers.dev/sse"]
93+
}
94+
}
10195
}
10296
```
10397

apps/workers-bindings/src/app.ts

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,74 @@
1-
import { Hono } from "hono";
1+
import { Hono } from 'hono'
2+
23
import {
3-
layout,
44
homeContent,
5+
layout,
56
parseApproveFormBody,
6-
renderAuthorizationRejectedContent,
77
renderAuthorizationApprovedContent,
8+
renderAuthorizationRejectedContent,
89
renderLoggedInAuthorizeScreen,
910
renderLoggedOutAuthorizeScreen,
10-
} from "./utils";
11-
import type { OAuthHelpers } from "@cloudflare/workers-oauth-provider";
11+
} from './utils'
12+
13+
import type { OAuthHelpers } from '@cloudflare/workers-oauth-provider'
1214

1315
export type Bindings = Env & {
14-
OAUTH_PROVIDER: OAuthHelpers;
15-
};
16+
OAUTH_PROVIDER: OAuthHelpers
17+
}
1618

1719
const app = new Hono<{
18-
Bindings: Bindings;
19-
}>();
20+
Bindings: Bindings
21+
}>()
2022

2123
// Render a basic homepage placeholder to make sure the app is up
22-
app.get("/", async (c) => {
23-
const content = await homeContent(c.req.raw);
24-
return c.html(layout(content, "MCP Remote Auth Demo - Home"));
25-
});
24+
app.get('/', async (c) => {
25+
const content = await homeContent(c.req.raw)
26+
return c.html(layout(content, 'MCP Remote Auth Demo - Home'))
27+
})
2628

2729
// Render an authorization page
2830
// If the user is logged in, we'll show a form to approve the appropriate scopes
2931
// If the user is not logged in, we'll show a form to both login and approve the scopes
30-
app.get("/authorize", async (c) => {
32+
app.get('/authorize', async (c) => {
3133
// We don't have an actual auth system, so to demonstrate both paths, you can
3234
// hard-code whether the user is logged in or not. We'll default to true
3335
// const isLoggedIn = false;
34-
const isLoggedIn = true;
36+
const isLoggedIn = true
3537

36-
const oauthReqInfo = await c.env.OAUTH_PROVIDER.parseAuthRequest(c.req.raw);
38+
const oauthReqInfo = await c.env.OAUTH_PROVIDER.parseAuthRequest(c.req.raw)
3739

3840
const oauthScopes = [
3941
{
40-
name: "read_profile",
41-
description: "Read your basic profile information",
42+
name: 'read_profile',
43+
description: 'Read your basic profile information',
4244
},
43-
{ name: "read_data", description: "Access your stored data" },
44-
{ name: "write_data", description: "Create and modify your data" },
45-
];
45+
{ name: 'read_data', description: 'Access your stored data' },
46+
{ name: 'write_data', description: 'Create and modify your data' },
47+
]
4648

4749
if (isLoggedIn) {
48-
const content = await renderLoggedInAuthorizeScreen(oauthScopes, oauthReqInfo);
49-
return c.html(layout(content, "MCP Remote Auth Demo - Authorization"));
50+
const content = await renderLoggedInAuthorizeScreen(oauthScopes, oauthReqInfo)
51+
return c.html(layout(content, 'MCP Remote Auth Demo - Authorization'))
5052
}
5153

52-
const content = await renderLoggedOutAuthorizeScreen(oauthScopes, oauthReqInfo);
53-
return c.html(layout(content, "MCP Remote Auth Demo - Authorization"));
54-
});
54+
const content = await renderLoggedOutAuthorizeScreen(oauthScopes, oauthReqInfo)
55+
return c.html(layout(content, 'MCP Remote Auth Demo - Authorization'))
56+
})
5557

5658
// The /authorize page has a form that will POST to /approve
5759
// This endpoint is responsible for validating any login information and
5860
// then completing the authorization request with the OAUTH_PROVIDER
59-
app.post("/approve", async (c) => {
61+
app.post('/approve', async (c) => {
6062
const { action, oauthReqInfo, email, password } = await parseApproveFormBody(
61-
await c.req.parseBody(),
62-
);
63+
await c.req.parseBody()
64+
)
6365

6466
if (!oauthReqInfo) {
65-
return c.html("INVALID LOGIN", 401);
67+
return c.html('INVALID LOGIN', 401)
6668
}
6769

6870
// If the user needs to both login and approve, we should validate the login first
69-
if (action === "login_approve") {
71+
if (action === 'login_approve') {
7072
// We'll allow any values for email and password for this demo
7173
// but you could validate them here
7274
// Ex:
@@ -75,10 +77,10 @@ app.post("/approve", async (c) => {
7577
if (false) {
7678
return c.html(
7779
layout(
78-
await renderAuthorizationRejectedContent("/"),
79-
"MCP Remote Auth Demo - Authorization Status",
80-
),
81-
);
80+
await renderAuthorizationRejectedContent('/'),
81+
'MCP Remote Auth Demo - Authorization Status'
82+
)
83+
)
8284
}
8385
}
8486

@@ -88,20 +90,20 @@ app.post("/approve", async (c) => {
8890
request: oauthReqInfo,
8991
userId: email,
9092
metadata: {
91-
label: "Test User",
93+
label: 'Test User',
9294
},
9395
scope: oauthReqInfo.scope,
9496
props: {
9597
userEmail: email,
9698
},
97-
});
99+
})
98100

99101
return c.html(
100102
layout(
101103
await renderAuthorizationApprovedContent(redirectTo),
102-
"MCP Remote Auth Demo - Authorization Status",
103-
),
104-
);
105-
});
104+
'MCP Remote Auth Demo - Authorization Status'
105+
)
106+
)
107+
})
106108

107-
export default app;
109+
export default app

0 commit comments

Comments
 (0)