Skip to content

Commit 38fb43b

Browse files
committed
style: format toolkit route changes
1 parent bf2bc48 commit 38fb43b

5 files changed

Lines changed: 35 additions & 40 deletions

File tree

‎apps/cloud/src/mcp/agent-handler.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,7 @@ export const makeCloudMcpAgentHandler = () => {
256256
let owner: "ok" | "not_found" | "forbidden" | "terminated";
257257
// oxlint-disable-next-line executor/no-try-catch-or-throw -- adapter boundary: a Durable Object stub RPC rejects with a plain platform Error, never a typed failure
258258
try {
259-
owner = await mcpSessionStub(
260-
env.MCP_SESSION,
261-
sessionId,
262-
).validateMcpSessionOwner(
259+
owner = await mcpSessionStub(env.MCP_SESSION, sessionId).validateMcpSessionOwner(
263260
{
264261
accountId: outcome.principal.accountId,
265262
organizationId: outcome.principal.organizationId,

‎apps/host-cloudflare/src/mcp/agent-handler.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ export const makeCloudflareMcpAgentHandler = (config: CloudflareConfig) => {
127127
}
128128

129129
if (sessionId) {
130-
const owner = await mcpSessionStub(
131-
env.MCP_SESSION,
132-
sessionId,
133-
).validateMcpSessionOwner(
130+
const owner = await mcpSessionStub(env.MCP_SESSION, sessionId).validateMcpSessionOwner(
134131
{
135132
accountId: outcome.principal.accountId,
136133
organizationId: outcome.principal.organizationId,
@@ -150,9 +147,7 @@ export const makeCloudflareMcpAgentHandler = (config: CloudflareConfig) => {
150147
}
151148
}
152149

153-
const props = await Effect.runPromise(
154-
propsForPrincipal(request, outcome.principal, resource),
155-
);
150+
const props = await Effect.runPromise(propsForPrincipal(request, outcome.principal, resource));
156151
(ctx as ExecutionContext & { props?: McpSessionProps }).props = props;
157152
const forwarded = withVerifiedIdentityHeaders(
158153
request,

‎apps/host-cloudflare/src/mcp/resource.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ export const mcpResourceFromPath = (pathname: string): McpResource | null => {
44
if (pathname === "/mcp") return defaultMcpResource;
55

66
const toolkitMatch = /^\/mcp\/toolkits\/([^/]+)$/.exec(pathname);
7-
return toolkitMatch?.[1]
8-
? { kind: "toolkit", slug: toolkitMatch[1] }
9-
: null;
7+
return toolkitMatch?.[1] ? { kind: "toolkit", slug: toolkitMatch[1] } : null;
108
};

‎packages/hosts/cloudflare/src/mcp/agent-session-durable-object.test.ts‎

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,13 @@ type HarnessSession = {
158158
identity: McpApprovalOwner,
159159
response: ResumeResponse,
160160
) => Promise<McpSessionModelResumeResult>;
161-
validateMcpSessionOwner: (identity: {
162-
readonly accountId: string;
163-
readonly organizationId: string;
164-
}, resource: McpResource) => Promise<"ok" | "not_found" | "forbidden" | "terminated">;
161+
validateMcpSessionOwner: (
162+
identity: {
163+
readonly accountId: string;
164+
readonly organizationId: string;
165+
},
166+
resource: McpResource,
167+
) => Promise<"ok" | "not_found" | "forbidden" | "terminated">;
165168
};
166169

167170
class StaleCloseTransport implements Transport {
@@ -550,9 +553,7 @@ describe("McpAgentSessionDOBase transport restore", () => {
550553
const session = await makeHarnessSession();
551554
const identity = { accountId: "user-1", organizationId: "org-1" };
552555

553-
await expect(
554-
session.validateMcpSessionOwner(identity, defaultMcpResource),
555-
).resolves.toBe("ok");
556+
await expect(session.validateMcpSessionOwner(identity, defaultMcpResource)).resolves.toBe("ok");
556557
await expect(
557558
session.validateMcpSessionOwner(identity, {
558559
kind: "toolkit",
@@ -581,14 +582,20 @@ describe("McpAgentSessionDOBase transport restore", () => {
581582

582583
await session.alarm();
583584

584-
const first = session.validateMcpSessionOwner({
585-
accountId: "user-1",
586-
organizationId: "org-1",
587-
}, defaultMcpResource);
588-
const second = session.validateMcpSessionOwner({
589-
accountId: "user-1",
590-
organizationId: "org-1",
591-
}, defaultMcpResource);
585+
const first = session.validateMcpSessionOwner(
586+
{
587+
accountId: "user-1",
588+
organizationId: "org-1",
589+
},
590+
defaultMcpResource,
591+
);
592+
const second = session.validateMcpSessionOwner(
593+
{
594+
accountId: "user-1",
595+
organizationId: "org-1",
596+
},
597+
defaultMcpResource,
598+
);
592599

593600
await firstRestoreEntered.promise;
594601
await Promise.resolve();
@@ -617,10 +624,13 @@ describe("McpAgentSessionDOBase transport restore", () => {
617624

618625
await session.alarm();
619626

620-
const restore = session.validateMcpSessionOwner({
621-
accountId: "user-1",
622-
organizationId: "org-1",
623-
}, defaultMcpResource);
627+
const restore = session.validateMcpSessionOwner(
628+
{
629+
accountId: "user-1",
630+
organizationId: "org-1",
631+
},
632+
defaultMcpResource,
633+
);
624634
const sdkStart = session.onStart();
625635

626636
await firstStartEntered.promise;

‎packages/hosts/cloudflare/src/mcp/agent-session-durable-object.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ import {
1818
type PausedExecutionHooks,
1919
type ResumeFallbackOutcome,
2020
} from "@executor-js/host-mcp/tool-server";
21-
import {
22-
defaultMcpResource,
23-
mcpResourceKey,
24-
type McpResource,
25-
} from "@executor-js/host-mcp";
21+
import { defaultMcpResource, mcpResourceKey, type McpResource } from "@executor-js/host-mcp";
2622

2723
import type { IncomingPropagationHeaders, McpElicitationMode } from "./do-headers";
2824
import { classifyDurableObjectError, type DurableObjectFailure } from "./durable-object-errors";
@@ -1569,8 +1565,7 @@ export abstract class McpAgentSessionDOBase<
15691565
const ownerMatches =
15701566
identity.accountId === sessionMeta.userId &&
15711567
identity.organizationId === sessionMeta.organizationId;
1572-
const resourceMatches =
1573-
mcpResourceKey(resource) === mcpResourceKey(sessionMeta.resource);
1568+
const resourceMatches = mcpResourceKey(resource) === mcpResourceKey(sessionMeta.resource);
15741569
return ownerMatches && resourceMatches ? ("ok" as const) : ("forbidden" as const);
15751570
}).pipe(
15761571
Effect.withSpan("McpSessionDO.validateMcpSessionOwner"),

0 commit comments

Comments
 (0)