Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions apps/cloud/src/mcp/v2-forward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Data, Effect, Schema } from "effect";

import {
FORWARD_TOKEN_TTL_SECONDS,
PASSTHROUGH_MOVED_MESSAGE,
TOOLKIT_NOT_FOUND_MESSAGE,
buildV2Url,
forwardHeaders,
Expand Down Expand Up @@ -123,6 +122,7 @@ describe("v2 URL", () => {

it("drops every other v1 parameter", () => {
expect(url("?search_tools=true&artifacts=false&mode=codemode&x=1")).toBe(`${ORIGIN}/mcp`);
expect(url("?mode=passthrough")).toBe(`${ORIGIN}/mcp`);
});

it("adds the connection for a toolkit URL", () => {
Expand Down Expand Up @@ -299,7 +299,7 @@ describe("forwardToV2", () => {
expect(seen).toHaveLength(0);
});

it("refuses passthrough mode without calling v2", async () => {
it("forwards a passthrough-mode request to v2 without the mode", async () => {
const { env, seen } = makeEnv(() => new Response("ok"));
const response = await forwardToV2(
new Request("https://executor.sh/mcp?mode=passthrough", { method: "POST", body: "{}" }),
Expand All @@ -308,11 +308,27 @@ describe("forwardToV2", () => {
env,
makeDeps(),
);
expect(response.status).toBe(400);
expect(((await response.json()) as { error: { message: string } }).error.message).toBe(
PASSTHROUGH_MOVED_MESSAGE,
expect(response.status).toBe(200);
expect(seen).toHaveLength(1);
expect(seen[0]?.url).toBe(`${ORIGIN}/mcp`);
});

it("forwards a passthrough-mode toolkit request to its connection", async () => {
const { env, seen } = makeEnv(() => new Response("ok"));
const response = await forwardToV2(
new Request("https://executor.sh/mcp/toolkits/deploy?mode=passthrough", {
method: "POST",
body: "{}",
}),
principal,
moved,
env,
makeDeps({ deploy: "tk_row_example" }),
);
expect(response.status).toBe(200);
expect(seen[0]?.url).toBe(
`${ORIGIN}/mcp?connection=v1-59b67fa9ffe6d72010b3b9fa56f5bdb38199f2e1`,
);
expect(seen).toHaveLength(0);
});

it("answers a retryable 503 when v2 answers 401", async () => {
Expand Down
Loading