feat: upgrade investigation and presentation runtime
This commit is contained in:
@@ -7,7 +7,7 @@ const sessions: string[] = [];
|
||||
afterEach(() => { for (const id of sessions.splice(0)) releaseSessionCredential(id); });
|
||||
const settings = { issuer: "http://localhost/realms/test", resource: "http://localhost/mcp", audience: "tjwater-mcp", clientId: "tjwater-agent-mcp", clientSecret: "fixture-secret" };
|
||||
const owner = (id: string) => ({ context: { sessionId: id, actorKey: "actor", clientSessionId: id, projectId: "project", projectKey: "project", traceId: "test", purpose: "ordinary_chat" as const }, runtimeSessionId: id });
|
||||
const catalog = PRODUCT_MCP_TOOLS.map((name) => ({ name, inputSchema: { type: "object" as const, additionalProperties: false, properties: { context_handle: { type: "string" }, element_type: { type: "string" }, ...(name === "run_simulation" ? { timeout_seconds: { type: "integer", default: 120, maximum: 3600 } } : {}) }, required: ["context_handle", "element_type"] } }));
|
||||
const catalog = PRODUCT_MCP_TOOLS.map((name) => ({ name, inputSchema: { type: "object" as const, additionalProperties: false, properties: { context_handle: { type: "string" }, element_type: { type: "string" }, ...(name === "run_simulation" ? { timeout_seconds: { type: "integer", default: 120, maximum: 240 } } : {}) }, required: ["context_handle", "element_type"] } }));
|
||||
// Test through a transport-independent fake only where the concern is token ownership/renewal.
|
||||
function fixture(http: McpHttpFetch, authMethod = "client_secret_post") {
|
||||
const client = new McpQueryClient(settings, (async (url, init) => {
|
||||
@@ -26,7 +26,7 @@ const resourceToken = jwt("resource");
|
||||
const token = () => Response.json({ access_token: resourceToken, token_type: "Bearer", expires_in: 300 });
|
||||
function credential(id: string) { sessions.push(id); bindSessionCredential(id, { authorization: `Bearer ${jwt(id)}`, projectId: "project" }); }
|
||||
|
||||
it("forwards the selected simulation budget through HTTP and SDK while rejecting excess before OAuth", async () => {
|
||||
it("owns simulation HTTP budgets and rejects model overrides before OAuth", async () => {
|
||||
const id = "mcp-calculation-budget"; credential(id);
|
||||
let requests = 0, transportTimeout = 0, sdkTimeout = 0;
|
||||
const client = fixture((async (url, init) => {
|
||||
@@ -42,12 +42,14 @@ it("forwards the selected simulation budget through HTTP and SDK while rejecting
|
||||
return { content: [], structuredContent: params };
|
||||
} });
|
||||
} });
|
||||
await expect(client.query(id, owner(id), "run_simulation", { timeout_seconds: 3601 }, "excess")).rejects.toMatchObject({ status: 400 });
|
||||
await expect(client.query(id, owner(id), "run_simulation", { timeout_seconds: 241 }, "excess")).rejects.toMatchObject({ status: 400 });
|
||||
expect(requests).toBe(0);
|
||||
const result = await client.query(id, owner(id), "run_simulation", { timeout_seconds: 900 }, "long");
|
||||
expect(transportTimeout).toBe(30_000);
|
||||
expect(sdkTimeout).toBe(30_000);
|
||||
expect(result.structuredContent).toMatchObject({ arguments: { timeout_seconds: 900, context_handle: "x".repeat(43) } });
|
||||
expect(client.catalog().find((tool) => tool.name === "run_simulation")!.inputSchema.properties).not.toHaveProperty("timeout_seconds");
|
||||
Object.assign(client, { tools: catalog.map((tool) => ({ ...tool, _meta: { "io.tjwater/request-timeout": { defaultSeconds: 240, maxSeconds: 240 } } })) });
|
||||
const result = await client.query(id, owner(id), "run_simulation", {}, "long");
|
||||
expect(transportTimeout).toBe(270_000);
|
||||
expect(sdkTimeout).toBe(270_000);
|
||||
expect(result.structuredContent).toMatchObject({ arguments: { timeout_seconds: 240, context_handle: "x".repeat(43) } });
|
||||
});
|
||||
|
||||
it("requires HTTPS except loopback, and fixed resource paths", () => {
|
||||
|
||||
Reference in New Issue
Block a user