@12-apps/mcp 3.9.0 → 3.11.0
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.
- package/dist/chunk-WUNMAHQG.js +325 -0
- package/dist/chunk-WUNMAHQG.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/locales-eKE_OJw4.d.ts +64 -0
- package/dist/react/index.d.ts +29 -3
- package/dist/react/index.js +134 -4
- package/dist/react/index.js.map +1 -1
- package/package.json +5 -4
- package/src/en-US.ts +204 -0
- package/src/index.ts +12 -0
- package/src/locales.ts +58 -0
- package/src/react/ai-landing.tsx +2 -2
- package/src/react/ai-status-board.tsx +1 -1
- package/src/react/copy.ts +9 -1
- package/src/react/en-US.ts +125 -0
- package/src/react/index.ts +18 -0
- package/src/react/locales.ts +17 -0
- package/src/react/pt-BR.ts +2 -0
- package/dist/chunk-HRAQKMDC.js +0 -154
- package/dist/chunk-HRAQKMDC.js.map +0 -1
- package/dist/pt-BR-e1RnV2v8.d.ts +0 -25
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-7QVYU63E.js";
|
|
4
|
+
|
|
5
|
+
// src/pt-BR.ts
|
|
6
|
+
var CONNECTOR_TAIL = [
|
|
7
|
+
"Deixe OAuth Client ID e Client Secret em branco \u2014 n\xE3o \xE9 preciso gerar credenciais: a loja registra o conector automaticamente no primeiro acesso.",
|
|
8
|
+
"Confirme e clique em Connect: abre a tela de login da loja \u2014 entre com a SUA conta de lojista e autorize o acesso.",
|
|
9
|
+
"Pronto: ative o conector na conversa para o assistente consultar e operar a sua loja."
|
|
10
|
+
];
|
|
11
|
+
function chatgptConfigureStages(platformName) {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
id: "enable-dev-mode",
|
|
15
|
+
label: "enable developer mode",
|
|
16
|
+
link: {
|
|
17
|
+
url: "https://chatgpt.com/plugins#settings/Security",
|
|
18
|
+
label: "Abrir Seguran\xE7a e login"
|
|
19
|
+
},
|
|
20
|
+
steps: [
|
|
21
|
+
"Ative o Modo desenvolvedor em Settings \u203A Security and login (Seguran\xE7a e login)."
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "configurar",
|
|
26
|
+
label: "configurar",
|
|
27
|
+
link: {
|
|
28
|
+
url: "https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins",
|
|
29
|
+
label: "Criar o conector"
|
|
30
|
+
},
|
|
31
|
+
steps: [
|
|
32
|
+
"Isso vai abrir um popup para voc\xEA criar um plugin novo. Coloque como nome o nome da sua loja e, no campo MCP, o link copiado no passo anterior.",
|
|
33
|
+
'Marque a caixa "I understand and want to continue" \u2014 a OpenAI n\xE3o revisou este servidor MCP; ela avisa que sites podem tentar roubar seus dados ou induzir o modelo a a\xE7\xF5es indevidas, incluindo destruir dados.',
|
|
34
|
+
`Clique em "Sign in with ${platformName}" e entre com a sua conta de lojista para autorizar o acesso. Pronto: a conex\xE3o \xE9 registrada automaticamente.`
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
__name(chatgptConfigureStages, "chatgptConfigureStages");
|
|
40
|
+
function PT_BR_AI_HOST_GUIDES(platformName) {
|
|
41
|
+
const chatgptStages = chatgptConfigureStages(platformName);
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
id: "claude",
|
|
45
|
+
label: "Claude.ai",
|
|
46
|
+
brand: "claude",
|
|
47
|
+
kind: "No navegador",
|
|
48
|
+
link: {
|
|
49
|
+
url: "https://claude.ai/new?modal=add-custom-connector#settings/customize-connectors",
|
|
50
|
+
label: "Abrir os conectores do Claude"
|
|
51
|
+
},
|
|
52
|
+
docs: {
|
|
53
|
+
url: "https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai",
|
|
54
|
+
label: "documenta\xE7\xE3o oficial da Anthropic \u2014 conectores personalizados"
|
|
55
|
+
},
|
|
56
|
+
steps: [
|
|
57
|
+
"Clique no bot\xE3o acima (ou v\xE1 em Settings \u203A Customize \u203A Connectors) e escolha Add custom connector.",
|
|
58
|
+
"D\xEA um nome ao conector (ex.: o nome da sua loja) e cole a URL do servidor MCP da sua loja (copie acima) no campo de URL.",
|
|
59
|
+
...CONNECTOR_TAIL
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "claude-desktop",
|
|
64
|
+
label: "Claude Desktop",
|
|
65
|
+
brand: "claude",
|
|
66
|
+
kind: "Aplicativo (Windows/Mac)",
|
|
67
|
+
docs: {
|
|
68
|
+
url: "https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai",
|
|
69
|
+
label: "documenta\xE7\xE3o oficial da Anthropic \u2014 conectores personalizados"
|
|
70
|
+
},
|
|
71
|
+
steps: [
|
|
72
|
+
"Abra o Claude Desktop e v\xE1 em Settings (\u2699\uFE0F) \u203A Connectors.",
|
|
73
|
+
"Clique em Add custom connector e cole a URL do servidor MCP da sua loja (copie acima).",
|
|
74
|
+
...CONNECTOR_TAIL
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "chatgpt",
|
|
79
|
+
label: "ChatGPT",
|
|
80
|
+
brand: "openai",
|
|
81
|
+
kind: "No navegador",
|
|
82
|
+
link: {
|
|
83
|
+
url: "https://chatgpt.com/plugins",
|
|
84
|
+
label: "Abrir os plugins do ChatGPT"
|
|
85
|
+
},
|
|
86
|
+
docs: {
|
|
87
|
+
url: "https://developers.openai.com/apps-sdk/deploy/connect-chatgpt",
|
|
88
|
+
label: "documenta\xE7\xE3o oficial da OpenAI \u2014 conectar um servidor MCP ao ChatGPT"
|
|
89
|
+
},
|
|
90
|
+
configureStages: chatgptStages,
|
|
91
|
+
// Mirrors the flattened stage instructions so the MCP connect guide
|
|
92
|
+
// (`connectToChatGpt`) can never drift from what owners see in the wizard.
|
|
93
|
+
steps: chatgptStages.flatMap((stage) => stage.steps)
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "codex",
|
|
97
|
+
label: "Codex",
|
|
98
|
+
brand: "openai",
|
|
99
|
+
kind: "App / CLI de desenvolvedor",
|
|
100
|
+
link: {
|
|
101
|
+
url: "https://developers.openai.com/codex",
|
|
102
|
+
label: "Documenta\xE7\xE3o do Codex"
|
|
103
|
+
},
|
|
104
|
+
docs: {
|
|
105
|
+
url: "https://developers.openai.com/apps-sdk/deploy/connect-chatgpt",
|
|
106
|
+
label: "documenta\xE7\xE3o oficial da OpenAI \u2014 conectar um servidor MCP"
|
|
107
|
+
},
|
|
108
|
+
steps: [
|
|
109
|
+
"No Codex, abra as configura\xE7\xF5es de MCP (Settings \u203A MCP no app, ou o arquivo de configura\xE7\xE3o na CLI).",
|
|
110
|
+
"Adicione um servidor MCP e cole a URL do servidor MCP da sua loja (copie acima) como um conector remoto (HTTP).",
|
|
111
|
+
...CONNECTOR_TAIL
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
__name(PT_BR_AI_HOST_GUIDES, "PT_BR_AI_HOST_GUIDES");
|
|
117
|
+
var PT_BR_AI_CAPABILITIES = [
|
|
118
|
+
{
|
|
119
|
+
id: "orders",
|
|
120
|
+
title: "Acompanhe seus pedidos",
|
|
121
|
+
detail: '"Quais pedidos entraram hoje?"'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "inventory",
|
|
125
|
+
title: "Controle o estoque",
|
|
126
|
+
detail: '"Quanto ainda tenho do produto X? Registre a entrada de 20 unidades."'
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: "catalog",
|
|
130
|
+
title: "Gerencie o cat\xE1logo",
|
|
131
|
+
detail: "Crie e edite produtos e categorias conversando."
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "sales",
|
|
135
|
+
title: "Entenda suas vendas",
|
|
136
|
+
detail: '"Qual foi o faturamento da semana?"'
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
var PT_BR_AI_PERMISSION_MODEL = "O assistente age em seu nome, com exatamente as suas permiss\xF5es: ele pode fazer o que voc\xEA pode fazer na sua loja \u2014 nada al\xE9m disso. N\xE3o \xE9 preciso criar nenhuma chave ou credencial extra; a autoriza\xE7\xE3o usa o seu pr\xF3prio login.";
|
|
140
|
+
function PT_BR_AI_CONNECT_PROMPT(spec) {
|
|
141
|
+
return `Voc\xEA agora tem acesso ao conector MCP da minha loja. Fa\xE7a, nesta ordem:
|
|
142
|
+
1) Execute a ferramenta ${spec.announceTool} informando qual assistente voc\xEA \xE9 (host: "chatgpt", "claude" ou "codex") para registrar a conex\xE3o com a minha loja.
|
|
143
|
+
2) Execute a ferramenta ${spec.probeTool} para confirmar o acesso a ${spec.probeSubject}.
|
|
144
|
+
Se precisar do identificador da loja, me pergunte o ${spec.identifierName}.`;
|
|
145
|
+
}
|
|
146
|
+
__name(PT_BR_AI_CONNECT_PROMPT, "PT_BR_AI_CONNECT_PROMPT");
|
|
147
|
+
|
|
148
|
+
// src/en-US.ts
|
|
149
|
+
var CONNECTOR_TAIL2 = [
|
|
150
|
+
"Leave OAuth Client ID and Client Secret blank \u2014 there are no credentials to generate: the store registers the connector automatically on first access.",
|
|
151
|
+
"Confirm and click Connect: the store's sign-in screen opens \u2014 sign in with YOUR own owner account and authorise the access.",
|
|
152
|
+
"Done: enable the connector in the chat so the assistant can query and operate your store."
|
|
153
|
+
];
|
|
154
|
+
function chatgptConfigureStages2(platformName) {
|
|
155
|
+
return [
|
|
156
|
+
{
|
|
157
|
+
id: "enable-dev-mode",
|
|
158
|
+
label: "enable developer mode",
|
|
159
|
+
link: {
|
|
160
|
+
url: "https://chatgpt.com/plugins#settings/Security",
|
|
161
|
+
label: "Open Security and login"
|
|
162
|
+
},
|
|
163
|
+
steps: [
|
|
164
|
+
"Turn on Developer mode under Settings \u203A Security and login."
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "configurar",
|
|
169
|
+
label: "configure",
|
|
170
|
+
link: {
|
|
171
|
+
url: "https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins",
|
|
172
|
+
label: "Create the connector"
|
|
173
|
+
},
|
|
174
|
+
steps: [
|
|
175
|
+
"That opens a popup to create a new plugin. Give it your store's name, and put the link you copied in the previous step in the MCP field.",
|
|
176
|
+
'Tick "I understand and want to continue" \u2014 OpenAI has not reviewed this MCP server; they warn that sites may try to steal your data or push the model into harmful actions, including destroying data.',
|
|
177
|
+
`Click "Sign in with ${platformName}" and sign in with your owner account to authorise access. That is it: the connection is registered automatically.`
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
__name(chatgptConfigureStages2, "chatgptConfigureStages");
|
|
183
|
+
function EN_US_AI_HOST_GUIDES(platformName) {
|
|
184
|
+
const chatgptStages = chatgptConfigureStages2(platformName);
|
|
185
|
+
return [
|
|
186
|
+
{
|
|
187
|
+
id: "claude",
|
|
188
|
+
label: "Claude.ai",
|
|
189
|
+
brand: "claude",
|
|
190
|
+
kind: "In the browser",
|
|
191
|
+
link: {
|
|
192
|
+
url: "https://claude.ai/new?modal=add-custom-connector#settings/customize-connectors",
|
|
193
|
+
label: "Open Claude's connectors"
|
|
194
|
+
},
|
|
195
|
+
docs: {
|
|
196
|
+
url: "https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai",
|
|
197
|
+
label: "Anthropic's own documentation \u2014 custom connectors"
|
|
198
|
+
},
|
|
199
|
+
steps: [
|
|
200
|
+
"Click the button above (or go to Settings \u203A Customize \u203A Connectors) and choose Add custom connector.",
|
|
201
|
+
"Name the connector (your store's name works) and paste your store's MCP server URL (copy it above) into the URL field.",
|
|
202
|
+
...CONNECTOR_TAIL2
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: "claude-desktop",
|
|
207
|
+
label: "Claude Desktop",
|
|
208
|
+
brand: "claude",
|
|
209
|
+
kind: "App (Windows/Mac)",
|
|
210
|
+
docs: {
|
|
211
|
+
url: "https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai",
|
|
212
|
+
label: "Anthropic's own documentation \u2014 custom connectors"
|
|
213
|
+
},
|
|
214
|
+
steps: [
|
|
215
|
+
"Open Claude Desktop and go to Settings (\u2699\uFE0F) \u203A Connectors.",
|
|
216
|
+
"Click Add custom connector and paste your store's MCP server URL (copy it above).",
|
|
217
|
+
...CONNECTOR_TAIL2
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: "chatgpt",
|
|
222
|
+
label: "ChatGPT",
|
|
223
|
+
brand: "openai",
|
|
224
|
+
kind: "In the browser",
|
|
225
|
+
link: {
|
|
226
|
+
url: "https://chatgpt.com/plugins",
|
|
227
|
+
label: "Open ChatGPT's plugins"
|
|
228
|
+
},
|
|
229
|
+
docs: {
|
|
230
|
+
url: "https://developers.openai.com/apps-sdk/deploy/connect-chatgpt",
|
|
231
|
+
label: "OpenAI's own documentation \u2014 connecting an MCP server to ChatGPT"
|
|
232
|
+
},
|
|
233
|
+
configureStages: chatgptStages,
|
|
234
|
+
// Mirrors the flattened stage instructions so the MCP connect guide
|
|
235
|
+
// (`connectToChatGpt`) can never drift from what owners see in the wizard.
|
|
236
|
+
steps: chatgptStages.flatMap((stage) => stage.steps)
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
id: "codex",
|
|
240
|
+
label: "Codex",
|
|
241
|
+
brand: "openai",
|
|
242
|
+
kind: "Developer app / CLI",
|
|
243
|
+
link: {
|
|
244
|
+
url: "https://developers.openai.com/codex",
|
|
245
|
+
label: "Codex documentation"
|
|
246
|
+
},
|
|
247
|
+
docs: {
|
|
248
|
+
url: "https://developers.openai.com/apps-sdk/deploy/connect-chatgpt",
|
|
249
|
+
label: "OpenAI's own documentation \u2014 connecting an MCP server"
|
|
250
|
+
},
|
|
251
|
+
steps: [
|
|
252
|
+
"In Codex, open the MCP settings (Settings \u203A MCP in the app, or the config file on the CLI).",
|
|
253
|
+
"Add an MCP server and paste your store's MCP server URL (copy it above) as a remote (HTTP) connector.",
|
|
254
|
+
...CONNECTOR_TAIL2
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
__name(EN_US_AI_HOST_GUIDES, "EN_US_AI_HOST_GUIDES");
|
|
260
|
+
var EN_US_AI_CAPABILITIES = [
|
|
261
|
+
// The `detail` of each is a QUESTION a reader could paste verbatim, so it is
|
|
262
|
+
// written as one rather than described.
|
|
263
|
+
{
|
|
264
|
+
id: "orders",
|
|
265
|
+
title: "Follow your orders",
|
|
266
|
+
detail: '"Which orders came in today?"'
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
id: "inventory",
|
|
270
|
+
title: "Keep on top of stock",
|
|
271
|
+
detail: '"How much of product X is left? Record 20 units received."'
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: "catalog",
|
|
275
|
+
title: "Manage the catalog",
|
|
276
|
+
detail: "Create and edit products and categories by chatting."
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
id: "sales",
|
|
280
|
+
title: "Understand your sales",
|
|
281
|
+
detail: `"What was this week's revenue?"`
|
|
282
|
+
}
|
|
283
|
+
];
|
|
284
|
+
var EN_US_AI_PERMISSION_MODEL = "The assistant acts on your behalf with exactly your permissions: it can do what you can do in your store \u2014 and nothing beyond that. There is no key or extra credential to create; the authorisation uses your own login.";
|
|
285
|
+
function EN_US_AI_CONNECT_PROMPT(spec) {
|
|
286
|
+
return `You now have access to my store's MCP connector. Do the following, in order:
|
|
287
|
+
1) Run the ${spec.announceTool} tool, saying which assistant you are (host: "chatgpt", "claude" or "codex"), to register the connection with my store.
|
|
288
|
+
2) Run the ${spec.probeTool} tool to confirm access to ${spec.probeSubject}.
|
|
289
|
+
If you need the store identifier, ask me for the ${spec.identifierName}.`;
|
|
290
|
+
}
|
|
291
|
+
__name(EN_US_AI_CONNECT_PROMPT, "EN_US_AI_CONNECT_PROMPT");
|
|
292
|
+
|
|
293
|
+
// src/locales.ts
|
|
294
|
+
var AI_HOST_GUIDES = {
|
|
295
|
+
"pt-BR": PT_BR_AI_HOST_GUIDES,
|
|
296
|
+
"en-US": EN_US_AI_HOST_GUIDES
|
|
297
|
+
};
|
|
298
|
+
var AI_CONNECT_PROMPT = {
|
|
299
|
+
"pt-BR": PT_BR_AI_CONNECT_PROMPT,
|
|
300
|
+
"en-US": EN_US_AI_CONNECT_PROMPT
|
|
301
|
+
};
|
|
302
|
+
var AI_CAPABILITIES = {
|
|
303
|
+
"pt-BR": PT_BR_AI_CAPABILITIES,
|
|
304
|
+
"en-US": EN_US_AI_CAPABILITIES
|
|
305
|
+
};
|
|
306
|
+
var AI_PERMISSION_MODEL = {
|
|
307
|
+
"pt-BR": PT_BR_AI_PERMISSION_MODEL,
|
|
308
|
+
"en-US": EN_US_AI_PERMISSION_MODEL
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export {
|
|
312
|
+
PT_BR_AI_HOST_GUIDES,
|
|
313
|
+
PT_BR_AI_CAPABILITIES,
|
|
314
|
+
PT_BR_AI_PERMISSION_MODEL,
|
|
315
|
+
PT_BR_AI_CONNECT_PROMPT,
|
|
316
|
+
EN_US_AI_HOST_GUIDES,
|
|
317
|
+
EN_US_AI_CAPABILITIES,
|
|
318
|
+
EN_US_AI_PERMISSION_MODEL,
|
|
319
|
+
EN_US_AI_CONNECT_PROMPT,
|
|
320
|
+
AI_HOST_GUIDES,
|
|
321
|
+
AI_CONNECT_PROMPT,
|
|
322
|
+
AI_CAPABILITIES,
|
|
323
|
+
AI_PERMISSION_MODEL
|
|
324
|
+
};
|
|
325
|
+
//# sourceMappingURL=chunk-WUNMAHQG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pt-BR.ts","../src/en-US.ts","../src/locales.ts"],"sourcesContent":["import type {\n AiCapability,\n AiConnectPromptSpec,\n AiHostConfigureStage,\n AiHostGuide,\n AiPermissionModel,\n} from \"./guide\";\n\n/**\n * The pt-BR pack for the AI-integration surface — NAMED constants a host passes\n * by hand, never defaults (FUT-760).\n *\n * The filename is what exempts this file from the copy-portability gate:\n * Portuguese may ship, it may not be silent. Every sentence here is VERBATIM\n * what `guide.ts` used to compile in, so a host adopting it sees no change on\n * screen — what changes is that the walkthrough is chosen in a diff.\n *\n * The guides are DATA as much as copy: which assistants are offered, their\n * stage ids and brands. Both halves travel together because a step label and\n * the stage it labels are useless apart.\n */\n\nconst CONNECTOR_TAIL: readonly string[] = [\n \"Deixe OAuth Client ID e Client Secret em branco — não é preciso gerar credenciais: a loja registra o conector automaticamente no primeiro acesso.\",\n \"Confirme e clique em Connect: abre a tela de login da loja — entre com a SUA conta de lojista e autorize o acesso.\",\n \"Pronto: ative o conector na conversa para o assistente consultar e operar a sua loja.\",\n];\n\n/**\n * ChatGPT's two-stage configuration (Developer mode is now required before a\n * connector can be created). Stage 1 enables Developer mode in Security & login;\n * stage 2 creates the connector and signs in — which registers the connection on\n * the store side, so no prompt needs to be pasted afterwards.\n */\nfunction chatgptConfigureStages(\n platformName: string,\n): readonly AiHostConfigureStage[] {\n return [\n {\n id: \"enable-dev-mode\",\n label: \"enable developer mode\",\n link: {\n url: \"https://chatgpt.com/plugins#settings/Security\",\n label: \"Abrir Segurança e login\",\n },\n steps: [\n \"Ative o Modo desenvolvedor em Settings › Security and login (Segurança e login).\",\n ],\n },\n {\n id: \"configurar\",\n label: \"configurar\",\n link: {\n url: \"https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins\",\n label: \"Criar o conector\",\n },\n steps: [\n \"Isso vai abrir um popup para você criar um plugin novo. Coloque como nome o nome da sua loja e, no campo MCP, o link copiado no passo anterior.\",\n 'Marque a caixa \"I understand and want to continue\" — a OpenAI não revisou este servidor MCP; ela avisa que sites podem tentar roubar seus dados ou induzir o modelo a ações indevidas, incluindo destruir dados.',\n `Clique em \"Sign in with ${platformName}\" e entre com a sua conta de lojista para autorizar o acesso. Pronto: a conexão é registrada automaticamente.`,\n ],\n },\n ];\n}\n\n/**\n * The AI hosts a store owner can connect, in recommended order. Same OAuth flow\n * everywhere (the host drives it) — only the menu path differs per app.\n *\n * A FUNCTION of the platform's name, because one step is not generic: the\n * ChatGPT connector's consent screen shows an OAuth button labelled with\n * whoever operates the server, and the owner is told which button to click. It\n * used to name one particular STORE on one particular deployment — not even the\n * product, a tenant of it — so every other adopter instructed its owners to\n * click a button that does not exist.\n */\nexport function PT_BR_AI_HOST_GUIDES(platformName: string): readonly AiHostGuide[] {\n const chatgptStages = chatgptConfigureStages(platformName);\n return [\n {\n id: \"claude\",\n label: \"Claude.ai\",\n brand: \"claude\",\n kind: \"No navegador\",\n link: {\n url: \"https://claude.ai/new?modal=add-custom-connector#settings/customize-connectors\",\n label: \"Abrir os conectores do Claude\",\n },\n docs: {\n url: \"https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai\",\n label: \"documentação oficial da Anthropic — conectores personalizados\",\n },\n steps: [\n \"Clique no botão acima (ou vá em Settings › Customize › Connectors) e escolha Add custom connector.\",\n \"Dê um nome ao conector (ex.: o nome da sua loja) e cole a URL do servidor MCP da sua loja (copie acima) no campo de URL.\",\n ...CONNECTOR_TAIL,\n ],\n },\n {\n id: \"claude-desktop\",\n label: \"Claude Desktop\",\n brand: \"claude\",\n kind: \"Aplicativo (Windows/Mac)\",\n docs: {\n url: \"https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai\",\n label: \"documentação oficial da Anthropic — conectores personalizados\",\n },\n steps: [\n \"Abra o Claude Desktop e vá em Settings (⚙️) › Connectors.\",\n \"Clique em Add custom connector e cole a URL do servidor MCP da sua loja (copie acima).\",\n ...CONNECTOR_TAIL,\n ],\n },\n {\n id: \"chatgpt\",\n label: \"ChatGPT\",\n brand: \"openai\",\n kind: \"No navegador\",\n link: {\n url: \"https://chatgpt.com/plugins\",\n label: \"Abrir os plugins do ChatGPT\",\n },\n docs: {\n url: \"https://developers.openai.com/apps-sdk/deploy/connect-chatgpt\",\n label:\n \"documentação oficial da OpenAI — conectar um servidor MCP ao ChatGPT\",\n },\n configureStages: chatgptStages,\n // Mirrors the flattened stage instructions so the MCP connect guide\n // (`connectToChatGpt`) can never drift from what owners see in the wizard.\n steps: chatgptStages.flatMap((stage) => stage.steps),\n },\n {\n id: \"codex\",\n label: \"Codex\",\n brand: \"openai\",\n kind: \"App / CLI de desenvolvedor\",\n link: {\n url: \"https://developers.openai.com/codex\",\n label: \"Documentação do Codex\",\n },\n docs: {\n url: \"https://developers.openai.com/apps-sdk/deploy/connect-chatgpt\",\n label: \"documentação oficial da OpenAI — conectar um servidor MCP\",\n },\n steps: [\n \"No Codex, abra as configurações de MCP (Settings › MCP no app, ou o arquivo de configuração na CLI).\",\n \"Adicione um servidor MCP e cole a URL do servidor MCP da sua loja (copie acima) como um conector remoto (HTTP).\",\n ...CONNECTOR_TAIL,\n ],\n },\n ];\n}\n\nexport const PT_BR_AI_CAPABILITIES: readonly AiCapability[] = [\n {\n id: \"orders\",\n title: \"Acompanhe seus pedidos\",\n detail: '\"Quais pedidos entraram hoje?\"',\n },\n {\n id: \"inventory\",\n title: \"Controle o estoque\",\n detail:\n '\"Quanto ainda tenho do produto X? Registre a entrada de 20 unidades.\"',\n },\n {\n id: \"catalog\",\n title: \"Gerencie o catálogo\",\n detail: \"Crie e edite produtos e categorias conversando.\",\n },\n {\n id: \"sales\",\n title: \"Entenda suas vendas\",\n detail: '\"Qual foi o faturamento da semana?\"',\n },\n];\n\n/**\n * The permission model in one line, shown prominently: the assistant acts AS\n * the signed-in owner (auth-passthrough) — it can do exactly what the owner\n * can, nothing more, and no extra credential/API key is ever created.\n */\nexport const PT_BR_AI_PERMISSION_MODEL: AiPermissionModel =\n \"O assistente age em seu nome, com exatamente as suas permissões: ele pode fazer o que você pode fazer na sua loja — nada além disso. Não é preciso criar nenhuma chave ou credencial extra; a autorização usa o seu próprio login.\";\n\n/** The pt-BR paste-in prompt, built from the host's own tool names. */\nexport function PT_BR_AI_CONNECT_PROMPT(spec: AiConnectPromptSpec): string {\n return (\n \"Você agora tem acesso ao conector MCP da minha loja. Faça, nesta ordem:\\n\" +\n `1) Execute a ferramenta ${spec.announceTool} informando qual assistente você é (host: \"chatgpt\", \"claude\" ou \"codex\") para registrar a conexão com a minha loja.\\n` +\n `2) Execute a ferramenta ${spec.probeTool} para confirmar o acesso a ${spec.probeSubject}.\\n` +\n `Se precisar do identificador da loja, me pergunte o ${spec.identifierName}.`\n );\n}\n","import type {\n AiCapability,\n AiConnectPromptSpec,\n AiHostConfigureStage,\n AiHostGuide,\n AiPermissionModel,\n} from \"./guide\";\n\n/**\n * The en-US pack for the AI-integration surface — NAMED constants a host passes\n * by hand, never defaults.\n *\n * The guides are DATA as much as copy: which assistants are offered, their\n * stage ids, their brands and their LINKS. Both halves travel together because\n * a step label and the stage it labels are useless apart — and the parts that\n * are not words do not change between languages:\n *\n * - `id` and `brand` are the package's own keys, matched on by the component;\n * - the URLs point at Anthropic's and OpenAI's own pages;\n * - the UI labels a reader must FIND in those products stay in the product's\n * own English (`Add custom connector`, `Settings › Security and login`,\n * `Sign in with …`), which is the same rule that keeps a vendor's field name\n * untranslated everywhere else here.\n *\n * The pt-BR pack quotes those same labels in English for exactly this reason;\n * what differs between the two packs is the instruction around them.\n */\n\nconst CONNECTOR_TAIL: readonly string[] = [\n \"Leave OAuth Client ID and Client Secret blank — there are no credentials to generate: the store registers the connector automatically on first access.\",\n \"Confirm and click Connect: the store's sign-in screen opens — sign in with YOUR own owner account and authorise the access.\",\n \"Done: enable the connector in the chat so the assistant can query and operate your store.\",\n];\n\n/**\n * ChatGPT's two-stage configuration (Developer mode is now required before a\n * connector can be created). Stage 1 enables Developer mode in Security & login;\n * stage 2 creates the connector and signs in — which registers the connection on\n * the store side, so no prompt needs to be pasted afterwards.\n */\nfunction chatgptConfigureStages(\n platformName: string,\n): readonly AiHostConfigureStage[] {\n return [\n {\n id: \"enable-dev-mode\",\n label: \"enable developer mode\",\n link: {\n url: \"https://chatgpt.com/plugins#settings/Security\",\n label: \"Open Security and login\",\n },\n steps: [\n \"Turn on Developer mode under Settings › Security and login.\",\n ],\n },\n {\n id: \"configurar\",\n label: \"configure\",\n link: {\n url: \"https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins\",\n label: \"Create the connector\",\n },\n steps: [\n \"That opens a popup to create a new plugin. Give it your store's name, and put the link you copied in the previous step in the MCP field.\",\n 'Tick \"I understand and want to continue\" — OpenAI has not reviewed this MCP server; they warn that sites may try to steal your data or push the model into harmful actions, including destroying data.',\n `Click \"Sign in with ${platformName}\" and sign in with your owner account to authorise access. That is it: the connection is registered automatically.`,\n ],\n },\n ];\n}\n\n/**\n * The AI hosts a store owner can connect, in recommended order. Same OAuth flow\n * everywhere (the host drives it) — only the menu path differs per app.\n *\n * A FUNCTION of the platform's name, because one step is not generic: the\n * ChatGPT connector's consent screen shows an OAuth button labelled with\n * whoever operates the server, and the owner is told which button to click. It\n * used to name one particular STORE on one particular deployment — not even the\n * product, a tenant of it — so every other adopter instructed its owners to\n * click a button that does not exist.\n */\nexport function EN_US_AI_HOST_GUIDES(platformName: string): readonly AiHostGuide[] {\n const chatgptStages = chatgptConfigureStages(platformName);\n return [\n {\n id: \"claude\",\n label: \"Claude.ai\",\n brand: \"claude\",\n kind: \"In the browser\",\n link: {\n url: \"https://claude.ai/new?modal=add-custom-connector#settings/customize-connectors\",\n label: \"Open Claude's connectors\",\n },\n docs: {\n url: \"https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai\",\n label: \"Anthropic's own documentation — custom connectors\",\n },\n steps: [\n \"Click the button above (or go to Settings › Customize › Connectors) and choose Add custom connector.\",\n \"Name the connector (your store's name works) and paste your store's MCP server URL (copy it above) into the URL field.\",\n ...CONNECTOR_TAIL,\n ],\n },\n {\n id: \"claude-desktop\",\n label: \"Claude Desktop\",\n brand: \"claude\",\n kind: \"App (Windows/Mac)\",\n docs: {\n url: \"https://support.anthropic.com/en/articles/11175166-how-do-i-connect-mcp-servers-to-claude-ai\",\n label: \"Anthropic's own documentation — custom connectors\",\n },\n steps: [\n \"Open Claude Desktop and go to Settings (⚙️) › Connectors.\",\n \"Click Add custom connector and paste your store's MCP server URL (copy it above).\",\n ...CONNECTOR_TAIL,\n ],\n },\n {\n id: \"chatgpt\",\n label: \"ChatGPT\",\n brand: \"openai\",\n kind: \"In the browser\",\n link: {\n url: \"https://chatgpt.com/plugins\",\n label: \"Open ChatGPT's plugins\",\n },\n docs: {\n url: \"https://developers.openai.com/apps-sdk/deploy/connect-chatgpt\",\n label: \"OpenAI's own documentation — connecting an MCP server to ChatGPT\",\n },\n configureStages: chatgptStages,\n // Mirrors the flattened stage instructions so the MCP connect guide\n // (`connectToChatGpt`) can never drift from what owners see in the wizard.\n steps: chatgptStages.flatMap((stage) => stage.steps),\n },\n {\n id: \"codex\",\n label: \"Codex\",\n brand: \"openai\",\n kind: \"Developer app / CLI\",\n link: {\n url: \"https://developers.openai.com/codex\",\n label: \"Codex documentation\",\n },\n docs: {\n url: \"https://developers.openai.com/apps-sdk/deploy/connect-chatgpt\",\n label: \"OpenAI's own documentation — connecting an MCP server\",\n },\n steps: [\n \"In Codex, open the MCP settings (Settings › MCP in the app, or the config file on the CLI).\",\n \"Add an MCP server and paste your store's MCP server URL (copy it above) as a remote (HTTP) connector.\",\n ...CONNECTOR_TAIL,\n ],\n },\n ];\n}\n\nexport const EN_US_AI_CAPABILITIES: readonly AiCapability[] = [\n // The `detail` of each is a QUESTION a reader could paste verbatim, so it is\n // written as one rather than described.\n {\n id: \"orders\",\n title: \"Follow your orders\",\n detail: '\"Which orders came in today?\"',\n },\n {\n id: \"inventory\",\n title: \"Keep on top of stock\",\n detail: '\"How much of product X is left? Record 20 units received.\"',\n },\n {\n id: \"catalog\",\n title: \"Manage the catalog\",\n detail: \"Create and edit products and categories by chatting.\",\n },\n {\n id: \"sales\",\n title: \"Understand your sales\",\n detail: '\"What was this week\\'s revenue?\"',\n },\n];\n\n/**\n * The permission model in one line, shown prominently: the assistant acts AS\n * the signed-in owner (auth-passthrough) — it can do exactly what the owner\n * can, nothing more, and no extra credential/API key is ever created.\n */\nexport const EN_US_AI_PERMISSION_MODEL: AiPermissionModel =\n \"The assistant acts on your behalf with exactly your permissions: it can do what you can do in your store — and nothing beyond that. There is no key or extra credential to create; the authorisation uses your own login.\";\n\n/** The en-US paste-in prompt, built from the host's own tool names. */\nexport function EN_US_AI_CONNECT_PROMPT(spec: AiConnectPromptSpec): string {\n // The TOOL NAMES are the host's own identifiers and are interpolated, never\n // translated: the assistant has to call them by the name they are registered\n // under, so a translated verb here is a prompt that does nothing.\n return (\n \"You now have access to my store's MCP connector. Do the following, in order:\\n\" +\n `1) Run the ${spec.announceTool} tool, saying which assistant you are (host: \"chatgpt\", \"claude\" or \"codex\"), to register the connection with my store.\\n` +\n `2) Run the ${spec.probeTool} tool to confirm access to ${spec.probeSubject}.\\n` +\n `If you need the store identifier, ask me for the ${spec.identifierName}.`\n );\n}\n","import {\n EN_US_AI_CAPABILITIES,\n EN_US_AI_CONNECT_PROMPT,\n EN_US_AI_HOST_GUIDES,\n EN_US_AI_PERMISSION_MODEL,\n} from \"./en-US\";\nimport type {\n AiCapability,\n AiConnectPromptSpec,\n AiHostGuide,\n AiPermissionModel,\n} from \"./guide\";\nimport {\n PT_BR_AI_CAPABILITIES,\n PT_BR_AI_CONNECT_PROMPT,\n PT_BR_AI_HOST_GUIDES,\n PT_BR_AI_PERMISSION_MODEL,\n} from \"./pt-BR\";\n\n/**\n * The AI-integration surface in both languages, keyed by tag — what a host\n * hands to `@12-apps/i18n` when the reader's language is a property of the\n * request rather than of the deployment.\n *\n * Two of these are FUNCTIONS rather than tables, and stay so:\n *\n * - `AI_HOST_GUIDES` takes the platform's name, because the ChatGPT consent\n * screen shows an OAuth button labelled with whoever operates the server and\n * the owner is told which button to click. It once named one particular\n * tenant of one deployment, so every other adopter instructed its owners to\n * click a button that does not exist.\n * - `AI_CONNECT_PROMPT` takes the host's own tool names, which the assistant\n * must call by the name they are registered under.\n *\n * `LocalePack` is mirrored here rather than imported so the package stays\n * liftable into a repo that has never heard of `@12-apps/i18n`.\n */\ntype LocalePack<T> = { readonly \"pt-BR\": T; readonly \"en-US\": T };\n\nexport const AI_HOST_GUIDES = {\n \"pt-BR\": PT_BR_AI_HOST_GUIDES,\n \"en-US\": EN_US_AI_HOST_GUIDES,\n} as const satisfies LocalePack<(platformName: string) => readonly AiHostGuide[]>;\n\nexport const AI_CONNECT_PROMPT = {\n \"pt-BR\": PT_BR_AI_CONNECT_PROMPT,\n \"en-US\": EN_US_AI_CONNECT_PROMPT,\n} as const satisfies LocalePack<(spec: AiConnectPromptSpec) => string>;\n\nexport const AI_CAPABILITIES = {\n \"pt-BR\": PT_BR_AI_CAPABILITIES,\n \"en-US\": EN_US_AI_CAPABILITIES,\n} as const satisfies LocalePack<readonly AiCapability[]>;\n\nexport const AI_PERMISSION_MODEL = {\n \"pt-BR\": PT_BR_AI_PERMISSION_MODEL,\n \"en-US\": EN_US_AI_PERMISSION_MODEL,\n} as const satisfies LocalePack<AiPermissionModel>;\n"],"mappings":";;;;;AAsBA,IAAM,iBAAoC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACF;AAQA,SAAS,uBACP,cACiC;AACjC,SAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,MAAM;AAAA,QACJ,KAAK;AAAA,QACL,OAAO;AAAA,MACT;AAAA,MACA,OAAO;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO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A,IACP,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AACF;AAOO,IAAM,4BACX;AAGK,SAAS,wBAAwB,MAAmC;AAIzE,SACE;AAAA,aACc,KAAK,YAAY;AAAA,aACjB,KAAK,SAAS,8BAA8B,KAAK,YAAY;AAAA,mDACvB,KAAK,cAAc;AAE3E;AAVgB;;;AC1JT,IAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,EACT,SAAS;AACX;AAEO,IAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,SAAS;AACX;AAEO,IAAM,kBAAkB;AAAA,EAC7B,SAAS;AAAA,EACT,SAAS;AACX;AAEO,IAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,SAAS;AACX;","names":["CONNECTOR_TAIL","chatgptConfigureStages"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { J as JsonSchema, G as GeneratedTool, D as DispatchConfig, a as Dispatch
|
|
|
2
2
|
export { A as AuthResolver, c as GenerateOptions, O as OpenApiDocument, d as OpenApiOperation, e as OpenApiParameter, f as OpenApiRequestBody, g as OpenApiResponse, P as ParameterLocation, h as ToolParameter, i as generateTools } from './generate-Dx3cK8th.js';
|
|
3
3
|
export { A as AiCapability, a as AiConnectPromptCopy, b as AiConnectPromptSpec, c as AiHostBrand, d as AiHostConfigureStage, e as AiHostGuide, f as AiHostLink, g as AiProvider, h as aiConnectPrompt, p as providerForHostId } from './guide-KQNcXlMG.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
export { P as PT_BR_AI_CAPABILITIES,
|
|
5
|
+
export { A as AI_CAPABILITIES, a as AI_CONNECT_PROMPT, b as AI_HOST_GUIDES, c as AI_PERMISSION_MODEL, E as EN_US_AI_CAPABILITIES, d as EN_US_AI_CONNECT_PROMPT, e as EN_US_AI_HOST_GUIDES, f as EN_US_AI_PERMISSION_MODEL, P as PT_BR_AI_CAPABILITIES, g as PT_BR_AI_CONNECT_PROMPT, h as PT_BR_AI_HOST_GUIDES, i as PT_BR_AI_PERMISSION_MODEL } from './locales-eKE_OJw4.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Raised when a JSON Schema cannot be turned into a flat, self-contained tool
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AI_CAPABILITIES,
|
|
3
|
+
AI_CONNECT_PROMPT,
|
|
4
|
+
AI_HOST_GUIDES,
|
|
5
|
+
AI_PERMISSION_MODEL,
|
|
6
|
+
EN_US_AI_CAPABILITIES,
|
|
7
|
+
EN_US_AI_CONNECT_PROMPT,
|
|
8
|
+
EN_US_AI_HOST_GUIDES,
|
|
9
|
+
EN_US_AI_PERMISSION_MODEL,
|
|
2
10
|
PT_BR_AI_CAPABILITIES,
|
|
3
11
|
PT_BR_AI_CONNECT_PROMPT,
|
|
4
12
|
PT_BR_AI_HOST_GUIDES,
|
|
5
13
|
PT_BR_AI_PERMISSION_MODEL
|
|
6
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-WUNMAHQG.js";
|
|
7
15
|
import {
|
|
8
16
|
aiConnectPrompt,
|
|
9
17
|
providerForHostId
|
|
@@ -356,7 +364,15 @@ async function handleMcpJsonRpc(request, registry, auth, options) {
|
|
|
356
364
|
}
|
|
357
365
|
__name(handleMcpJsonRpc, "handleMcpJsonRpc");
|
|
358
366
|
export {
|
|
367
|
+
AI_CAPABILITIES,
|
|
368
|
+
AI_CONNECT_PROMPT,
|
|
369
|
+
AI_HOST_GUIDES,
|
|
370
|
+
AI_PERMISSION_MODEL,
|
|
359
371
|
DispatchInputError,
|
|
372
|
+
EN_US_AI_CAPABILITIES,
|
|
373
|
+
EN_US_AI_CONNECT_PROMPT,
|
|
374
|
+
EN_US_AI_HOST_GUIDES,
|
|
375
|
+
EN_US_AI_PERMISSION_MODEL,
|
|
360
376
|
HTTP_STATUS_META_KEY,
|
|
361
377
|
MCP_PROTOCOL_VERSION,
|
|
362
378
|
PROTECTED_RESOURCE_METADATA_PATH,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/openapi/refs.ts","../src/dispatch/proxy.ts","../src/server/redact.ts","../src/server/registry.ts","../src/server/jsonrpc.ts"],"sourcesContent":["import type { JsonSchema } from \"../types\";\n\n/**\n * Raised when a JSON Schema cannot be turned into a flat, self-contained tool\n * input — an unresolvable `$ref`, an unsupported pointer, or a recursive schema.\n * The MCP tool surface is deliberately finite and flat (it is handed to an LLM\n * and committed to the drift manifest), so recursion is rejected rather than\n * silently truncated.\n */\nexport class UnsupportedSchemaError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"UnsupportedSchemaError\";\n }\n}\n\n/** Local-definition containers a `$ref` may point into, in resolution order. */\nconst REF_PREFIXES = [\"#/$defs/\", \"#/definitions/\", \"#/components/schemas/\"] as const;\nconst DEF_CONTAINERS = [\"$defs\", \"definitions\"] as const;\n\n/** The definition name a supported local pointer targets, or `null` if unsupported. */\nfunction refName(ref: string): string | null {\n const prefix = REF_PREFIXES.find((candidate) => ref.startsWith(candidate));\n return prefix ? decodeURIComponent(ref.slice(prefix.length)) : null;\n}\n\n/** Collect the `$defs`/`definitions` maps hoisted onto a schema root into one lookup. */\nfunction collectDefs(root: JsonSchema): Record<string, JsonSchema> {\n const defs: Record<string, JsonSchema> = {};\n DEF_CONTAINERS.forEach((key) => {\n const container = root[key];\n if (container && typeof container === \"object\") {\n Object.assign(defs, container as Record<string, JsonSchema>);\n }\n });\n return defs;\n}\n\nfunction inlineRef(\n ref: string,\n defs: Record<string, JsonSchema>,\n active: Set<string>,\n): unknown {\n const name = refName(ref);\n if (name === null) throw new UnsupportedSchemaError(`Unsupported $ref pointer: ${ref}`);\n const target = defs[name];\n if (!target) throw new UnsupportedSchemaError(`Unresolved $ref: ${ref}`);\n if (active.has(name)) throw new UnsupportedSchemaError(`Recursive schema not supported: ${name}`);\n active.add(name);\n const resolved = walk(target, defs, active);\n active.delete(name);\n return resolved;\n}\n\n/** Deep-copy `node`, inlining every `$ref` and stripping definition containers. */\nfunction walk(node: unknown, defs: Record<string, JsonSchema>, active: Set<string>): unknown {\n if (Array.isArray(node)) return node.map((item) => walk(item, defs, active));\n if (!node || typeof node !== \"object\") return node;\n\n const obj = node as Record<string, unknown>;\n if (typeof obj.$ref === \"string\") return inlineRef(obj.$ref, defs, active);\n\n const out: Record<string, unknown> = {};\n Object.entries(obj).forEach(([key, value]) => {\n if (!DEF_CONTAINERS.includes(key as (typeof DEF_CONTAINERS)[number])) {\n out[key] = walk(value, defs, active);\n }\n });\n return out;\n}\n\n/**\n * Inline every local `$ref` in a JSON Schema and drop the now-empty `$defs`/\n * `definitions` containers, yielding a flat, self-contained schema. Diamond reuse\n * (the same definition referenced by sibling branches) is fine; only a true cycle\n * — a definition that references itself up the resolution stack — is rejected.\n *\n * A schema with no `$ref`/definitions is returned structurally unchanged, so\n * inlining an already-flat spec is a no-op (the drift gate stays a stable diff).\n */\nexport function inlineSchemaRefs(schema: JsonSchema): JsonSchema {\n const defs = collectDefs(schema);\n return walk(schema, defs, new Set<string>()) as JsonSchema;\n}\n","import type { DispatchConfig, DispatchResult, GeneratedTool } from \"../types\";\n\n/** Raised when tool arguments cannot be routed onto the HTTP request. */\nexport class DispatchInputError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DispatchInputError\";\n }\n}\n\n/** Expand a path template (`/products/{id}`) using the path args, URL-encoding each. */\nfunction expandPath(\n tool: GeneratedTool,\n args: Record<string, unknown>,\n): string {\n return tool.path.replace(/\\{([^}]+)\\}/g, (_match, key: string) => {\n const value = args[key];\n if (value === undefined || value === null) {\n throw new DispatchInputError(`Missing required path parameter: ${key}`);\n }\n return encodeURIComponent(String(value));\n });\n}\n\n/**\n * Route the non-path parameters (query + header) from the flat args. A missing\n * required parameter is a hard error; a missing optional one is simply omitted.\n */\nfunction routeParams(\n tool: GeneratedTool,\n args: Record<string, unknown>,\n): { query: URLSearchParams; headers: Record<string, string> } {\n const query = new URLSearchParams();\n const headers: Record<string, string> = {};\n\n tool.parameters\n .filter((param) => param.in !== \"path\")\n .forEach((param) => {\n const value = args[param.name];\n if (value === undefined || value === null) {\n if (param.required) {\n throw new DispatchInputError(`Missing required ${param.in} parameter: ${param.name}`);\n }\n return;\n }\n if (param.in === \"query\") query.set(param.name, String(value));\n else headers[param.name] = String(value);\n });\n\n return { query, headers };\n}\n\n/**\n * Reconstruct the request body from the flat args using the routing metadata.\n * Anything not claimed by a known body property is dropped — the input schema is\n * `additionalProperties: false`, so a validated call never carries extras and an\n * unvalidated one cannot smuggle fields upstream.\n */\nfunction routeBody(tool: GeneratedTool, args: Record<string, unknown>): unknown {\n if (tool.bodyIsWhole) return args.body;\n if (!tool.bodyProps.length) return undefined;\n const payload: Record<string, unknown> = {};\n tool.bodyProps.forEach((key) => {\n if (args[key] !== undefined) payload[key] = args[key];\n });\n return Object.keys(payload).length ? payload : undefined;\n}\n\n/**\n * Execute one generated tool by proxying to its HTTP endpoint, forwarding the\n * caller's bearer verbatim. This function performs NO authorization — the\n * endpoint does, exactly as it would for a first-party request. That is the whole\n * point of the passthrough: the agent can do precisely what the user can.\n */\nexport async function dispatchTool(\n tool: GeneratedTool,\n args: Record<string, unknown>,\n config: DispatchConfig,\n): Promise<DispatchResult> {\n const doFetch = config.fetchImpl ?? fetch;\n const pathname = expandPath(tool, args);\n const { query, headers } = routeParams(tool, args);\n const body = routeBody(tool, args);\n\n const url = new URL(pathname, config.baseUrl);\n for (const [key, value] of query) url.searchParams.set(key, value);\n\n // Carry the proxy origin as the standard reverse-proxy forwarded headers. The\n // wrapped endpoint's auth guard re-derives the request origin (to check the\n // access token's `aud`) WITHOUT a request object, so it can only see the origin\n // through these headers. `baseUrl` is exactly the origin the token was minted\n // and transport-verified against, so forwarding its scheme+host makes the\n // wrapped guard reconstruct the SAME origin — the `aud` survives the replay in\n // both dev (http) and prod (any proxied https origin). Omitting them let the\n // guard default the scheme to https and 401 a valid http-minted bearer.\n const base = new URL(config.baseUrl);\n\n const init: RequestInit = {\n method: tool.method,\n headers: {\n accept: \"application/json\",\n authorization: `Bearer ${config.bearer}`,\n \"x-forwarded-proto\": base.protocol.replace(/:$/, \"\"),\n \"x-forwarded-host\": base.host,\n ...headers,\n },\n };\n if (body !== undefined) {\n (init.headers as Record<string, string>)[\"content-type\"] = \"application/json\";\n init.body = JSON.stringify(body);\n }\n\n const response = await doFetch(url.toString(), init);\n const text = await response.text();\n let parsed: unknown = text;\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\") && text) {\n try {\n parsed = JSON.parse(text);\n } catch {\n parsed = text;\n }\n }\n\n return { status: response.status, ok: response.ok, body: parsed };\n}\n","import type { JsonSchema } from \"../types\";\n\n/**\n * Both halves of the redaction contract: the SCHEMA a tool advertises, and the\n * BODY it returns.\n *\n * They only work as a pair, and the failure mode when they disagree is not a\n * cosmetic one. The dispatcher forwards the wrapped endpoint's response body\n * verbatim, so a narrowed `outputSchema` alone would only change what the\n * manifest CLAIMS is returned — the value still reaches the agent. Strip the\n * body but leave the schema advertising the field, and every successful call\n * fails validation against the very schema the manifest published, worst of all\n * when the field was `required`.\n *\n * So `redactResponseSchema` removes the paths at generate time and\n * `redactResponseBody` removes the same paths at dispatch, from one list. A host\n * that takes one and hand-rolls the other is back to the disagreement this pair\n * exists to prevent.\n */\n\n/** Structural keywords that wrap a value without naming a field. */\nconst SCHEMA_WRAPPERS = [\"items\", \"anyOf\", \"oneOf\", \"allOf\"] as const;\n\nfunction isSchema(value: unknown): value is JsonSchema {\n return Boolean(value) && typeof value === \"object\";\n}\n\n/** Drop `field` from an object schema's properties AND its `required` list. */\nfunction deleteProperty(schema: JsonSchema, field: string): true {\n delete (schema.properties as Record<string, JsonSchema>)[field];\n if (Array.isArray(schema.required)) {\n const kept = (schema.required as string[]).filter((name) => name !== field);\n if (kept.length) schema.required = kept;\n else delete schema.required;\n }\n return true;\n}\n\n/**\n * Descend into wrappers without consuming a segment, so `data.taxId` addresses\n * an array of rows and a `.nullable()` union branch alike.\n */\nfunction omitInWrappers(schema: JsonSchema, segments: readonly string[]): boolean {\n return SCHEMA_WRAPPERS.reduce((removed, keyword) => {\n const child = schema[keyword];\n const branches = Array.isArray(child) ? child : [child];\n return branches.reduce<boolean>(\n (acc, branch) => (isSchema(branch) && omitSchemaPath(branch, segments)) || acc,\n removed,\n );\n }, false);\n}\n\nfunction omitSchemaPath(schema: JsonSchema, segments: readonly string[]): boolean {\n const inWrappers = omitInWrappers(schema, segments);\n\n const properties = schema.properties as Record<string, JsonSchema> | undefined;\n const [head, ...rest] = segments;\n if (!properties || !head || !(head in properties)) return inWrappers;\n\n if (rest.length === 0) return deleteProperty(schema, head);\n\n const child = properties[head];\n return (isSchema(child) && omitSchemaPath(child, rest)) || inWrappers;\n}\n\n/**\n * Return `schema` without the listed dotted paths — the advertised half.\n *\n * THROWS when a path names nothing, rather than returning quietly: a typo'd or\n * stale redaction would otherwise protect nothing at all, and it would do so\n * invisibly, which is the one outcome a redaction list must never have. Failing\n * here turns it into a generator error naming the offending path.\n *\n * The input is cloned, not narrowed in place: a caller may hold the converted\n * schema for other uses (a shared `$defs` component, a schema reused across two\n * operations), and mutating it would redact those too.\n *\n * `operationId` only shapes the error message — pass it so the failure names\n * which tool declared the bad path.\n */\nexport function redactResponseSchema(\n schema: JsonSchema,\n paths: readonly string[],\n operationId?: string,\n): JsonSchema {\n if (!paths.length) return schema;\n\n const clone = structuredClone(schema);\n paths.forEach((path) => {\n if (!omitSchemaPath(clone, path.split(\".\"))) {\n const subject = operationId ? `MCP endpoint \"${operationId}\"` : \"This response schema\";\n throw new Error(\n `${subject} declares a response redaction for \"${path}\", which is not a field of its response schema`,\n );\n }\n });\n return clone;\n}\n\n/** Walk one dotted path, mapping over arrays, and delete the leaf. */\nfunction stripPath(value: unknown, segments: readonly string[]): void {\n if (value === null || typeof value !== \"object\") return;\n\n if (Array.isArray(value)) {\n value.forEach((entry) => stripPath(entry, segments));\n return;\n }\n\n const [head, ...rest] = segments;\n if (!head) return;\n\n const record = value as Record<string, unknown>;\n if (rest.length === 0) {\n delete record[head];\n return;\n }\n if (head in record) stripPath(record[head], rest);\n}\n\n/**\n * Return `body` without the listed dotted paths.\n *\n * The input is deep-cloned first: dispatch results are handed straight to the\n * JSON-RPC encoder AND reused as `structuredContent`, so mutating in place\n * could leak a half-redacted object into one of the two surfaces.\n */\nexport function redactResponseBody(\n body: unknown,\n paths: readonly string[] | undefined,\n): unknown {\n if (!paths?.length || body === null || typeof body !== \"object\") return body;\n\n const clone = structuredClone(body);\n paths.forEach((path) => stripPath(clone, path.split(\".\")));\n return clone;\n}\n","import { dispatchTool } from \"../dispatch/proxy\";\nimport type {\n GeneratedTool,\n JsonSchema,\n RequestAuth,\n ToolAnnotations,\n} from \"../types\";\nimport { redactResponseBody } from \"./redact\";\n\n/**\n * The registry is the transport-agnostic seam between the generated tools and the\n * MCP SDK. The consuming app owns the HTTP/JSON-RPC transport (mounting it at\n * `/api/mcp`) and, per request, resolves {@link RequestAuth} and calls\n * {@link ToolRegistry.listTools} / {@link ToolRegistry.callTool}. Keeping the\n * SDK out of this package means the core stays testable and portable.\n */\n\n/** An MCP tool descriptor as advertised to clients (subset of the MCP schema). */\nexport interface McpToolDescriptor {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n outputSchema?: JsonSchema;\n annotations: ToolAnnotations;\n}\n\n/**\n * `_meta` key carrying the upstream HTTP status of a dispatched call.\n *\n * `isError` is one bit, and it collapses answers that mean opposite things: a\n * 404 for a record that does not exist, a 403 a guard correctly refused, a\n * domain refusal (\"this store does not use comandas\"), and a 500 where the route\n * threw all arrive identical. Callers that need to tell \"correctly refused\" from\n * \"actually broken\" — `mcp:smoke` above all — cannot, because the status is\n * known at dispatch and then dropped. Publishing it under a namespaced `_meta`\n * key (permitted by the MCP result schema) keeps `isError` as the agent-facing\n * signal while making the distinction recoverable.\n */\nexport const HTTP_STATUS_META_KEY = \"dispatch/httpStatus\";\n\n/** An MCP tool-call result (subset of the MCP schema). */\nexport interface McpToolResult {\n content: Array<{ type: \"text\"; text: string }>;\n isError: boolean;\n /** Machine-readable output matching the advertised outputSchema. */\n structuredContent?: Record<string, unknown>;\n /** Out-of-band metadata; carries {@link HTTP_STATUS_META_KEY} when dispatched. */\n _meta?: Record<string, unknown>;\n}\n\nexport interface ToolRegistry {\n listTools(auth?: RequestAuth): McpToolDescriptor[];\n callTool(\n name: string,\n args: Record<string, unknown>,\n auth: RequestAuth,\n ): Promise<McpToolResult>;\n}\n\nexport interface RegistryOptions {\n tools: GeneratedTool[];\n /** Origin the tools proxy to (usually the app's own public URL). */\n baseUrl: string;\n fetchImpl?: typeof fetch;\n /**\n * Optional visibility filter — e.g. hide mutating tools, or tools whose\n * required scope the caller lacks. Authorization is still enforced upstream;\n * this only shapes what the agent is shown.\n */\n isVisible?: (tool: GeneratedTool, auth?: RequestAuth) => boolean;\n}\n\nfunction textResult(\n value: unknown,\n isError: boolean,\n httpStatus?: number,\n): McpToolResult {\n const text =\n typeof value === \"string\" ? value : JSON.stringify(value, null, 2);\n const result: McpToolResult = { content: [{ type: \"text\", text }], isError };\n if (httpStatus !== undefined) {\n result._meta = { [HTTP_STATUS_META_KEY]: httpStatus };\n }\n return result;\n}\n\nfunction successfulResult(tool: GeneratedTool, value: unknown): McpToolResult {\n // Redact BEFORE rendering the text block: the agent reads `content` even when\n // it ignores `structuredContent`, so stripping only the latter would still\n // hand over the field.\n const safe = redactResponseBody(value, tool.redactResponse);\n const result = textResult(safe, false);\n if (\n tool.outputSchema &&\n safe !== null &&\n typeof safe === \"object\" &&\n !Array.isArray(safe)\n ) {\n result.structuredContent = safe as Record<string, unknown>;\n }\n return result;\n}\n\nexport function createToolRegistry(options: RegistryOptions): ToolRegistry {\n const byName = new Map(options.tools.map((tool) => [tool.name, tool]));\n\n return {\n listTools(auth) {\n return options.tools\n .filter((tool) =>\n options.isVisible ? options.isVisible(tool, auth) : true,\n )\n .map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n ...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),\n annotations: tool.annotations,\n }));\n },\n\n async callTool(name, args, auth) {\n const tool = byName.get(name);\n if (!tool) return textResult(`Unknown tool: ${name}`, true);\n\n try {\n const result = await dispatchTool(tool, args, {\n baseUrl: options.baseUrl,\n bearer: auth.bearer,\n fetchImpl: options.fetchImpl,\n });\n // A non-2xx from the endpoint (e.g. 403 tenant-forbidden) is surfaced to\n // the agent as an error result, NOT thrown — the permission decision was\n // made upstream and its message is the useful signal. The status rides\n // along in `_meta` so a caller can tell a correct refusal from a break.\n return result.ok\n ? successfulResult(tool, result.body)\n : textResult(result.body, true, result.status);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return textResult(`Tool dispatch failed: ${message}`, true);\n }\n },\n };\n}\n","import type { RequestAuth } from \"../types\";\n\nimport type { ToolRegistry } from \"./registry\";\n\n/**\n * The MCP JSON-RPC 2.0 request half of the Streamable HTTP transport.\n *\n * Implemented directly rather than via the MCP SDK because the SDK's transport is\n * Node-`http` oriented, and a host serving Web `Request`/`Response` (a Next route\n * handler, a Hono route) has no `http.IncomingMessage` to hand it. It covers the\n * methods a client needs to discover and call tools: `initialize`, `tools/list`,\n * `tools/call`, plus `ping`.\n *\n * WHAT IS MECHANISM AND LIVES HERE: the envelope, the method table, the error\n * codes, the well-formedness rule, and the notification convention. None of it\n * varies per host — it is JSON-RPC 2.0 and the MCP specification.\n *\n * WHAT IS VOCABULARY AND STAYS WITH THE HOST: the server's NAME, its version, and\n * the `instructions` string an agent reads on connect. Those describe one\n * particular product's tool surface, so they arrive as {@link McpJsonRpcOptions}\n * rather than being written here.\n */\n\n/** The MCP protocol revision this transport implements. */\nexport const MCP_PROTOCOL_VERSION = \"2025-06-18\";\n\n/**\n * JSON-RPC error code for \"authentication required\", returned by `tools/call`\n * when the request carried no valid bearer. Outside the reserved -32768..-32000\n * band's *defined* codes on purpose: it is an implementation-defined server\n * error, and a host maps it to HTTP 401.\n */\nexport const UNAUTHORIZED_CODE = -32001;\n\n/** JSON-RPC \"Invalid Request\" — a payload that isn't a well-formed request object. */\nconst INVALID_REQUEST_CODE = -32600;\n\n/** JSON-RPC \"Method not found\". */\nconst METHOD_NOT_FOUND_CODE = -32601;\n\n/** JSON-RPC \"Invalid params\". */\nconst INVALID_PARAMS_CODE = -32602;\n\nexport interface JsonRpcRequest {\n jsonrpc: \"2.0\";\n id?: string | number | null;\n method: string;\n params?: unknown;\n}\n\nexport interface JsonRpcResponse {\n jsonrpc: \"2.0\";\n id: string | number | null;\n result?: unknown;\n error?: { code: number; message: string };\n}\n\n/** What a client is told it connected to, in `initialize`'s `serverInfo`. */\nexport interface McpServerInfo {\n /** The server's name, as a connected host displays it. */\n name: string;\n /**\n * The advertised surface version.\n *\n * This is the ONLY signal a client gets that the tool surface changed: the\n * transport is request/response only, so `notifications/tools/list_changed`\n * can never be sent, and a host that cached `tools/list` at the handshake has\n * no other reason to ask again. See `server/surface-lock.ts` for the guard\n * that makes forgetting to move it a build error instead of a comment.\n */\n version: string;\n}\n\nexport interface McpJsonRpcOptions {\n /** The host's identity, returned verbatim in `initialize`. */\n serverInfo: McpServerInfo;\n /**\n * Server-level guidance surfaced to the model on `initialize` (the MCP spec's\n * optional `instructions` field). Omitted from the result when absent, rather\n * than sent empty — a blank string is a claim that there is guidance.\n */\n instructions?: string;\n /**\n * Override the advertised protocol revision. Defaults to\n * {@link MCP_PROTOCOL_VERSION}; a host should not normally set it.\n */\n protocolVersion?: string;\n}\n\nfunction ok(id: JsonRpcRequest[\"id\"], result: unknown): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id: id ?? null, result };\n}\n\nfunction fail(id: JsonRpcRequest[\"id\"], code: number, message: string): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id: id ?? null, error: { code, message } };\n}\n\n/** A parsed body is a usable request only if it's an object carrying a string `method`. */\nfunction isWellFormed(request: JsonRpcRequest): boolean {\n return request != null && typeof request === \"object\" && typeof request.method === \"string\";\n}\n\nasync function handleToolsCall(\n request: JsonRpcRequest,\n registry: ToolRegistry,\n auth: RequestAuth | null,\n): Promise<JsonRpcResponse> {\n if (!auth) return fail(request.id, UNAUTHORIZED_CODE, \"Authentication required\");\n const params = (request.params ?? {}) as { name?: string; arguments?: Record<string, unknown> };\n if (!params.name) return fail(request.id, INVALID_PARAMS_CODE, \"Missing tool name\");\n const result = await registry.callTool(params.name, params.arguments ?? {}, auth);\n return ok(request.id, result);\n}\n\nfunction handleInitialize(\n request: JsonRpcRequest,\n options: McpJsonRpcOptions,\n): JsonRpcResponse {\n return ok(request.id, {\n protocolVersion: options.protocolVersion ?? MCP_PROTOCOL_VERSION,\n // Deliberately does NOT claim `listChanged`: this transport has no\n // server→client stream, so the notification could never be sent, and\n // advertising it would stop a host from ever re-reading `tools/list`.\n capabilities: { tools: {} },\n serverInfo: options.serverInfo,\n ...(options.instructions ? { instructions: options.instructions } : {}),\n });\n}\n\n/**\n * Handle one MCP JSON-RPC request.\n *\n * Returns `null` for notifications (no id, no reply expected). `auth` is the\n * verified caller identity, or `null` when the request carried no valid bearer —\n * `tools/call` then returns {@link UNAUTHORIZED_CODE}, which the host surfaces as\n * HTTP 401. Discovery (`initialize`, `ping`, `tools/list`) stays open, so a client\n * can read the surface before it has a token.\n */\nexport async function handleMcpJsonRpc(\n request: JsonRpcRequest,\n registry: ToolRegistry,\n auth: RequestAuth | null,\n options: McpJsonRpcOptions,\n): Promise<JsonRpcResponse | null> {\n // A host casts the parsed body to JsonRpcRequest without validating it, so a\n // malformed payload can arrive here: a `null` body/batch element, a non-object,\n // or an object with no `method`. Reject any of these as Invalid Request rather\n // than dereferencing `request`/`request.method` and throwing a 500 below.\n if (!isWellFormed(request)) {\n return fail(request?.id ?? null, INVALID_REQUEST_CODE, \"Invalid Request\");\n }\n switch (request.method) {\n case \"initialize\":\n return handleInitialize(request, options);\n case \"ping\":\n return ok(request.id, {});\n case \"tools/list\":\n return ok(request.id, { tools: registry.listTools(auth ?? undefined) });\n case \"tools/call\":\n return handleToolsCall(request, registry, auth);\n default:\n // JSON-RPC notifications (`notifications/*`) expect no reply — silently\n // ignore any we don't explicitly handle, rather than returning an error.\n if (request.method.startsWith(\"notifications/\")) return null;\n return fail(request.id, METHOD_NOT_FOUND_CODE, `Method not found: ${request.method}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EATlD,OASkD;AAAA;AAAA;AAAA,EAChD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGA,IAAM,eAAe,CAAC,YAAY,kBAAkB,uBAAuB;AAC3E,IAAM,iBAAiB,CAAC,SAAS,aAAa;AAG9C,SAAS,QAAQ,KAA4B;AAC3C,QAAM,SAAS,aAAa,KAAK,CAAC,cAAc,IAAI,WAAW,SAAS,CAAC;AACzE,SAAO,SAAS,mBAAmB,IAAI,MAAM,OAAO,MAAM,CAAC,IAAI;AACjE;AAHS;AAMT,SAAS,YAAY,MAA8C;AACjE,QAAM,OAAmC,CAAC;AAC1C,iBAAe,QAAQ,CAAC,QAAQ;AAC9B,UAAM,YAAY,KAAK,GAAG;AAC1B,QAAI,aAAa,OAAO,cAAc,UAAU;AAC9C,aAAO,OAAO,MAAM,SAAuC;AAAA,IAC7D;AAAA,EACF,CAAC;AACD,SAAO;AACT;AATS;AAWT,SAAS,UACP,KACA,MACA,QACS;AACT,QAAM,OAAO,QAAQ,GAAG;AACxB,MAAI,SAAS,KAAM,OAAM,IAAI,uBAAuB,6BAA6B,GAAG,EAAE;AACtF,QAAM,SAAS,KAAK,IAAI;AACxB,MAAI,CAAC,OAAQ,OAAM,IAAI,uBAAuB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
{"version":3,"sources":["../src/openapi/refs.ts","../src/dispatch/proxy.ts","../src/server/redact.ts","../src/server/registry.ts","../src/server/jsonrpc.ts"],"sourcesContent":["import type { JsonSchema } from \"../types\";\n\n/**\n * Raised when a JSON Schema cannot be turned into a flat, self-contained tool\n * input — an unresolvable `$ref`, an unsupported pointer, or a recursive schema.\n * The MCP tool surface is deliberately finite and flat (it is handed to an LLM\n * and committed to the drift manifest), so recursion is rejected rather than\n * silently truncated.\n */\nexport class UnsupportedSchemaError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"UnsupportedSchemaError\";\n }\n}\n\n/** Local-definition containers a `$ref` may point into, in resolution order. */\nconst REF_PREFIXES = [\"#/$defs/\", \"#/definitions/\", \"#/components/schemas/\"] as const;\nconst DEF_CONTAINERS = [\"$defs\", \"definitions\"] as const;\n\n/** The definition name a supported local pointer targets, or `null` if unsupported. */\nfunction refName(ref: string): string | null {\n const prefix = REF_PREFIXES.find((candidate) => ref.startsWith(candidate));\n return prefix ? decodeURIComponent(ref.slice(prefix.length)) : null;\n}\n\n/** Collect the `$defs`/`definitions` maps hoisted onto a schema root into one lookup. */\nfunction collectDefs(root: JsonSchema): Record<string, JsonSchema> {\n const defs: Record<string, JsonSchema> = {};\n DEF_CONTAINERS.forEach((key) => {\n const container = root[key];\n if (container && typeof container === \"object\") {\n Object.assign(defs, container as Record<string, JsonSchema>);\n }\n });\n return defs;\n}\n\nfunction inlineRef(\n ref: string,\n defs: Record<string, JsonSchema>,\n active: Set<string>,\n): unknown {\n const name = refName(ref);\n if (name === null) throw new UnsupportedSchemaError(`Unsupported $ref pointer: ${ref}`);\n const target = defs[name];\n if (!target) throw new UnsupportedSchemaError(`Unresolved $ref: ${ref}`);\n if (active.has(name)) throw new UnsupportedSchemaError(`Recursive schema not supported: ${name}`);\n active.add(name);\n const resolved = walk(target, defs, active);\n active.delete(name);\n return resolved;\n}\n\n/** Deep-copy `node`, inlining every `$ref` and stripping definition containers. */\nfunction walk(node: unknown, defs: Record<string, JsonSchema>, active: Set<string>): unknown {\n if (Array.isArray(node)) return node.map((item) => walk(item, defs, active));\n if (!node || typeof node !== \"object\") return node;\n\n const obj = node as Record<string, unknown>;\n if (typeof obj.$ref === \"string\") return inlineRef(obj.$ref, defs, active);\n\n const out: Record<string, unknown> = {};\n Object.entries(obj).forEach(([key, value]) => {\n if (!DEF_CONTAINERS.includes(key as (typeof DEF_CONTAINERS)[number])) {\n out[key] = walk(value, defs, active);\n }\n });\n return out;\n}\n\n/**\n * Inline every local `$ref` in a JSON Schema and drop the now-empty `$defs`/\n * `definitions` containers, yielding a flat, self-contained schema. Diamond reuse\n * (the same definition referenced by sibling branches) is fine; only a true cycle\n * — a definition that references itself up the resolution stack — is rejected.\n *\n * A schema with no `$ref`/definitions is returned structurally unchanged, so\n * inlining an already-flat spec is a no-op (the drift gate stays a stable diff).\n */\nexport function inlineSchemaRefs(schema: JsonSchema): JsonSchema {\n const defs = collectDefs(schema);\n return walk(schema, defs, new Set<string>()) as JsonSchema;\n}\n","import type { DispatchConfig, DispatchResult, GeneratedTool } from \"../types\";\n\n/** Raised when tool arguments cannot be routed onto the HTTP request. */\nexport class DispatchInputError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DispatchInputError\";\n }\n}\n\n/** Expand a path template (`/products/{id}`) using the path args, URL-encoding each. */\nfunction expandPath(\n tool: GeneratedTool,\n args: Record<string, unknown>,\n): string {\n return tool.path.replace(/\\{([^}]+)\\}/g, (_match, key: string) => {\n const value = args[key];\n if (value === undefined || value === null) {\n throw new DispatchInputError(`Missing required path parameter: ${key}`);\n }\n return encodeURIComponent(String(value));\n });\n}\n\n/**\n * Route the non-path parameters (query + header) from the flat args. A missing\n * required parameter is a hard error; a missing optional one is simply omitted.\n */\nfunction routeParams(\n tool: GeneratedTool,\n args: Record<string, unknown>,\n): { query: URLSearchParams; headers: Record<string, string> } {\n const query = new URLSearchParams();\n const headers: Record<string, string> = {};\n\n tool.parameters\n .filter((param) => param.in !== \"path\")\n .forEach((param) => {\n const value = args[param.name];\n if (value === undefined || value === null) {\n if (param.required) {\n throw new DispatchInputError(`Missing required ${param.in} parameter: ${param.name}`);\n }\n return;\n }\n if (param.in === \"query\") query.set(param.name, String(value));\n else headers[param.name] = String(value);\n });\n\n return { query, headers };\n}\n\n/**\n * Reconstruct the request body from the flat args using the routing metadata.\n * Anything not claimed by a known body property is dropped — the input schema is\n * `additionalProperties: false`, so a validated call never carries extras and an\n * unvalidated one cannot smuggle fields upstream.\n */\nfunction routeBody(tool: GeneratedTool, args: Record<string, unknown>): unknown {\n if (tool.bodyIsWhole) return args.body;\n if (!tool.bodyProps.length) return undefined;\n const payload: Record<string, unknown> = {};\n tool.bodyProps.forEach((key) => {\n if (args[key] !== undefined) payload[key] = args[key];\n });\n return Object.keys(payload).length ? payload : undefined;\n}\n\n/**\n * Execute one generated tool by proxying to its HTTP endpoint, forwarding the\n * caller's bearer verbatim. This function performs NO authorization — the\n * endpoint does, exactly as it would for a first-party request. That is the whole\n * point of the passthrough: the agent can do precisely what the user can.\n */\nexport async function dispatchTool(\n tool: GeneratedTool,\n args: Record<string, unknown>,\n config: DispatchConfig,\n): Promise<DispatchResult> {\n const doFetch = config.fetchImpl ?? fetch;\n const pathname = expandPath(tool, args);\n const { query, headers } = routeParams(tool, args);\n const body = routeBody(tool, args);\n\n const url = new URL(pathname, config.baseUrl);\n for (const [key, value] of query) url.searchParams.set(key, value);\n\n // Carry the proxy origin as the standard reverse-proxy forwarded headers. The\n // wrapped endpoint's auth guard re-derives the request origin (to check the\n // access token's `aud`) WITHOUT a request object, so it can only see the origin\n // through these headers. `baseUrl` is exactly the origin the token was minted\n // and transport-verified against, so forwarding its scheme+host makes the\n // wrapped guard reconstruct the SAME origin — the `aud` survives the replay in\n // both dev (http) and prod (any proxied https origin). Omitting them let the\n // guard default the scheme to https and 401 a valid http-minted bearer.\n const base = new URL(config.baseUrl);\n\n const init: RequestInit = {\n method: tool.method,\n headers: {\n accept: \"application/json\",\n authorization: `Bearer ${config.bearer}`,\n \"x-forwarded-proto\": base.protocol.replace(/:$/, \"\"),\n \"x-forwarded-host\": base.host,\n ...headers,\n },\n };\n if (body !== undefined) {\n (init.headers as Record<string, string>)[\"content-type\"] = \"application/json\";\n init.body = JSON.stringify(body);\n }\n\n const response = await doFetch(url.toString(), init);\n const text = await response.text();\n let parsed: unknown = text;\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\") && text) {\n try {\n parsed = JSON.parse(text);\n } catch {\n parsed = text;\n }\n }\n\n return { status: response.status, ok: response.ok, body: parsed };\n}\n","import type { JsonSchema } from \"../types\";\n\n/**\n * Both halves of the redaction contract: the SCHEMA a tool advertises, and the\n * BODY it returns.\n *\n * They only work as a pair, and the failure mode when they disagree is not a\n * cosmetic one. The dispatcher forwards the wrapped endpoint's response body\n * verbatim, so a narrowed `outputSchema` alone would only change what the\n * manifest CLAIMS is returned — the value still reaches the agent. Strip the\n * body but leave the schema advertising the field, and every successful call\n * fails validation against the very schema the manifest published, worst of all\n * when the field was `required`.\n *\n * So `redactResponseSchema` removes the paths at generate time and\n * `redactResponseBody` removes the same paths at dispatch, from one list. A host\n * that takes one and hand-rolls the other is back to the disagreement this pair\n * exists to prevent.\n */\n\n/** Structural keywords that wrap a value without naming a field. */\nconst SCHEMA_WRAPPERS = [\"items\", \"anyOf\", \"oneOf\", \"allOf\"] as const;\n\nfunction isSchema(value: unknown): value is JsonSchema {\n return Boolean(value) && typeof value === \"object\";\n}\n\n/** Drop `field` from an object schema's properties AND its `required` list. */\nfunction deleteProperty(schema: JsonSchema, field: string): true {\n delete (schema.properties as Record<string, JsonSchema>)[field];\n if (Array.isArray(schema.required)) {\n const kept = (schema.required as string[]).filter((name) => name !== field);\n if (kept.length) schema.required = kept;\n else delete schema.required;\n }\n return true;\n}\n\n/**\n * Descend into wrappers without consuming a segment, so `data.taxId` addresses\n * an array of rows and a `.nullable()` union branch alike.\n */\nfunction omitInWrappers(schema: JsonSchema, segments: readonly string[]): boolean {\n return SCHEMA_WRAPPERS.reduce((removed, keyword) => {\n const child = schema[keyword];\n const branches = Array.isArray(child) ? child : [child];\n return branches.reduce<boolean>(\n (acc, branch) => (isSchema(branch) && omitSchemaPath(branch, segments)) || acc,\n removed,\n );\n }, false);\n}\n\nfunction omitSchemaPath(schema: JsonSchema, segments: readonly string[]): boolean {\n const inWrappers = omitInWrappers(schema, segments);\n\n const properties = schema.properties as Record<string, JsonSchema> | undefined;\n const [head, ...rest] = segments;\n if (!properties || !head || !(head in properties)) return inWrappers;\n\n if (rest.length === 0) return deleteProperty(schema, head);\n\n const child = properties[head];\n return (isSchema(child) && omitSchemaPath(child, rest)) || inWrappers;\n}\n\n/**\n * Return `schema` without the listed dotted paths — the advertised half.\n *\n * THROWS when a path names nothing, rather than returning quietly: a typo'd or\n * stale redaction would otherwise protect nothing at all, and it would do so\n * invisibly, which is the one outcome a redaction list must never have. Failing\n * here turns it into a generator error naming the offending path.\n *\n * The input is cloned, not narrowed in place: a caller may hold the converted\n * schema for other uses (a shared `$defs` component, a schema reused across two\n * operations), and mutating it would redact those too.\n *\n * `operationId` only shapes the error message — pass it so the failure names\n * which tool declared the bad path.\n */\nexport function redactResponseSchema(\n schema: JsonSchema,\n paths: readonly string[],\n operationId?: string,\n): JsonSchema {\n if (!paths.length) return schema;\n\n const clone = structuredClone(schema);\n paths.forEach((path) => {\n if (!omitSchemaPath(clone, path.split(\".\"))) {\n const subject = operationId ? `MCP endpoint \"${operationId}\"` : \"This response schema\";\n throw new Error(\n `${subject} declares a response redaction for \"${path}\", which is not a field of its response schema`,\n );\n }\n });\n return clone;\n}\n\n/** Walk one dotted path, mapping over arrays, and delete the leaf. */\nfunction stripPath(value: unknown, segments: readonly string[]): void {\n if (value === null || typeof value !== \"object\") return;\n\n if (Array.isArray(value)) {\n value.forEach((entry) => stripPath(entry, segments));\n return;\n }\n\n const [head, ...rest] = segments;\n if (!head) return;\n\n const record = value as Record<string, unknown>;\n if (rest.length === 0) {\n delete record[head];\n return;\n }\n if (head in record) stripPath(record[head], rest);\n}\n\n/**\n * Return `body` without the listed dotted paths.\n *\n * The input is deep-cloned first: dispatch results are handed straight to the\n * JSON-RPC encoder AND reused as `structuredContent`, so mutating in place\n * could leak a half-redacted object into one of the two surfaces.\n */\nexport function redactResponseBody(\n body: unknown,\n paths: readonly string[] | undefined,\n): unknown {\n if (!paths?.length || body === null || typeof body !== \"object\") return body;\n\n const clone = structuredClone(body);\n paths.forEach((path) => stripPath(clone, path.split(\".\")));\n return clone;\n}\n","import { dispatchTool } from \"../dispatch/proxy\";\nimport type {\n GeneratedTool,\n JsonSchema,\n RequestAuth,\n ToolAnnotations,\n} from \"../types\";\nimport { redactResponseBody } from \"./redact\";\n\n/**\n * The registry is the transport-agnostic seam between the generated tools and the\n * MCP SDK. The consuming app owns the HTTP/JSON-RPC transport (mounting it at\n * `/api/mcp`) and, per request, resolves {@link RequestAuth} and calls\n * {@link ToolRegistry.listTools} / {@link ToolRegistry.callTool}. Keeping the\n * SDK out of this package means the core stays testable and portable.\n */\n\n/** An MCP tool descriptor as advertised to clients (subset of the MCP schema). */\nexport interface McpToolDescriptor {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n outputSchema?: JsonSchema;\n annotations: ToolAnnotations;\n}\n\n/**\n * `_meta` key carrying the upstream HTTP status of a dispatched call.\n *\n * `isError` is one bit, and it collapses answers that mean opposite things: a\n * 404 for a record that does not exist, a 403 a guard correctly refused, a\n * domain refusal (\"this store does not use comandas\"), and a 500 where the route\n * threw all arrive identical. Callers that need to tell \"correctly refused\" from\n * \"actually broken\" — `mcp:smoke` above all — cannot, because the status is\n * known at dispatch and then dropped. Publishing it under a namespaced `_meta`\n * key (permitted by the MCP result schema) keeps `isError` as the agent-facing\n * signal while making the distinction recoverable.\n */\nexport const HTTP_STATUS_META_KEY = \"dispatch/httpStatus\";\n\n/** An MCP tool-call result (subset of the MCP schema). */\nexport interface McpToolResult {\n content: Array<{ type: \"text\"; text: string }>;\n isError: boolean;\n /** Machine-readable output matching the advertised outputSchema. */\n structuredContent?: Record<string, unknown>;\n /** Out-of-band metadata; carries {@link HTTP_STATUS_META_KEY} when dispatched. */\n _meta?: Record<string, unknown>;\n}\n\nexport interface ToolRegistry {\n listTools(auth?: RequestAuth): McpToolDescriptor[];\n callTool(\n name: string,\n args: Record<string, unknown>,\n auth: RequestAuth,\n ): Promise<McpToolResult>;\n}\n\nexport interface RegistryOptions {\n tools: GeneratedTool[];\n /** Origin the tools proxy to (usually the app's own public URL). */\n baseUrl: string;\n fetchImpl?: typeof fetch;\n /**\n * Optional visibility filter — e.g. hide mutating tools, or tools whose\n * required scope the caller lacks. Authorization is still enforced upstream;\n * this only shapes what the agent is shown.\n */\n isVisible?: (tool: GeneratedTool, auth?: RequestAuth) => boolean;\n}\n\nfunction textResult(\n value: unknown,\n isError: boolean,\n httpStatus?: number,\n): McpToolResult {\n const text =\n typeof value === \"string\" ? value : JSON.stringify(value, null, 2);\n const result: McpToolResult = { content: [{ type: \"text\", text }], isError };\n if (httpStatus !== undefined) {\n result._meta = { [HTTP_STATUS_META_KEY]: httpStatus };\n }\n return result;\n}\n\nfunction successfulResult(tool: GeneratedTool, value: unknown): McpToolResult {\n // Redact BEFORE rendering the text block: the agent reads `content` even when\n // it ignores `structuredContent`, so stripping only the latter would still\n // hand over the field.\n const safe = redactResponseBody(value, tool.redactResponse);\n const result = textResult(safe, false);\n if (\n tool.outputSchema &&\n safe !== null &&\n typeof safe === \"object\" &&\n !Array.isArray(safe)\n ) {\n result.structuredContent = safe as Record<string, unknown>;\n }\n return result;\n}\n\nexport function createToolRegistry(options: RegistryOptions): ToolRegistry {\n const byName = new Map(options.tools.map((tool) => [tool.name, tool]));\n\n return {\n listTools(auth) {\n return options.tools\n .filter((tool) =>\n options.isVisible ? options.isVisible(tool, auth) : true,\n )\n .map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n ...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),\n annotations: tool.annotations,\n }));\n },\n\n async callTool(name, args, auth) {\n const tool = byName.get(name);\n if (!tool) return textResult(`Unknown tool: ${name}`, true);\n\n try {\n const result = await dispatchTool(tool, args, {\n baseUrl: options.baseUrl,\n bearer: auth.bearer,\n fetchImpl: options.fetchImpl,\n });\n // A non-2xx from the endpoint (e.g. 403 tenant-forbidden) is surfaced to\n // the agent as an error result, NOT thrown — the permission decision was\n // made upstream and its message is the useful signal. The status rides\n // along in `_meta` so a caller can tell a correct refusal from a break.\n return result.ok\n ? successfulResult(tool, result.body)\n : textResult(result.body, true, result.status);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return textResult(`Tool dispatch failed: ${message}`, true);\n }\n },\n };\n}\n","import type { RequestAuth } from \"../types\";\n\nimport type { ToolRegistry } from \"./registry\";\n\n/**\n * The MCP JSON-RPC 2.0 request half of the Streamable HTTP transport.\n *\n * Implemented directly rather than via the MCP SDK because the SDK's transport is\n * Node-`http` oriented, and a host serving Web `Request`/`Response` (a Next route\n * handler, a Hono route) has no `http.IncomingMessage` to hand it. It covers the\n * methods a client needs to discover and call tools: `initialize`, `tools/list`,\n * `tools/call`, plus `ping`.\n *\n * WHAT IS MECHANISM AND LIVES HERE: the envelope, the method table, the error\n * codes, the well-formedness rule, and the notification convention. None of it\n * varies per host — it is JSON-RPC 2.0 and the MCP specification.\n *\n * WHAT IS VOCABULARY AND STAYS WITH THE HOST: the server's NAME, its version, and\n * the `instructions` string an agent reads on connect. Those describe one\n * particular product's tool surface, so they arrive as {@link McpJsonRpcOptions}\n * rather than being written here.\n */\n\n/** The MCP protocol revision this transport implements. */\nexport const MCP_PROTOCOL_VERSION = \"2025-06-18\";\n\n/**\n * JSON-RPC error code for \"authentication required\", returned by `tools/call`\n * when the request carried no valid bearer. Outside the reserved -32768..-32000\n * band's *defined* codes on purpose: it is an implementation-defined server\n * error, and a host maps it to HTTP 401.\n */\nexport const UNAUTHORIZED_CODE = -32001;\n\n/** JSON-RPC \"Invalid Request\" — a payload that isn't a well-formed request object. */\nconst INVALID_REQUEST_CODE = -32600;\n\n/** JSON-RPC \"Method not found\". */\nconst METHOD_NOT_FOUND_CODE = -32601;\n\n/** JSON-RPC \"Invalid params\". */\nconst INVALID_PARAMS_CODE = -32602;\n\nexport interface JsonRpcRequest {\n jsonrpc: \"2.0\";\n id?: string | number | null;\n method: string;\n params?: unknown;\n}\n\nexport interface JsonRpcResponse {\n jsonrpc: \"2.0\";\n id: string | number | null;\n result?: unknown;\n error?: { code: number; message: string };\n}\n\n/** What a client is told it connected to, in `initialize`'s `serverInfo`. */\nexport interface McpServerInfo {\n /** The server's name, as a connected host displays it. */\n name: string;\n /**\n * The advertised surface version.\n *\n * This is the ONLY signal a client gets that the tool surface changed: the\n * transport is request/response only, so `notifications/tools/list_changed`\n * can never be sent, and a host that cached `tools/list` at the handshake has\n * no other reason to ask again. See `server/surface-lock.ts` for the guard\n * that makes forgetting to move it a build error instead of a comment.\n */\n version: string;\n}\n\nexport interface McpJsonRpcOptions {\n /** The host's identity, returned verbatim in `initialize`. */\n serverInfo: McpServerInfo;\n /**\n * Server-level guidance surfaced to the model on `initialize` (the MCP spec's\n * optional `instructions` field). Omitted from the result when absent, rather\n * than sent empty — a blank string is a claim that there is guidance.\n */\n instructions?: string;\n /**\n * Override the advertised protocol revision. Defaults to\n * {@link MCP_PROTOCOL_VERSION}; a host should not normally set it.\n */\n protocolVersion?: string;\n}\n\nfunction ok(id: JsonRpcRequest[\"id\"], result: unknown): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id: id ?? null, result };\n}\n\nfunction fail(id: JsonRpcRequest[\"id\"], code: number, message: string): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id: id ?? null, error: { code, message } };\n}\n\n/** A parsed body is a usable request only if it's an object carrying a string `method`. */\nfunction isWellFormed(request: JsonRpcRequest): boolean {\n return request != null && typeof request === \"object\" && typeof request.method === \"string\";\n}\n\nasync function handleToolsCall(\n request: JsonRpcRequest,\n registry: ToolRegistry,\n auth: RequestAuth | null,\n): Promise<JsonRpcResponse> {\n if (!auth) return fail(request.id, UNAUTHORIZED_CODE, \"Authentication required\");\n const params = (request.params ?? {}) as { name?: string; arguments?: Record<string, unknown> };\n if (!params.name) return fail(request.id, INVALID_PARAMS_CODE, \"Missing tool name\");\n const result = await registry.callTool(params.name, params.arguments ?? {}, auth);\n return ok(request.id, result);\n}\n\nfunction handleInitialize(\n request: JsonRpcRequest,\n options: McpJsonRpcOptions,\n): JsonRpcResponse {\n return ok(request.id, {\n protocolVersion: options.protocolVersion ?? MCP_PROTOCOL_VERSION,\n // Deliberately does NOT claim `listChanged`: this transport has no\n // server→client stream, so the notification could never be sent, and\n // advertising it would stop a host from ever re-reading `tools/list`.\n capabilities: { tools: {} },\n serverInfo: options.serverInfo,\n ...(options.instructions ? { instructions: options.instructions } : {}),\n });\n}\n\n/**\n * Handle one MCP JSON-RPC request.\n *\n * Returns `null` for notifications (no id, no reply expected). `auth` is the\n * verified caller identity, or `null` when the request carried no valid bearer —\n * `tools/call` then returns {@link UNAUTHORIZED_CODE}, which the host surfaces as\n * HTTP 401. Discovery (`initialize`, `ping`, `tools/list`) stays open, so a client\n * can read the surface before it has a token.\n */\nexport async function handleMcpJsonRpc(\n request: JsonRpcRequest,\n registry: ToolRegistry,\n auth: RequestAuth | null,\n options: McpJsonRpcOptions,\n): Promise<JsonRpcResponse | null> {\n // A host casts the parsed body to JsonRpcRequest without validating it, so a\n // malformed payload can arrive here: a `null` body/batch element, a non-object,\n // or an object with no `method`. Reject any of these as Invalid Request rather\n // than dereferencing `request`/`request.method` and throwing a 500 below.\n if (!isWellFormed(request)) {\n return fail(request?.id ?? null, INVALID_REQUEST_CODE, \"Invalid Request\");\n }\n switch (request.method) {\n case \"initialize\":\n return handleInitialize(request, options);\n case \"ping\":\n return ok(request.id, {});\n case \"tools/list\":\n return ok(request.id, { tools: registry.listTools(auth ?? undefined) });\n case \"tools/call\":\n return handleToolsCall(request, registry, auth);\n default:\n // JSON-RPC notifications (`notifications/*`) expect no reply — silently\n // ignore any we don't explicitly handle, rather than returning an error.\n if (request.method.startsWith(\"notifications/\")) return null;\n return fail(request.id, METHOD_NOT_FOUND_CODE, `Method not found: ${request.method}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EATlD,OASkD;AAAA;AAAA;AAAA,EAChD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGA,IAAM,eAAe,CAAC,YAAY,kBAAkB,uBAAuB;AAC3E,IAAM,iBAAiB,CAAC,SAAS,aAAa;AAG9C,SAAS,QAAQ,KAA4B;AAC3C,QAAM,SAAS,aAAa,KAAK,CAAC,cAAc,IAAI,WAAW,SAAS,CAAC;AACzE,SAAO,SAAS,mBAAmB,IAAI,MAAM,OAAO,MAAM,CAAC,IAAI;AACjE;AAHS;AAMT,SAAS,YAAY,MAA8C;AACjE,QAAM,OAAmC,CAAC;AAC1C,iBAAe,QAAQ,CAAC,QAAQ;AAC9B,UAAM,YAAY,KAAK,GAAG;AAC1B,QAAI,aAAa,OAAO,cAAc,UAAU;AAC9C,aAAO,OAAO,MAAM,SAAuC;AAAA,IAC7D;AAAA,EACF,CAAC;AACD,SAAO;AACT;AATS;AAWT,SAAS,UACP,KACA,MACA,QACS;AACT,QAAM,OAAO,QAAQ,GAAG;AACxB,MAAI,SAAS,KAAM,OAAM,IAAI,uBAAuB,6BAA6B,GAAG,EAAE;AACtF,QAAM,SAAS,KAAK,IAAI;AACxB,MAAI,CAAC,OAAQ,OAAM,IAAI,uBAAuB,oBAAoB,GAAG,EAAE;AACvE,MAAI,OAAO,IAAI,IAAI,EAAG,OAAM,IAAI,uBAAuB,mCAAmC,IAAI,EAAE;AAChG,SAAO,IAAI,IAAI;AACf,QAAM,WAAW,KAAK,QAAQ,MAAM,MAAM;AAC1C,SAAO,OAAO,IAAI;AAClB,S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