@@ -86,10 +86,7 @@ async function validateServer(serverId: string) {
8686/**
8787 * GET - Server info and capabilities (MCP initialize)
8888 */
89- export async function GET (
90- request : NextRequest ,
91- { params } : { params : Promise < RouteParams > }
92- ) {
89+ export async function GET ( request : NextRequest , { params } : { params : Promise < RouteParams > } ) {
9390 const { serverId } = await params
9491
9592 try {
@@ -122,10 +119,7 @@ export async function GET(
122119/**
123120 * POST - Handle MCP JSON-RPC requests
124121 */
125- export async function POST (
126- request : NextRequest ,
127- { params } : { params : Promise < RouteParams > }
128- ) {
122+ export async function POST ( request : NextRequest , { params } : { params : Promise < RouteParams > } ) {
129123 const { serverId } = await params
130124
131125 try {
@@ -151,10 +145,9 @@ export async function POST(
151145 const rpcRequest = body as JsonRpcRequest
152146
153147 if ( rpcRequest . jsonrpc !== '2.0' || ! rpcRequest . method ) {
154- return NextResponse . json (
155- createJsonRpcError ( rpcRequest ?. id || 0 , - 32600 , 'Invalid Request' ) ,
156- { status : 400 }
157- )
148+ return NextResponse . json ( createJsonRpcError ( rpcRequest ?. id || 0 , - 32600 , 'Invalid Request' ) , {
149+ status : 400 ,
150+ } )
158151 }
159152
160153 // Handle different MCP methods
@@ -178,7 +171,9 @@ export async function POST(
178171
179172 case 'tools/call' : {
180173 // Get the API key from the request to forward to the workflow execute call
181- const apiKey = request . headers . get ( 'X-API-Key' ) || request . headers . get ( 'Authorization' ) ?. replace ( 'Bearer ' , '' )
174+ const apiKey =
175+ request . headers . get ( 'X-API-Key' ) ||
176+ request . headers . get ( 'Authorization' ) ?. replace ( 'Bearer ' , '' )
182177 return handleToolsCall ( rpcRequest , serverId , auth . userId , server . workspaceId , apiKey )
183178 }
184179
@@ -193,10 +188,7 @@ export async function POST(
193188 }
194189 } catch ( error ) {
195190 logger . error ( 'Error handling MCP request:' , error )
196- return NextResponse . json (
197- createJsonRpcError ( 0 , - 32603 , 'Internal error' ) ,
198- { status : 500 }
199- )
191+ return NextResponse . json ( createJsonRpcError ( 0 , - 32603 , 'Internal error' ) , { status : 500 } )
200192 }
201193}
202194
@@ -236,15 +228,12 @@ async function handleToolsList(
236228 } ,
237229 } ) )
238230
239- return NextResponse . json (
240- createJsonRpcResponse ( rpcRequest . id , { tools : mcpTools } )
241- )
231+ return NextResponse . json ( createJsonRpcResponse ( rpcRequest . id , { tools : mcpTools } ) )
242232 } catch ( error ) {
243233 logger . error ( 'Error listing tools:' , error )
244- return NextResponse . json (
245- createJsonRpcError ( rpcRequest . id , - 32603 , 'Failed to list tools' ) ,
246- { status : 500 }
247- )
234+ return NextResponse . json ( createJsonRpcError ( rpcRequest . id , - 32603 , 'Failed to list tools' ) , {
235+ status : 500 ,
236+ } )
248237 }
249238}
250239
@@ -259,7 +248,9 @@ async function handleToolsCall(
259248 apiKey ?: string | null
260249) : Promise < NextResponse > {
261250 try {
262- const params = rpcRequest . params as { name : string ; arguments ?: Record < string , unknown > } | undefined
251+ const params = rpcRequest . params as
252+ | { name : string ; arguments ?: Record < string , unknown > }
253+ | undefined
263254
264255 if ( ! params ?. name ) {
265256 return NextResponse . json (
@@ -318,7 +309,7 @@ async function handleToolsCall(
318309 const executeHeaders : Record < string , string > = {
319310 'Content-Type' : 'application/json' ,
320311 }
321-
312+
322313 // Forward the API key for authentication
323314 if ( apiKey ) {
324315 executeHeaders [ 'X-API-Key' ] = apiKey
@@ -362,9 +353,8 @@ async function handleToolsCall(
362353 )
363354 } catch ( error ) {
364355 logger . error ( 'Error calling tool:' , error )
365- return NextResponse . json (
366- createJsonRpcError ( rpcRequest . id , - 32603 , 'Tool execution failed' ) ,
367- { status : 500 }
368- )
356+ return NextResponse . json ( createJsonRpcError ( rpcRequest . id , - 32603 , 'Tool execution failed' ) , {
357+ status : 500 ,
358+ } )
369359 }
370360}
0 commit comments