fix(httpapi): return mcp server not found errors (#28817)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { expect, mock, beforeEach } from "bun:test"
|
||||
import { Effect, Exit } from "effect"
|
||||
import { Cause, Effect, Exit } from "effect"
|
||||
import type { MCP as MCPNS } from "../../src/mcp/index"
|
||||
import { testEffect } from "../lib/effect"
|
||||
|
||||
@@ -635,12 +635,15 @@ it.instance(
|
||||
// ========================================================================
|
||||
|
||||
it.instance(
|
||||
"connect() on nonexistent server does not throw",
|
||||
"connect() on nonexistent server fails with NotFoundError",
|
||||
() =>
|
||||
MCP.Service.use((mcp: MCPNS.Interface) =>
|
||||
Effect.gen(function* () {
|
||||
// Should not throw
|
||||
yield* mcp.connect("nonexistent")
|
||||
const exit = yield* mcp.connect("nonexistent").pipe(Effect.exit)
|
||||
expect(Exit.isFailure(exit)).toBe(true)
|
||||
if (Exit.isFailure(exit)) {
|
||||
expect(Cause.squash(exit.cause)).toMatchObject({ _tag: "MCP.NotFoundError", name: "nonexistent" })
|
||||
}
|
||||
const status = yield* mcp.status()
|
||||
expect(status["nonexistent"]).toBeUndefined()
|
||||
}),
|
||||
@@ -653,12 +656,15 @@ it.instance(
|
||||
// ========================================================================
|
||||
|
||||
it.instance(
|
||||
"disconnect() on nonexistent server does not throw",
|
||||
"disconnect() on nonexistent server fails with NotFoundError",
|
||||
() =>
|
||||
MCP.Service.use((mcp: MCPNS.Interface) =>
|
||||
Effect.gen(function* () {
|
||||
yield* mcp.disconnect("nonexistent")
|
||||
// Should complete without error
|
||||
const exit = yield* mcp.disconnect("nonexistent").pipe(Effect.exit)
|
||||
expect(Exit.isFailure(exit)).toBe(true)
|
||||
if (Exit.isFailure(exit)) {
|
||||
expect(Cause.squash(exit.cause)).toMatchObject({ _tag: "MCP.NotFoundError", name: "nonexistent" })
|
||||
}
|
||||
}),
|
||||
),
|
||||
{ config: { mcp: {} } },
|
||||
|
||||
Reference in New Issue
Block a user