@superinterface/server 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_btwyo7 +1 -1
  5. package/.next/fallback-build-manifest.json +2 -2
  6. package/.next/server/app/_not-found.html +1 -1
  7. package/.next/server/app/_not-found.rsc +1 -1
  8. package/.next/server/app/api/api-keys/[apiKeyId]/route.js +1 -1
  9. package/.next/server/app/api/api-keys/[apiKeyId]/route.js.nft.json +1 -1
  10. package/.next/server/app/api/api-keys/route.js +1 -1
  11. package/.next/server/app/api/api-keys/route.js.nft.json +1 -1
  12. package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js +1 -1
  13. package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js.nft.json +1 -1
  14. package/.next/server/app/api/assistants/[assistantId]/functions/route.js +1 -1
  15. package/.next/server/app/api/assistants/[assistantId]/functions/route.js.nft.json +1 -1
  16. package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js +1 -1
  17. package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js.nft.json +1 -1
  18. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +1 -1
  19. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js.nft.json +1 -1
  20. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js +1 -1
  21. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js.nft.json +1 -1
  22. package/.next/server/app/api/assistants/[assistantId]/route.js +1 -1
  23. package/.next/server/app/api/assistants/[assistantId]/route.js.nft.json +1 -1
  24. package/.next/server/app/api/assistants/route.js +1 -1
  25. package/.next/server/app/api/assistants/route.js.nft.json +1 -1
  26. package/.next/server/app/api/files/[fileId]/contents/route.js +1 -1
  27. package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
  28. package/.next/server/app/api/files/route.js +1 -1
  29. package/.next/server/app/api/files/route.js.nft.json +1 -1
  30. package/.next/server/app/api/messages/route.js +1 -1
  31. package/.next/server/app/api/messages/route.js.nft.json +1 -1
  32. package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js +1 -1
  33. package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js.nft.json +1 -1
  34. package/.next/server/app/api/providers/[modelProviderId]/models/route.js +1 -1
  35. package/.next/server/app/api/providers/[modelProviderId]/models/route.js.nft.json +1 -1
  36. package/.next/server/app/api/providers/[modelProviderId]/route.js +1 -1
  37. package/.next/server/app/api/providers/[modelProviderId]/route.js.nft.json +1 -1
  38. package/.next/server/app/api/providers/route.js +1 -1
  39. package/.next/server/app/api/providers/route.js.nft.json +1 -1
  40. package/.next/server/app/api/tasks/[taskId]/route.js +1 -1
  41. package/.next/server/app/api/tasks/[taskId]/route.js.nft.json +1 -1
  42. package/.next/server/app/api/tasks/callback/route.js +1 -1
  43. package/.next/server/app/api/tasks/callback/route.js.nft.json +1 -1
  44. package/.next/server/app/api/tasks/route.js +1 -1
  45. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  46. package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js +1 -1
  47. package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js.nft.json +1 -1
  48. package/.next/server/app/api/workspaces/[workspaceId]/route.js +1 -1
  49. package/.next/server/app/api/workspaces/[workspaceId]/route.js.nft.json +1 -1
  50. package/.next/server/app/api/workspaces/route.js +1 -1
  51. package/.next/server/app/api/workspaces/route.js.nft.json +1 -1
  52. package/.next/server/app/index.html +1 -1
  53. package/.next/server/app/index.rsc +1 -1
  54. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
  55. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
  60. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
  61. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
  62. package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
  63. package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js +1 -1
  65. package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js.map +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
  68. package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
  69. package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__47b17fad._.js +38 -0
  71. package/.next/server/chunks/[root-of-the-server]__47b17fad._.js.map +1 -0
  72. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
  73. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
  74. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
  75. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
  76. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
  77. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
  78. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
  79. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
  80. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
  81. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
  82. package/.next/server/chunks/[root-of-the-server]__676affb1._.js +1 -1
  83. package/.next/server/chunks/[root-of-the-server]__676affb1._.js.map +1 -1
  84. package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
  85. package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
  86. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
  87. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
  88. package/.next/server/chunks/[root-of-the-server]__a878c913._.js +1 -1
  89. package/.next/server/chunks/[root-of-the-server]__a878c913._.js.map +1 -1
  90. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
  91. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
  92. package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
  93. package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
  94. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
  95. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
  96. package/.next/server/chunks/[root-of-the-server]__f6f61507._.js +38 -0
  97. package/.next/server/chunks/[root-of-the-server]__f6f61507._.js.map +1 -0
  98. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
  99. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
  100. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
  101. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
  102. package/.next/server/functions-config-manifest.json +1 -8
  103. package/.next/server/pages/404.html +1 -1
  104. package/.next/server/pages/500.html +1 -1
  105. package/.next/trace +1 -1
  106. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts +52 -0
  107. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts.map +1 -0
  108. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.js +121 -0
  109. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +10 -21
  110. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
  111. package/dist/app/api/api-keys/[apiKeyId]/route.js +6 -125
  112. package/dist/app/api/api-keys/buildRoute.d.ts +32 -0
  113. package/dist/app/api/api-keys/buildRoute.d.ts.map +1 -0
  114. package/dist/app/api/api-keys/buildRoute.js +104 -0
  115. package/dist/app/api/api-keys/builders.d.ts +31 -0
  116. package/dist/app/api/api-keys/builders.d.ts.map +1 -0
  117. package/dist/app/api/api-keys/builders.js +109 -0
  118. package/dist/app/api/api-keys/route.d.ts +5 -13
  119. package/dist/app/api/api-keys/route.d.ts.map +1 -1
  120. package/dist/app/api/api-keys/route.js +8 -108
  121. package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts +120 -0
  122. package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts.map +1 -0
  123. package/dist/app/api/assistants/[assistantId]/buildRoute.js +226 -0
  124. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts +167 -0
  125. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts.map +1 -0
  126. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.js +184 -0
  127. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +10 -21
  128. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
  129. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +6 -191
  130. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts +114 -0
  131. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts.map +1 -0
  132. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.js +117 -0
  133. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +7 -15
  134. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
  135. package/dist/app/api/assistants/[assistantId]/functions/route.js +5 -122
  136. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts +40 -0
  137. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts.map +1 -0
  138. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.js +85 -0
  139. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +7 -15
  140. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
  141. package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +5 -90
  142. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts +89 -0
  143. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts.map +1 -0
  144. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.js +167 -0
  145. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +10 -21
  146. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
  147. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +6 -174
  148. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts +62 -0
  149. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts.map +1 -0
  150. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.js +115 -0
  151. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +7 -15
  152. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
  153. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +5 -120
  154. package/dist/app/api/assistants/[assistantId]/route.d.ts +11 -22
  155. package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
  156. package/dist/app/api/assistants/[assistantId]/route.js +6 -233
  157. package/dist/app/api/assistants/buildRoute.d.ts +121 -0
  158. package/dist/app/api/assistants/buildRoute.d.ts.map +1 -0
  159. package/dist/app/api/assistants/buildRoute.js +144 -0
  160. package/dist/app/api/assistants/route.d.ts +7 -13
  161. package/dist/app/api/assistants/route.d.ts.map +1 -1
  162. package/dist/app/api/assistants/route.js +6 -148
  163. package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts +18 -0
  164. package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts.map +1 -0
  165. package/dist/app/api/files/[fileId]/contents/buildRoute.js +81 -0
  166. package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -13
  167. package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
  168. package/dist/app/api/files/[fileId]/contents/route.js +4 -84
  169. package/dist/app/api/files/buildRoute.d.ts +14 -0
  170. package/dist/app/api/files/buildRoute.d.ts.map +1 -0
  171. package/dist/app/api/files/buildRoute.js +88 -0
  172. package/dist/app/api/files/route.d.ts +4 -10
  173. package/dist/app/api/files/route.d.ts.map +1 -1
  174. package/dist/app/api/files/route.js +4 -91
  175. package/dist/app/api/messages/buildRoute.d.ts +34 -0
  176. package/dist/app/api/messages/buildRoute.d.ts.map +1 -0
  177. package/dist/app/api/messages/buildRoute.js +607 -0
  178. package/dist/app/api/messages/lib/initialMessagesResponse.d.ts.map +1 -1
  179. package/dist/app/api/messages/lib/initialMessagesResponse.js +1 -1
  180. package/dist/app/api/messages/route.d.ts +10 -22
  181. package/dist/app/api/messages/route.d.ts.map +1 -1
  182. package/dist/app/api/messages/route.js +6 -612
  183. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts +24 -0
  184. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts.map +1 -0
  185. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.js +43 -0
  186. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +4 -9
  187. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
  188. package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -46
  189. package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts +61 -0
  190. package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts.map +1 -0
  191. package/dist/app/api/providers/[modelProviderId]/buildRoute.js +134 -0
  192. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts +19 -0
  193. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts.map +1 -0
  194. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.js +43 -0
  195. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +4 -9
  196. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
  197. package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -46
  198. package/dist/app/api/providers/[modelProviderId]/route.d.ts +10 -21
  199. package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
  200. package/dist/app/api/providers/[modelProviderId]/route.js +6 -141
  201. package/dist/app/api/providers/buildRoute.d.ts +38 -0
  202. package/dist/app/api/providers/buildRoute.d.ts.map +1 -0
  203. package/dist/app/api/providers/buildRoute.js +75 -0
  204. package/dist/app/api/providers/route.d.ts +5 -13
  205. package/dist/app/api/providers/route.d.ts.map +1 -1
  206. package/dist/app/api/providers/route.js +5 -80
  207. package/dist/app/api/tasks/[taskId]/buildRoute.d.ts +19 -0
  208. package/dist/app/api/tasks/[taskId]/buildRoute.d.ts.map +1 -0
  209. package/dist/app/api/tasks/[taskId]/buildRoute.js +125 -0
  210. package/dist/app/api/tasks/[taskId]/route.d.ts +7 -57
  211. package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
  212. package/dist/app/api/tasks/[taskId]/route.js +6 -144
  213. package/dist/app/api/tasks/buildRoute.d.ts +36 -0
  214. package/dist/app/api/tasks/buildRoute.d.ts.map +1 -0
  215. package/dist/app/api/tasks/buildRoute.js +85 -0
  216. package/dist/app/api/tasks/callback/buildRoute.d.ts +6 -0
  217. package/dist/app/api/tasks/callback/buildRoute.d.ts.map +1 -0
  218. package/dist/app/api/tasks/callback/buildRoute.js +244 -0
  219. package/dist/app/api/tasks/callback/route.d.ts +2 -1
  220. package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
  221. package/dist/app/api/tasks/callback/route.js +4 -244
  222. package/dist/app/api/tasks/route.d.ts +5 -13
  223. package/dist/app/api/tasks/route.d.ts.map +1 -1
  224. package/dist/app/api/tasks/route.js +5 -90
  225. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts +10 -0
  226. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts.map +1 -0
  227. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.js +36 -0
  228. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +2 -7
  229. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
  230. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +3 -37
  231. package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts +16 -0
  232. package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts.map +1 -0
  233. package/dist/app/api/workspaces/[workspaceId]/buildRoute.js +89 -0
  234. package/dist/app/api/workspaces/[workspaceId]/route.d.ts +5 -31
  235. package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
  236. package/dist/app/api/workspaces/[workspaceId]/route.js +5 -89
  237. package/dist/app/api/workspaces/buildRoute.d.ts +42 -0
  238. package/dist/app/api/workspaces/buildRoute.d.ts.map +1 -0
  239. package/dist/app/api/workspaces/buildRoute.js +78 -0
  240. package/dist/app/api/workspaces/route.d.ts +7 -27
  241. package/dist/app/api/workspaces/route.d.ts.map +1 -1
  242. package/dist/app/api/workspaces/route.js +6 -82
  243. package/dist/lib/functions/functionSchema.d.ts +56 -56
  244. package/dist/lib/functions/handleFunction/getFunction.d.ts +4 -4
  245. package/dist/lib/mcpServers/mcpServerSchema.d.ts +20 -20
  246. package/dist/lib/prisma/index.d.ts +2 -5
  247. package/dist/lib/prisma/index.d.ts.map +1 -1
  248. package/dist/lib/prisma/index.js +5 -70
  249. package/package.json +2 -2
  250. package/.next/server/chunks/[root-of-the-server]__228bff78._.js +0 -38
  251. package/.next/server/chunks/[root-of-the-server]__228bff78._.js.map +0 -1
  252. package/.next/server/chunks/[root-of-the-server]__3307123c._.js +0 -38
  253. package/.next/server/chunks/[root-of-the-server]__3307123c._.js.map +0 -1
  254. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js +0 -38
  255. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js.map +0 -1
  256. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js +0 -38
  257. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js.map +0 -1
  258. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js +0 -38
  259. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js.map +0 -1
  260. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js +0 -38
  261. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js.map +0 -1
  262. package/.next/server/chunks/[root-of-the-server]__ff90af03._.js +0 -38
  263. package/.next/server/chunks/[root-of-the-server]__ff90af03._.js.map +0 -1
  264. /package/.next/static/{X1k4ISA6YteJsnJalPLxm → KhKDqyqUf75vkMRrXaWJf}/_buildManifest.js +0 -0
  265. /package/.next/static/{X1k4ISA6YteJsnJalPLxm → KhKDqyqUf75vkMRrXaWJf}/_clientMiddlewareManifest.json +0 -0
  266. /package/.next/static/{X1k4ISA6YteJsnJalPLxm → KhKDqyqUf75vkMRrXaWJf}/_ssgManifest.js +0 -0
@@ -0,0 +1,167 @@
1
+ import { headers } from 'next/headers';
2
+ import { ApiKeyType, TransportType } from '@prisma/client';
3
+ import { NextResponse } from 'next/server';
4
+ import { cacheHeaders } from '../../../../../../lib/cache/cacheHeaders';
5
+ import { getApiKey } from '../../../../../../lib/apiKeys/getApiKey';
6
+ import { validate } from 'uuid';
7
+ import { serializeApiMcpServer } from '../../../../../../lib/mcpServers/serializeApiMcpServer';
8
+ import { mcpServerSchema } from '../../../../../../lib/mcpServers/mcpServerSchema';
9
+ const validateIds = ({ assistantId, mcpServerId, }) => {
10
+ if (!validate(assistantId)) {
11
+ return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
12
+ }
13
+ if (!validate(mcpServerId)) {
14
+ return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
15
+ }
16
+ return null;
17
+ };
18
+ export const buildGET = ({ prisma }) => async (_request, props) => {
19
+ const { assistantId, mcpServerId } = await props.params;
20
+ const headersList = await headers();
21
+ const authorization = headersList.get('authorization');
22
+ if (!authorization) {
23
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
24
+ }
25
+ const privateApiKey = await getApiKey({
26
+ type: ApiKeyType.PRIVATE,
27
+ authorization,
28
+ prisma,
29
+ });
30
+ if (!privateApiKey) {
31
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
32
+ }
33
+ const validationError = validateIds({ assistantId, mcpServerId });
34
+ if (validationError)
35
+ return validationError;
36
+ const mcpServer = await prisma.mcpServer.findFirst({
37
+ where: {
38
+ id: mcpServerId,
39
+ assistant: {
40
+ id: assistantId,
41
+ workspaceId: privateApiKey.workspaceId,
42
+ },
43
+ },
44
+ include: {
45
+ sseTransport: true,
46
+ httpTransport: true,
47
+ },
48
+ });
49
+ if (!mcpServer) {
50
+ return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
51
+ }
52
+ return NextResponse.json({
53
+ mcpServer: serializeApiMcpServer({ mcpServer }),
54
+ }, { headers: cacheHeaders });
55
+ };
56
+ export const buildPATCH = ({ prisma }) => async (request, props) => {
57
+ const { assistantId, mcpServerId } = await props.params;
58
+ const headersList = await headers();
59
+ const authorization = headersList.get('authorization');
60
+ if (!authorization) {
61
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
62
+ }
63
+ const privateApiKey = await getApiKey({
64
+ authorization,
65
+ type: ApiKeyType.PRIVATE,
66
+ prisma,
67
+ });
68
+ if (!privateApiKey) {
69
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
70
+ }
71
+ const validationError = validateIds({ assistantId, mcpServerId });
72
+ if (validationError)
73
+ return validationError;
74
+ const body = await request.json();
75
+ const parsed = mcpServerSchema.safeParse(body);
76
+ if (!parsed.success) {
77
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
78
+ }
79
+ const { transportType, sseTransport, httpTransport } = parsed.data;
80
+ const mcpServer = await prisma.mcpServer.findFirst({
81
+ where: {
82
+ id: mcpServerId,
83
+ assistant: {
84
+ id: assistantId,
85
+ workspaceId: privateApiKey.workspaceId,
86
+ },
87
+ },
88
+ });
89
+ if (!mcpServer) {
90
+ return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
91
+ }
92
+ const updatedMcpServer = await prisma.mcpServer.update({
93
+ where: {
94
+ id: mcpServerId,
95
+ },
96
+ data: Object.assign(Object.assign({ transportType }, (transportType === TransportType.SSE
97
+ ? {
98
+ sseTransport: {
99
+ update: {
100
+ url: sseTransport.url,
101
+ headers: JSON.parse(sseTransport.headers),
102
+ },
103
+ },
104
+ }
105
+ : {})), (transportType === TransportType.HTTP
106
+ ? {
107
+ httpTransport: {
108
+ update: {
109
+ url: httpTransport.url,
110
+ headers: JSON.parse(httpTransport.headers),
111
+ },
112
+ },
113
+ }
114
+ : {})),
115
+ include: {
116
+ sseTransport: true,
117
+ httpTransport: true,
118
+ },
119
+ });
120
+ return NextResponse.json({
121
+ mcpServer: serializeApiMcpServer({ mcpServer: updatedMcpServer }),
122
+ }, { headers: cacheHeaders });
123
+ };
124
+ export const buildDELETE = ({ prisma }) => async (_request, props) => {
125
+ const { assistantId, mcpServerId } = await props.params;
126
+ const headersList = await headers();
127
+ const authorization = headersList.get('authorization');
128
+ if (!authorization) {
129
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
130
+ }
131
+ const privateApiKey = await getApiKey({
132
+ authorization,
133
+ type: ApiKeyType.PRIVATE,
134
+ prisma,
135
+ });
136
+ if (!privateApiKey) {
137
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
138
+ }
139
+ const validationError = validateIds({ assistantId, mcpServerId });
140
+ if (validationError)
141
+ return validationError;
142
+ const mcpServer = await prisma.mcpServer.findFirst({
143
+ where: {
144
+ id: mcpServerId,
145
+ assistant: {
146
+ id: assistantId,
147
+ workspaceId: privateApiKey.workspaceId,
148
+ },
149
+ },
150
+ });
151
+ if (!mcpServer) {
152
+ return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
153
+ }
154
+ const deletedMcpServer = await prisma.mcpServer.delete({
155
+ where: { id: mcpServerId },
156
+ include: {
157
+ sseTransport: true,
158
+ httpTransport: true,
159
+ },
160
+ });
161
+ return NextResponse.json({
162
+ mcpServer: serializeApiMcpServer({ mcpServer: deletedMcpServer }),
163
+ }, { headers: cacheHeaders });
164
+ };
165
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
166
+ headers: cacheHeaders,
167
+ });
@@ -1,15 +1,11 @@
1
- import { type PrismaClient } from '@prisma/client';
2
- import { NextResponse, type NextRequest } from 'next/server';
3
- export declare const buildGET: ({ prisma: providedPrisma }?: {
4
- prisma?: PrismaClient;
5
- }) => (_request: NextRequest, props: {
1
+ export declare const GET: (_request: import("next/server").NextRequest, props: {
6
2
  params: Promise<{
7
3
  assistantId: string;
8
4
  mcpServerId: string;
9
5
  }>;
10
- }) => Promise<NextResponse<{
6
+ }) => Promise<import("next/server").NextResponse<{
11
7
  error: string;
12
- }> | NextResponse<{
8
+ }> | import("next/server").NextResponse<{
13
9
  mcpServer: {
14
10
  id: string;
15
11
  transportType: import("@prisma/client").$Enums.TransportType;
@@ -31,17 +27,14 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
31
27
  updatedAt: string;
32
28
  };
33
29
  }>>;
34
- export declare const GET: ReturnType<typeof buildGET>;
35
- export declare const buildPATCH: ({ prisma: providedPrisma }?: {
36
- prisma?: PrismaClient;
37
- }) => (request: NextRequest, props: {
30
+ export declare const PATCH: (request: import("next/server").NextRequest, props: {
38
31
  params: Promise<{
39
32
  assistantId: string;
40
33
  mcpServerId: string;
41
34
  }>;
42
- }) => Promise<NextResponse<{
35
+ }) => Promise<import("next/server").NextResponse<{
43
36
  error: string;
44
- }> | NextResponse<{
37
+ }> | import("next/server").NextResponse<{
45
38
  mcpServer: {
46
39
  id: string;
47
40
  transportType: import("@prisma/client").$Enums.TransportType;
@@ -63,17 +56,14 @@ export declare const buildPATCH: ({ prisma: providedPrisma }?: {
63
56
  updatedAt: string;
64
57
  };
65
58
  }>>;
66
- export declare const PATCH: ReturnType<typeof buildPATCH>;
67
- export declare const buildDELETE: ({ prisma: providedPrisma }?: {
68
- prisma?: PrismaClient;
69
- }) => (_request: NextRequest, props: {
59
+ export declare const DELETE: (_request: import("next/server").NextRequest, props: {
70
60
  params: Promise<{
71
61
  assistantId: string;
72
62
  mcpServerId: string;
73
63
  }>;
74
- }) => Promise<NextResponse<{
64
+ }) => Promise<import("next/server").NextResponse<{
75
65
  error: string;
76
- }> | NextResponse<{
66
+ }> | import("next/server").NextResponse<{
77
67
  mcpServer: {
78
68
  id: string;
79
69
  transportType: import("@prisma/client").$Enums.TransportType;
@@ -95,6 +85,5 @@ export declare const buildDELETE: ({ prisma: providedPrisma }?: {
95
85
  updatedAt: string;
96
86
  };
97
87
  }>>;
98
- export declare const DELETE: ReturnType<typeof buildDELETE>;
99
- export declare const OPTIONS: () => NextResponse<{}>;
88
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
100
89
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ5D,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D;;;;;;;;;;;;;;;;;;;;;;;GAiEF,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,UAAU,GACpB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D;;;;;;;;;;;;;;;;;;;;;;;GAwGF,CAAA;AAEH,eAAO,MAAM,KAAK,EACU,UAAU,CAAC,OAAO,UAAU,CAAC,CAAA;AAEzD,eAAO,MAAM,WAAW,GACrB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D;;;;;;;;;;;;;;;;;;;;;;;GAqEF,CAAA;AAEH,eAAO,MAAM,MAAM,EACU,UAAU,CAAC,OAAO,WAAW,CAAC,CAAA;AAE3D,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAyB,CAAA;AAE3C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA0B,CAAA;AAE7C,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,174 +1,6 @@
1
- import { headers } from 'next/headers';
2
- import { ApiKeyType, TransportType } from '@prisma/client';
3
- import { NextResponse } from 'next/server';
4
- import { cacheHeaders } from '../../../../../../lib/cache/cacheHeaders';
5
- import { resolvePrisma } from '../../../../../../lib/prisma';
6
- import { getApiKey } from '../../../../../../lib/apiKeys/getApiKey';
7
- import { validate } from 'uuid';
8
- import { serializeApiMcpServer } from '../../../../../../lib/mcpServers/serializeApiMcpServer';
9
- import { mcpServerSchema } from '../../../../../../lib/mcpServers/mcpServerSchema';
10
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
11
- const prisma = resolvePrisma(providedPrisma);
12
- const { assistantId, mcpServerId } = await props.params;
13
- const headersList = await headers();
14
- const authorization = headersList.get('authorization');
15
- if (!authorization) {
16
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
17
- }
18
- const privateApiKey = await getApiKey({
19
- type: ApiKeyType.PRIVATE,
20
- authorization,
21
- prisma,
22
- });
23
- if (!privateApiKey) {
24
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
25
- }
26
- if (!validate(assistantId)) {
27
- return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
28
- }
29
- if (!validate(mcpServerId)) {
30
- return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
31
- }
32
- const mcpServer = await prisma.mcpServer.findFirst({
33
- where: {
34
- id: mcpServerId,
35
- assistant: {
36
- id: assistantId,
37
- workspaceId: privateApiKey.workspaceId,
38
- },
39
- },
40
- include: {
41
- sseTransport: true,
42
- httpTransport: true,
43
- },
44
- });
45
- if (!mcpServer) {
46
- return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
47
- }
48
- return NextResponse.json({
49
- mcpServer: serializeApiMcpServer({ mcpServer }),
50
- }, { headers: cacheHeaders });
51
- };
52
- export const GET = ((...args) => buildGET()(...args));
53
- export const buildPATCH = ({ prisma: providedPrisma } = {}) => async (request, props) => {
54
- const prisma = resolvePrisma(providedPrisma);
55
- const { assistantId, mcpServerId } = await props.params;
56
- const headersList = await headers();
57
- const authorization = headersList.get('authorization');
58
- if (!authorization) {
59
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
60
- }
61
- const privateApiKey = await getApiKey({
62
- authorization,
63
- type: ApiKeyType.PRIVATE,
64
- prisma,
65
- });
66
- if (!privateApiKey) {
67
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
68
- }
69
- if (!validate(assistantId)) {
70
- return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
71
- }
72
- if (!validate(mcpServerId)) {
73
- return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
74
- }
75
- const body = await request.json();
76
- const parsed = mcpServerSchema.safeParse(body);
77
- if (!parsed.success) {
78
- return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
79
- }
80
- const { transportType, sseTransport, httpTransport } = parsed.data;
81
- const mcpServer = await prisma.mcpServer.findFirst({
82
- where: {
83
- id: mcpServerId,
84
- assistant: {
85
- id: assistantId,
86
- workspaceId: privateApiKey.workspaceId,
87
- },
88
- },
89
- });
90
- if (!mcpServer) {
91
- return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
92
- }
93
- const updatedMcpServer = await prisma.mcpServer.update({
94
- where: {
95
- id: mcpServerId,
96
- },
97
- data: Object.assign(Object.assign({ transportType }, (transportType === TransportType.SSE
98
- ? {
99
- sseTransport: {
100
- update: {
101
- url: sseTransport.url,
102
- headers: JSON.parse(sseTransport.headers),
103
- },
104
- },
105
- }
106
- : {})), (transportType === TransportType.HTTP
107
- ? {
108
- httpTransport: {
109
- update: {
110
- url: httpTransport.url,
111
- headers: JSON.parse(httpTransport.headers),
112
- },
113
- },
114
- }
115
- : {})),
116
- include: {
117
- sseTransport: true,
118
- httpTransport: true,
119
- },
120
- });
121
- return NextResponse.json({
122
- mcpServer: serializeApiMcpServer({ mcpServer: updatedMcpServer }),
123
- }, { headers: cacheHeaders });
124
- };
125
- export const PATCH = ((...args) => buildPATCH()(...args));
126
- export const buildDELETE = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
127
- const prisma = resolvePrisma(providedPrisma);
128
- const { assistantId, mcpServerId } = await props.params;
129
- const headersList = await headers();
130
- const authorization = headersList.get('authorization');
131
- if (!authorization) {
132
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
133
- }
134
- const privateApiKey = await getApiKey({
135
- authorization,
136
- type: ApiKeyType.PRIVATE,
137
- prisma,
138
- });
139
- if (!privateApiKey) {
140
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
141
- }
142
- if (!validate(assistantId)) {
143
- return NextResponse.json({ error: 'Invalid assistant id' }, { status: 400 });
144
- }
145
- if (!validate(mcpServerId)) {
146
- return NextResponse.json({ error: 'Invalid MCP server id' }, { status: 400 });
147
- }
148
- const mcpServer = await prisma.mcpServer.findFirst({
149
- where: {
150
- id: mcpServerId,
151
- assistant: {
152
- id: assistantId,
153
- workspaceId: privateApiKey.workspaceId,
154
- },
155
- },
156
- });
157
- if (!mcpServer) {
158
- return NextResponse.json({ error: 'No MCP server found' }, { status: 400 });
159
- }
160
- const deletedMcpServer = await prisma.mcpServer.delete({
161
- where: { id: mcpServerId },
162
- include: {
163
- sseTransport: true,
164
- httpTransport: true,
165
- },
166
- });
167
- return NextResponse.json({
168
- mcpServer: serializeApiMcpServer({ mcpServer: deletedMcpServer }),
169
- }, { headers: cacheHeaders });
170
- };
171
- export const DELETE = ((...args) => buildDELETE()(...args));
172
- export const OPTIONS = () => NextResponse.json({}, {
173
- headers: cacheHeaders,
174
- });
1
+ import { prisma } from '../../../../../../lib/prisma';
2
+ import { buildDELETE, buildGET, buildOPTIONS, buildPATCH, } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const PATCH = buildPATCH({ prisma });
5
+ export const DELETE = buildDELETE({ prisma });
6
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,62 @@
1
+ import { type NextRequest, NextResponse } from 'next/server';
2
+ import { type PrismaClient } from '@prisma/client';
3
+ type RouteProps = {
4
+ params: Promise<{
5
+ assistantId: string;
6
+ }>;
7
+ };
8
+ export declare const buildGET: ({ prisma }: {
9
+ prisma: PrismaClient;
10
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<{
11
+ error: string;
12
+ }> | NextResponse<{
13
+ mcpServers: {
14
+ id: string;
15
+ transportType: import("@prisma/client").$Enums.TransportType;
16
+ sseTransport: {
17
+ id: string;
18
+ url: string;
19
+ headers: PrismaJson.SseTransportHeaders;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ } | null;
23
+ httpTransport: {
24
+ id: string;
25
+ url: string;
26
+ headers: PrismaJson.HttpTransportHeaders;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ } | null;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ }[];
33
+ }>>;
34
+ export declare const buildPOST: ({ prisma }: {
35
+ prisma: PrismaClient;
36
+ }) => (request: NextRequest, props: RouteProps) => Promise<NextResponse<{
37
+ error: string;
38
+ }> | NextResponse<{
39
+ mcpServer: {
40
+ id: string;
41
+ transportType: import("@prisma/client").$Enums.TransportType;
42
+ sseTransport: {
43
+ id: string;
44
+ url: string;
45
+ headers: PrismaJson.SseTransportHeaders;
46
+ createdAt: string;
47
+ updatedAt: string;
48
+ } | null;
49
+ httpTransport: {
50
+ id: string;
51
+ url: string;
52
+ headers: PrismaJson.HttpTransportHeaders;
53
+ createdAt: string;
54
+ updatedAt: string;
55
+ } | null;
56
+ createdAt: string;
57
+ updatedAt: string;
58
+ };
59
+ }>>;
60
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
61
+ export {};
62
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/buildRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAO7E,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC,CAAA;AAED,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;GAuD9C,CAAA;AAEH,eAAO,MAAM,SAAS,GACnB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;GAoF7C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
@@ -0,0 +1,115 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { ApiKeyType, TransportType } from '@prisma/client';
3
+ import { headers } from 'next/headers';
4
+ import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
+ import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
6
+ import { serializeApiMcpServer } from '../../../../../lib/mcpServers/serializeApiMcpServer';
7
+ import { mcpServerSchema } from '../../../../../lib/mcpServers/mcpServerSchema';
8
+ export const buildGET = ({ prisma }) => async (_request, props) => {
9
+ const { assistantId } = await props.params;
10
+ const headersList = await headers();
11
+ const authorization = headersList.get('authorization');
12
+ if (!authorization) {
13
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
14
+ }
15
+ const privateApiKey = await getApiKey({
16
+ type: ApiKeyType.PRIVATE,
17
+ authorization,
18
+ prisma,
19
+ });
20
+ if (!privateApiKey) {
21
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
22
+ }
23
+ const assistant = await prisma.assistant.findFirst({
24
+ where: {
25
+ id: assistantId,
26
+ workspaceId: privateApiKey.workspaceId,
27
+ },
28
+ include: {
29
+ mcpServers: {
30
+ include: {
31
+ stdioTransport: true,
32
+ sseTransport: true,
33
+ httpTransport: true,
34
+ },
35
+ orderBy: {
36
+ createdAt: 'desc',
37
+ },
38
+ },
39
+ },
40
+ });
41
+ if (!assistant) {
42
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
43
+ }
44
+ return NextResponse.json({
45
+ mcpServers: assistant.mcpServers.map((mcpServer) => serializeApiMcpServer({
46
+ mcpServer,
47
+ })),
48
+ }, { headers: cacheHeaders });
49
+ };
50
+ export const buildPOST = ({ prisma }) => async (request, props) => {
51
+ const { assistantId } = await props.params;
52
+ const headersList = await headers();
53
+ const authorization = headersList.get('authorization');
54
+ if (!authorization) {
55
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
56
+ }
57
+ const privateApiKey = await getApiKey({
58
+ authorization,
59
+ type: ApiKeyType.PRIVATE,
60
+ prisma,
61
+ });
62
+ if (!privateApiKey) {
63
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
64
+ }
65
+ const body = await request.json();
66
+ const parsed = mcpServerSchema.safeParse(body);
67
+ if (!parsed.success) {
68
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
69
+ }
70
+ const { transportType, sseTransport, httpTransport } = parsed.data;
71
+ const workspaceId = privateApiKey.workspaceId;
72
+ const assistant = await prisma.assistant.findFirst({
73
+ where: { id: assistantId, workspaceId },
74
+ });
75
+ if (!assistant) {
76
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
77
+ }
78
+ const mcpServer = await prisma.mcpServer.create({
79
+ data: Object.assign(Object.assign(Object.assign({ transportType }, (transportType === TransportType.SSE
80
+ ? {
81
+ sseTransport: {
82
+ create: {
83
+ url: sseTransport.url,
84
+ headers: JSON.parse(sseTransport.headers),
85
+ },
86
+ },
87
+ }
88
+ : {})), (transportType === TransportType.HTTP
89
+ ? {
90
+ httpTransport: {
91
+ create: {
92
+ url: httpTransport.url,
93
+ headers: JSON.parse(httpTransport.headers),
94
+ },
95
+ },
96
+ }
97
+ : {})), { assistant: {
98
+ connect: {
99
+ id: assistantId,
100
+ workspaceId,
101
+ },
102
+ } }),
103
+ include: {
104
+ stdioTransport: true,
105
+ sseTransport: true,
106
+ httpTransport: true,
107
+ },
108
+ });
109
+ return NextResponse.json({
110
+ mcpServer: serializeApiMcpServer({ mcpServer }),
111
+ }, { headers: cacheHeaders });
112
+ };
113
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
114
+ headers: cacheHeaders,
115
+ });
@@ -1,14 +1,10 @@
1
- import { type NextRequest, NextResponse } from 'next/server';
2
- import { type PrismaClient } from '@prisma/client';
3
- export declare const buildGET: ({ prisma: providedPrisma }?: {
4
- prisma?: PrismaClient;
5
- }) => (_request: NextRequest, props: {
1
+ export declare const GET: (_request: import("next/server").NextRequest, props: {
6
2
  params: Promise<{
7
3
  assistantId: string;
8
4
  }>;
9
- }) => Promise<NextResponse<{
5
+ }) => Promise<import("next/server").NextResponse<{
10
6
  error: string;
11
- }> | NextResponse<{
7
+ }> | import("next/server").NextResponse<{
12
8
  mcpServers: {
13
9
  id: string;
14
10
  transportType: import("@prisma/client").$Enums.TransportType;
@@ -30,16 +26,13 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
30
26
  updatedAt: string;
31
27
  }[];
32
28
  }>>;
33
- export declare const GET: ReturnType<typeof buildGET>;
34
- export declare const buildPOST: ({ prisma: providedPrisma }?: {
35
- prisma?: PrismaClient;
36
- }) => (request: NextRequest, props: {
29
+ export declare const POST: (request: import("next/server").NextRequest, props: {
37
30
  params: Promise<{
38
31
  assistantId: string;
39
32
  }>;
40
- }) => Promise<NextResponse<{
33
+ }) => Promise<import("next/server").NextResponse<{
41
34
  error: string;
42
- }> | NextResponse<{
35
+ }> | import("next/server").NextResponse<{
43
36
  mcpServer: {
44
37
  id: string;
45
38
  transportType: import("@prisma/client").$Enums.TransportType;
@@ -61,6 +54,5 @@ export declare const buildPOST: ({ prisma: providedPrisma }?: {
61
54
  updatedAt: string;
62
55
  };
63
56
  }>>;
64
- export declare const POST: ReturnType<typeof buildPOST>;
65
- export declare const OPTIONS: () => NextResponse<{}>;
57
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
66
58
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAQ7E,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;;;;;;;;;;;;;;;GAyDF,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,SAAS,GACnB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;;;;;;;;;;;;;;;GAsFF,CAAA;AAEH,eAAO,MAAM,IAAI,EACU,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA;AAEvD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/assistants/[assistantId]/mcp-servers/route.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAwB,CAAA;AAEzC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}