/**
* Shared fixtures for the MCP end-to-end tests. They run against a live dev server (default
* http://localhost:3000, override with MCP_BASE_URL) and seed users, tokens and sessions straight into
* that server's local D1 and KV with wrangler, so run them from the worktree whose `vite dev` is under test.
*/
import { createHash, randomBytes } from "node:crypto";
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
import type {
OAuthClientInformationMixed,
OAuthClientMetadata,
OAuthClientProvider,
OAuthTokens,
} from "@modelcontextprotocol/client";
export const BASE = process.env.MCP_BASE_URL ?? "http://localhost:3000";
export const MODERN = "2026-07-28";
const ROOT = new URL("..", import.meta.url).pathname;
const REDIRECT = "http://127.0.0.1:8976/callback";
const SESSION_COOKIE = "__Host-gitfor_session";
const SSE_DATA = "data: ";
const SSE_ID = "id: ";
const HTTP_CREATED = 201;
export type World = {
suffix: string;
userId: string;
owner: string;
repo: string;
otherRepo: string;
repoId: string;
classicToken: string;
sessionCookie: string;
};
/** The parts of JSON-RPC replies the raw-HTTP tests look at. */
export type RpcReply = {
result?: {
structuredContent?: { pushed?: boolean };
tools?: unknown[];
resultType?: string;