@@ -14,6 +14,7 @@ import { Effect, Layer, Schema } from "effect";
1414
1515import { addGroup , observabilityMiddleware } from "@executor-js/api" ;
1616import { CoreHandlers , ExecutionEngineService , ExecutorService } from "@executor-js/api/server" ;
17+ import { IntegrationNotFoundError , IntegrationSlug } from "@executor-js/sdk/shared" ;
1718import type { McpPluginExtension } from "../sdk/plugin" ;
1819import { McpConnectionError } from "../sdk/errors" ;
1920import { McpExtensionService , McpHandlers } from "./handlers" ;
@@ -69,6 +70,11 @@ const McpConnectionErrorResponse = Schema.Struct({
6970 message : Schema . String ,
7071} ) ;
7172
73+ const IntegrationNotFoundErrorResponse = Schema . Struct ( {
74+ _tag : Schema . Literal ( "IntegrationNotFoundError" ) ,
75+ slug : Schema . String ,
76+ } ) ;
77+
7278describe ( "McpHandlers" , ( ) => {
7379 it . effect ( "defect-returning methods produce an opaque InternalError, no leakage" , ( ) =>
7480 Effect . gen ( function * ( ) {
@@ -119,4 +125,36 @@ describe("McpHandlers", () => {
119125 expect ( body . message ) . toContain ( "Do you need to provide an API key" ) ;
120126 } ) ,
121127 ) ;
128+
129+ it . effect ( "configureServer IntegrationNotFoundError is encoded as a 404 response" , ( ) =>
130+ Effect . gen ( function * ( ) {
131+ const slug = IntegrationSlug . make ( "missing_mcp" ) ;
132+ const web = yield * webHandlerFor ( {
133+ ...failingExtension ,
134+ configureServer : ( ) => Effect . fail ( new IntegrationNotFoundError ( { slug } ) ) ,
135+ } ) ;
136+ const response = yield * Effect . promise ( ( ) =>
137+ ( web . handler as ( request : Request ) => Promise < Response > ) (
138+ new Request ( "http://localhost/mcp/servers/missing_mcp/config" , {
139+ method : "POST" ,
140+ headers : { "content-type" : "application/json" } ,
141+ body : JSON . stringify ( {
142+ config : {
143+ transport : "remote" ,
144+ endpoint : "https://example.com/mcp" ,
145+ remoteTransport : "auto" ,
146+ authenticationTemplate : [ { slug : "none" , kind : "none" } ] ,
147+ } ,
148+ } ) ,
149+ } ) ,
150+ ) ,
151+ ) ;
152+
153+ expect ( response . status ) . toBe ( 404 ) ;
154+ const body = yield * Schema . decodeUnknownEffect ( IntegrationNotFoundErrorResponse ) (
155+ yield * Effect . promise ( ( ) => response . json ( ) ) ,
156+ ) ;
157+ expect ( body . slug ) . toBe ( "missing_mcp" ) ;
158+ } ) ,
159+ ) ;
122160} ) ;
0 commit comments