techprotrade commited on
Commit
4d583b7
·
verified ·
1 Parent(s): 4db1732

Add loan-advisor-chatgpt-app (part 3)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/ext-apps/README.md +258 -0
  2. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/ext-apps/package.json +133 -0
  3. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts +190 -0
  4. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts.map +1 -0
  5. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js +299 -0
  6. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js.map +1 -0
  7. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts +451 -0
  8. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts.map +1 -0
  9. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js +943 -0
  10. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js.map +1 -0
  11. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts +591 -0
  12. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map +1 -0
  13. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js +629 -0
  14. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map +1 -0
  15. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/middleware.d.ts +169 -0
  16. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/middleware.d.ts.map +1 -0
  17. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/middleware.js +252 -0
  18. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/middleware.js.map +1 -0
  19. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/sse.d.ts +81 -0
  20. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/sse.d.ts.map +1 -0
  21. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/sse.js +211 -0
  22. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/sse.js.map +1 -0
  23. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts +77 -0
  24. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map +1 -0
  25. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js +196 -0
  26. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map +1 -0
  27. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts +171 -0
  28. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map +1 -0
  29. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js +482 -0
  30. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map +1 -0
  31. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.d.ts +17 -0
  32. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.d.ts.map +1 -0
  33. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.js +58 -0
  34. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.js.map +1 -0
  35. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/elicitationUrlExample.d.ts +2 -0
  36. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/elicitationUrlExample.d.ts.map +1 -0
  37. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/elicitationUrlExample.js +680 -0
  38. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/elicitationUrlExample.js.map +1 -0
  39. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.d.ts +2 -0
  40. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.d.ts.map +1 -0
  41. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.js +134 -0
  42. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.js.map +1 -0
  43. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.d.ts +2 -0
  44. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.d.ts.map +1 -0
  45. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.js +176 -0
  46. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.js.map +1 -0
  47. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts +20 -0
  48. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts.map +1 -0
  49. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js +70 -0
  50. loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js.map +1 -0
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/ext-apps/README.md ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- LOGO -->
2
+ <div align="center">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="media/mcp-white.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="media/mcp.svg">
6
+ <img src="media/mcp.svg" alt="MCP Apps" width="128">
7
+ </picture>
8
+ <h1>MCP Apps</h1>
9
+ <p>
10
+ Build interactive UIs for MCP tools — charts, forms, dashboards — that render inline in Claude, ChatGPT and any other compliant chat client.
11
+ <br /><br />
12
+ <a href="#why-mcp-apps">Why</a>
13
+ ·
14
+ <a href="https://apps.extensions.modelcontextprotocol.io/api/documents/Quickstart.html">Quickstart</a>
15
+ ·
16
+ <a href="https://apps.extensions.modelcontextprotocol.io/api/">API Docs</a>
17
+ ·
18
+ <a href="https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx">Spec</a>
19
+ ·
20
+ <a href="CONTRIBUTING.md">Contributing</a>
21
+ </p>
22
+ </div>
23
+
24
+ <p align="center">
25
+ <a href="https://github.com/modelcontextprotocol/ext-apps/actions/workflows/ci.yml"><img src="https://github.com/modelcontextprotocol/ext-apps/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
26
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License: Apache 2.0"></a>
27
+ <a href="https://www.npmjs.com/package/@modelcontextprotocol/ext-apps"><img src="https://img.shields.io/npm/v/@modelcontextprotocol/ext-apps.svg" alt="npm version"></a>
28
+ <a href="https://www.npmjs.com/package/@modelcontextprotocol/ext-apps"><img src="https://img.shields.io/npm/dm/@modelcontextprotocol/ext-apps.svg" alt="npm downloads"></a>
29
+ <a href="https://github.com/modelcontextprotocol/ext-apps"><img src="https://img.shields.io/github/stars/modelcontextprotocol/ext-apps" alt="GitHub stars"></a>
30
+ <a href="https://apps.extensions.modelcontextprotocol.io/api/"><img src="https://img.shields.io/badge/docs-API%20Reference-blue" alt="API Documentation"></a>
31
+ </p>
32
+
33
+ <p align="center">
34
+ <img src="media/excalidraw.gif" alt="MCP Apps demo" width="600">
35
+ <br><em>Excalidraw built with MCP Apps, running in Claude</em>
36
+ </p>
37
+
38
+ ## Table of Contents
39
+
40
+ - [Build with Agent Skills](#build-with-agent-skills)
41
+ - [Supported Clients](#supported-clients)
42
+ - [Why MCP Apps?](#why-mcp-apps)
43
+ - [How It Works](#how-it-works)
44
+ - [Getting Started](#getting-started)
45
+ - [Using the SDK](#using-the-sdk)
46
+ - [Examples](#examples)
47
+ - [Specification](#specification)
48
+ - [Resources](#resources)
49
+ - [Contributing](#contributing)
50
+
51
+ ## Build with Agent Skills
52
+
53
+ The fastest way to build an MCP App is to let your AI coding agent do it. This
54
+ repo ships four [Agent Skills](https://agentskills.io/) — install them once,
55
+ then just ask:
56
+
57
+ | Skill | What it does | Try it |
58
+ | --------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------- |
59
+ | [`create-mcp-app`](./plugins/mcp-apps/skills/create-mcp-app/SKILL.md) | Scaffolds a new MCP App with an interactive UI from scratch | _"Create an MCP App"_ |
60
+ | [`migrate-oai-app`](./plugins/mcp-apps/skills/migrate-oai-app/SKILL.md) | Converts an existing OpenAI App to use MCP Apps | _"Migrate from OpenAI Apps SDK"_ |
61
+ | [`add-app-to-server`](./plugins/mcp-apps/skills/add-app-to-server/SKILL.md) | Adds interactive UI to an existing MCP server's tools | _"Add UI to my MCP server"_ |
62
+ | [`convert-web-app`](./plugins/mcp-apps/skills/convert-web-app/SKILL.md) | Turns an existing web app into a hybrid web + MCP App | _"Add MCP App support to my web app"_ |
63
+
64
+ ### Install the Skills
65
+
66
+ **Claude Code** — install via the plugin marketplace:
67
+
68
+ ```
69
+ /plugin marketplace add modelcontextprotocol/ext-apps
70
+ /plugin install mcp-apps@modelcontextprotocol-ext-apps
71
+ ```
72
+
73
+ **Other agents** — any AI coding agent that supports
74
+ [Agent Skills](https://agentskills.io/) can use these skills. See the
75
+ [agent skills guide](./docs/agent-skills.md) for manual installation
76
+ instructions.
77
+
78
+ Once installed, verify by asking your agent _"What skills do you have?"_ — you
79
+ should see `create-mcp-app`, `migrate-oai-app`, `add-app-to-server`, and
80
+ `convert-web-app` in the list. Then just ask it to create or migrate an app and
81
+ it will guide you through the rest.
82
+
83
+ ## Supported Clients
84
+
85
+ <p align="center">
86
+ <a href="https://developers.openai.com/apps-sdk/mcp-apps-in-chatgpt/"><img src="https://img.shields.io/badge/ChatGPT-docs-74aa9c?logo=openai&logoColor=white" alt="ChatGPT"></a>
87
+ <a href="https://claude.com/docs/connectors/building/mcp-apps/getting-started"><img src="https://img.shields.io/badge/Claude-docs-d97706?logo=claude&logoColor=white" alt="Claude"></a>
88
+ <a href="https://code.visualstudio.com/blogs/2026/01/26/mcp-apps-support"><img src="https://img.shields.io/badge/VS_Code-docs-007ACC?logo=visualstudiocode&logoColor=white" alt="VS Code"></a>
89
+ <a href="https://block.github.io/goose/docs/tutorials/building-mcp-apps/"><img src="https://img.shields.io/badge/Goose-docs-000000?logo=goose&logoColor=white" alt="Goose"></a>
90
+ <a href="https://learning.postman.com/docs/postman-ai/mcp-requests/interact"><img src="https://img.shields.io/badge/Postman-docs-FF6C37?logo=postman&logoColor=white" alt="Postman"></a>
91
+ <a href="https://www.mcpjam.com/blog/mcp-apps-example"><img src="https://img.shields.io/badge/MCPJam-docs-8B5CF6" alt="MCPJam"></a>
92
+ </p>
93
+
94
+ > [!NOTE]
95
+ > MCP Apps is an extension to the
96
+ > [core MCP specification](https://modelcontextprotocol.io/specification). Host
97
+ > support varies — see the
98
+ > [clients page](https://modelcontextprotocol.io/clients) for the full list.
99
+
100
+ ## Why MCP Apps?
101
+
102
+ MCP tools return text and structured data. That works for many cases, but not
103
+ when you need an interactive UI, like a chart, form, design canvas or video player.
104
+
105
+ MCP Apps provide a standardized way to deliver interactive UIs from MCP servers.
106
+ Your UI renders inline in the conversation, in context, in any compliant host.
107
+
108
+ ## How It Works
109
+
110
+ MCP Apps extend the Model Context Protocol by letting tools declare UI
111
+ resources:
112
+
113
+ 1. **Tool definition** — Your tool declares a `ui://` resource containing its
114
+ HTML interface
115
+ 2. **Tool call** — The LLM calls the tool on your server
116
+ 3. **Host renders** — The host fetches the resource and displays it in a
117
+ sandboxed iframe
118
+ 4. **Bidirectional communication** — The host passes tool data to the UI via
119
+ notifications, and the UI can call other tools through the host
120
+
121
+ ## Getting Started
122
+
123
+ ```bash
124
+ npm install -S @modelcontextprotocol/ext-apps
125
+ ```
126
+
127
+ **New here?** Start with the
128
+ [Quickstart Guide](https://apps.extensions.modelcontextprotocol.io/api/documents/Quickstart.html)
129
+ to build your first MCP App.
130
+
131
+ ## Using the SDK
132
+
133
+ The SDK serves three roles: app developers building interactive Views, host
134
+ developers embedding those Views, and MCP server authors registering tools with
135
+ UI metadata.
136
+
137
+ | Package | Purpose | Docs |
138
+ | ------------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
139
+ | `@modelcontextprotocol/ext-apps` | Build interactive Views (App class, PostMessageTransport) | [API Docs →](https://apps.extensions.modelcontextprotocol.io/api/modules/app.html) |
140
+ | `@modelcontextprotocol/ext-apps/react` | React hooks for Views (useApp, useHostStyles, etc.) | [API Docs →](https://apps.extensions.modelcontextprotocol.io/api/modules/_modelcontextprotocol_ext-apps_react.html) |
141
+ | `@modelcontextprotocol/ext-apps/app-bridge` | Embed and communicate with Views in your chat client | [API Docs →](https://apps.extensions.modelcontextprotocol.io/api/modules/app-bridge.html) |
142
+ | `@modelcontextprotocol/ext-apps/server` | Register tools and resources on your MCP server | [API Docs →](https://apps.extensions.modelcontextprotocol.io/api/modules/server.html) |
143
+
144
+ There's no _supported_ host implementation in this repo (beyond the
145
+ [examples/basic-host](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-host)
146
+ example).
147
+
148
+ The [MCP-UI](https://github.com/idosal/mcp-ui) client SDK offers a
149
+ fully-featured MCP Apps framework used by a few hosts. Clients may choose to use
150
+ it or roll their own implementation.
151
+
152
+ ## Examples
153
+
154
+ The
155
+ [`examples/`](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples)
156
+ directory contains demo apps showcasing real-world use cases.
157
+
158
+ <!-- prettier-ignore-start -->
159
+ | | | |
160
+ |:---:|:---:|:---:|
161
+ | [![Map](examples/map-server/grid-cell.png "Interactive 3D globe viewer using CesiumJS")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/map-server) | [![Three.js](examples/threejs-server/grid-cell.png "Interactive 3D scene renderer")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/threejs-server) | [![ShaderToy](examples/shadertoy-server/grid-cell.png "Real-time GLSL shader renderer")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/shadertoy-server) |
162
+ | [**Map**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/map-server) | [**Three.js**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/threejs-server) | [**ShaderToy**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/shadertoy-server) |
163
+ | [![Sheet Music](examples/sheet-music-server/grid-cell.png "ABC notation to sheet music")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/sheet-music-server) | [![Wiki Explorer](examples/wiki-explorer-server/grid-cell.png "Wikipedia link graph visualization")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/wiki-explorer-server) | [![Cohort Heatmap](examples/cohort-heatmap-server/grid-cell.png "Customer retention heatmap")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/cohort-heatmap-server) |
164
+ | [**Sheet Music**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/sheet-music-server) | [**Wiki Explorer**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/wiki-explorer-server) | [**Cohort Heatmap**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/cohort-heatmap-server) |
165
+ | [![Scenario Modeler](examples/scenario-modeler-server/grid-cell.png "SaaS business projections")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/scenario-modeler-server) | [![Budget Allocator](examples/budget-allocator-server/grid-cell.png "Interactive budget allocation")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/budget-allocator-server) | [![Customer Segmentation](examples/customer-segmentation-server/grid-cell.png "Scatter chart with clustering")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/customer-segmentation-server) |
166
+ | [**Scenario Modeler**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/scenario-modeler-server) | [**Budget Allocator**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/budget-allocator-server) | [**Customer Segmentation**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/customer-segmentation-server) |
167
+ | [![System Monitor](examples/system-monitor-server/grid-cell.png "Real-time OS metrics")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/system-monitor-server) | [![Transcript](examples/transcript-server/grid-cell.png "Live speech transcription")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/transcript-server) | [![Video Resource](examples/video-resource-server/grid-cell.png "Binary video via MCP resources")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/video-resource-server) |
168
+ | [**System Monitor**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/system-monitor-server) | [**Transcript**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/transcript-server) | [**Video Resource**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/video-resource-server) |
169
+ | [![PDF Server](examples/pdf-server/grid-cell.png "Interactive PDF viewer with chunked loading")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/pdf-server) | [![QR Code](examples/qr-server/grid-cell.png "QR code generator")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/qr-server) | [![Say Demo](examples/say-server/grid-cell.png "Text-to-speech demo")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/say-server) |
170
+ | [**PDF Server**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/pdf-server) | [**QR Code (Python)**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/qr-server) | [**Say Demo**](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/say-server) |
171
+
172
+ ### Starter Templates
173
+
174
+ | | |
175
+ |:---:|:---|
176
+ | [![Basic](examples/basic-server-react/grid-cell.png "Starter template")](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-react) | The same app built with different frameworks — pick your favorite!<br><br>[React](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-react) · [Vue](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-vue) · [Svelte](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-svelte) · [Preact](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-preact) · [Solid](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-solid) · [Vanilla JS](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-server-vanillajs) |
177
+ <!-- prettier-ignore-end -->
178
+
179
+ ### Running the Examples
180
+
181
+ #### With basic-host
182
+
183
+ To run all examples locally using
184
+ [basic-host](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-host)
185
+ (the reference host implementation included in this repo):
186
+
187
+ ```bash
188
+ git clone https://github.com/modelcontextprotocol/ext-apps.git
189
+ cd ext-apps
190
+ npm install
191
+ npm start
192
+ ```
193
+
194
+ Then open http://localhost:8080/.
195
+
196
+ #### With MCP Clients
197
+
198
+ Every Node.js example is published as `@modelcontextprotocol/server-<name>`. To
199
+ add one to an MCP client that supports stdio (Claude Desktop, VS Code, etc.),
200
+ use this pattern:
201
+
202
+ ```json
203
+ {
204
+ "mcpServers": {
205
+ "<name>": {
206
+ "command": "npx",
207
+ "args": ["-y", "@modelcontextprotocol/server-<name>", "--stdio"]
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ For example, to add the map server: `@modelcontextprotocol/server-map`. The
214
+ Python examples (`qr-server`, `say-server`) use `uv run` instead — see their
215
+ READMEs for details.
216
+
217
+ #### Local Development
218
+
219
+ To test local modifications with an MCP client, clone the repo, install, then
220
+ point your client at a local build:
221
+
222
+ ```json
223
+ {
224
+ "mcpServers": {
225
+ "<name>": {
226
+ "command": "bash",
227
+ "args": [
228
+ "-c",
229
+ "cd ~/code/ext-apps/examples/<name>-server && npm run build >&2 && node dist/index.js --stdio"
230
+ ]
231
+ }
232
+ }
233
+ }
234
+ ```
235
+
236
+ ## Specification
237
+
238
+ <div align="center">
239
+
240
+ | Version | Status | Link |
241
+ | -------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------- |
242
+ | **2026-01-26** | Stable | [specification/2026-01-26/apps.mdx](https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx) |
243
+ | **draft** | Development | [specification/draft/apps.mdx](https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx) |
244
+
245
+ </div>
246
+
247
+ ## Resources
248
+
249
+ - [Quickstart Guide](https://apps.extensions.modelcontextprotocol.io/api/documents/Quickstart.html)
250
+ - [API Documentation](https://apps.extensions.modelcontextprotocol.io/api/)
251
+ - [Specification (2026-01-26)](https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx)
252
+ ([Draft](https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx))
253
+ - [SEP-1865 Discussion](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1865)
254
+
255
+ ## Contributing
256
+
257
+ Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for
258
+ guidelines on how to get started, submit pull requests, and report issues.
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/ext-apps/package.json ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@modelcontextprotocol/ext-apps",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/modelcontextprotocol/ext-apps"
6
+ },
7
+ "homepage": "https://github.com/modelcontextprotocol/ext-apps",
8
+ "version": "1.7.4",
9
+ "license": "MIT",
10
+ "description": "MCP Apps SDK — Enable MCP servers to display interactive user interfaces in conversational clients.",
11
+ "type": "module",
12
+ "engines": {
13
+ "node": ">=20"
14
+ },
15
+ "main": "./dist/src/app.js",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/src/app.d.ts",
19
+ "default": "./dist/src/app.js"
20
+ },
21
+ "./app-with-deps": {
22
+ "types": "./dist/src/app.d.ts",
23
+ "default": "./dist/src/app-with-deps.js"
24
+ },
25
+ "./react": {
26
+ "types": "./dist/src/react/index.d.ts",
27
+ "default": "./dist/src/react/index.js"
28
+ },
29
+ "./react-with-deps": {
30
+ "types": "./dist/src/react/index.d.ts",
31
+ "default": "./dist/src/react/react-with-deps.js"
32
+ },
33
+ "./app-bridge": {
34
+ "types": "./dist/src/app-bridge.d.ts",
35
+ "default": "./dist/src/app-bridge.js"
36
+ },
37
+ "./server": {
38
+ "types": "./dist/src/server/index.d.ts",
39
+ "default": "./dist/src/server/index.js"
40
+ },
41
+ "./schema.json": "./dist/src/generated/schema.json"
42
+ },
43
+ "files": [
44
+ "dist"
45
+ ],
46
+ "workspaces": [
47
+ "examples/*"
48
+ ],
49
+ "scripts": {
50
+ "start": "npm run examples:dev",
51
+ "generate:schemas": "tsx scripts/generate-schemas.ts && prettier --write \"src/generated/**/*\"",
52
+ "sync:snippets": "bun scripts/sync-snippets.ts",
53
+ "build": "npm run generate:schemas && npm run sync:snippets && node scripts/run-bun.mjs build.bun.ts && node scripts/link-self.mjs",
54
+ "prepack": "npm run build",
55
+ "build:all": "npm run examples:build",
56
+ "test": "bun test src examples",
57
+ "test:e2e": "playwright test",
58
+ "test:e2e:update": "playwright test --update-snapshots",
59
+ "test:e2e:ui": "playwright test --ui",
60
+ "test:e2e:docker": "docker run --rm -e EXAMPLE -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test'",
61
+ "test:e2e:docker:update": "npm run build:all && docker run --rm -e EXAMPLE -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test --update-snapshots'",
62
+ "preexamples:build": "npm run build",
63
+ "examples:build": "bun examples/run-all.ts build",
64
+ "examples:start": "NODE_ENV=development npm run build && bun examples/run-all.ts start",
65
+ "examples:dev": "NODE_ENV=development bun examples/run-all.ts dev",
66
+ "watch": "nodemon --watch src --ext ts,tsx --exec 'bun build.bun.ts'",
67
+ "prepare": "npm run build && husky",
68
+ "docs": "typedoc",
69
+ "docs:watch": "typedoc --watch",
70
+ "generate:screenshots": "npm run build:all && docker run --rm -e EXAMPLE -e GENERATE_SCREENSHOTS=1 -v $(pwd):/work -w /work mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test tests/e2e/generate-grid-screenshots.spec.ts'",
71
+ "prettier": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --check",
72
+ "prettier:fix": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --write",
73
+ "check:versions": "node scripts/check-versions.mjs",
74
+ "bump": "node scripts/bump-version.mjs",
75
+ "update-lock:docker": "rm -rf node_modules package-lock.json examples/*/node_modules && docker run --rm --platform linux/amd64 -v $(pwd):/work -w /work -e HOME=/tmp node:latest npm i --registry=https://registry.npmjs.org/ --ignore-scripts && rm -rf node_modules examples/*/node_modules && npm i --registry=https://registry.npmjs.org/"
76
+ },
77
+ "author": "Olivier Chafik",
78
+ "devDependencies": {
79
+ "@boneskull/typedoc-plugin-mermaid": "^0.2.0",
80
+ "@modelcontextprotocol/sdk": "^1.29.0",
81
+ "@playwright/test": "1.57.0",
82
+ "@types/bun": "^1.3.2",
83
+ "@types/node": "20.19.27",
84
+ "@types/react": "^19.2.2",
85
+ "@types/react-dom": "^19.2.2",
86
+ "bun": "^1.2.21",
87
+ "caniuse-lite": "1.0.30001763",
88
+ "cheerio": "1.1.2",
89
+ "concurrently": "^9.2.1",
90
+ "cors": "^2.8.5",
91
+ "cross-env": "^10.1.0",
92
+ "electron-to-chromium": "1.5.267",
93
+ "esbuild": "^0.25.12",
94
+ "express": "^5.1.0",
95
+ "husky": "^9.1.7",
96
+ "nodemon": "^3.1.0",
97
+ "playwright": "1.57.0",
98
+ "playwright-core": "1.57.0",
99
+ "prettier": "^3.6.2",
100
+ "react": "^19.2.0",
101
+ "react-dom": "^19.2.0",
102
+ "sharp": "^0.34.5",
103
+ "ts-to-zod": "^5.1.0",
104
+ "tsx": "^4.21.0",
105
+ "typedoc": "^0.28.14",
106
+ "typedoc-github-theme": "^0.4.0",
107
+ "typescript": "^5.9.3",
108
+ "zod": "^4.1.13"
109
+ },
110
+ "peerDependencies": {
111
+ "@modelcontextprotocol/sdk": "^1.29.0",
112
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
113
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
114
+ "zod": "^3.25.0 || ^4.0.0"
115
+ },
116
+ "peerDependenciesMeta": {
117
+ "react": {
118
+ "optional": true
119
+ },
120
+ "react-dom": {
121
+ "optional": true
122
+ }
123
+ },
124
+ "overrides": {
125
+ "seroval": "1.4.1",
126
+ "seroval-plugins": "1.4.2",
127
+ "solid-js": "1.9.10",
128
+ "@types/node": "20.19.27"
129
+ },
130
+ "dependencies": {
131
+ "@standard-schema/spec": "^1.1.0"
132
+ }
133
+ }
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * OAuth provider extensions for specialized authentication flows.
3
+ *
4
+ * This module provides ready-to-use OAuthClientProvider implementations
5
+ * for common machine-to-machine authentication scenarios.
6
+ */
7
+ import { OAuthClientInformation, OAuthClientMetadata, OAuthTokens } from '../shared/auth.js';
8
+ import { AddClientAuthentication, OAuthClientProvider } from './auth.js';
9
+ /**
10
+ * Helper to produce a private_key_jwt client authentication function.
11
+ *
12
+ * Usage:
13
+ * const addClientAuth = createPrivateKeyJwtAuth({ issuer, subject, privateKey, alg, audience? });
14
+ * // pass addClientAuth as provider.addClientAuthentication implementation
15
+ */
16
+ export declare function createPrivateKeyJwtAuth(options: {
17
+ issuer: string;
18
+ subject: string;
19
+ privateKey: string | Uint8Array | Record<string, unknown>;
20
+ alg: string;
21
+ audience?: string | URL;
22
+ lifetimeSeconds?: number;
23
+ claims?: Record<string, unknown>;
24
+ }): AddClientAuthentication;
25
+ /**
26
+ * Options for creating a ClientCredentialsProvider.
27
+ */
28
+ export interface ClientCredentialsProviderOptions {
29
+ /**
30
+ * The client_id for this OAuth client.
31
+ */
32
+ clientId: string;
33
+ /**
34
+ * The client_secret for client_secret_basic authentication.
35
+ */
36
+ clientSecret: string;
37
+ /**
38
+ * Optional client name for metadata.
39
+ */
40
+ clientName?: string;
41
+ /**
42
+ * Space-separated scopes values requested by the client.
43
+ */
44
+ scope?: string;
45
+ }
46
+ /**
47
+ * OAuth provider for client_credentials grant with client_secret_basic authentication.
48
+ *
49
+ * This provider is designed for machine-to-machine authentication where
50
+ * the client authenticates using a client_id and client_secret.
51
+ *
52
+ * @example
53
+ * const provider = new ClientCredentialsProvider({
54
+ * clientId: 'my-client',
55
+ * clientSecret: 'my-secret'
56
+ * });
57
+ *
58
+ * const transport = new StreamableHTTPClientTransport(serverUrl, {
59
+ * authProvider: provider
60
+ * });
61
+ */
62
+ export declare class ClientCredentialsProvider implements OAuthClientProvider {
63
+ private _tokens?;
64
+ private _clientInfo;
65
+ private _clientMetadata;
66
+ constructor(options: ClientCredentialsProviderOptions);
67
+ get redirectUrl(): undefined;
68
+ get clientMetadata(): OAuthClientMetadata;
69
+ clientInformation(): OAuthClientInformation;
70
+ saveClientInformation(info: OAuthClientInformation): void;
71
+ tokens(): OAuthTokens | undefined;
72
+ saveTokens(tokens: OAuthTokens): void;
73
+ redirectToAuthorization(): void;
74
+ saveCodeVerifier(): void;
75
+ codeVerifier(): string;
76
+ prepareTokenRequest(scope?: string): URLSearchParams;
77
+ }
78
+ /**
79
+ * Options for creating a PrivateKeyJwtProvider.
80
+ */
81
+ export interface PrivateKeyJwtProviderOptions {
82
+ /**
83
+ * The client_id for this OAuth client.
84
+ */
85
+ clientId: string;
86
+ /**
87
+ * The private key for signing JWT assertions.
88
+ * Can be a PEM string, Uint8Array, or JWK object.
89
+ */
90
+ privateKey: string | Uint8Array | Record<string, unknown>;
91
+ /**
92
+ * The algorithm to use for signing (e.g., 'RS256', 'ES256').
93
+ */
94
+ algorithm: string;
95
+ /**
96
+ * Optional client name for metadata.
97
+ */
98
+ clientName?: string;
99
+ /**
100
+ * Optional JWT lifetime in seconds (default: 300).
101
+ */
102
+ jwtLifetimeSeconds?: number;
103
+ /**
104
+ * Space-separated scopes values requested by the client.
105
+ */
106
+ scope?: string;
107
+ }
108
+ /**
109
+ * OAuth provider for client_credentials grant with private_key_jwt authentication.
110
+ *
111
+ * This provider is designed for machine-to-machine authentication where
112
+ * the client authenticates using a signed JWT assertion (RFC 7523 Section 2.2).
113
+ *
114
+ * @example
115
+ * const provider = new PrivateKeyJwtProvider({
116
+ * clientId: 'my-client',
117
+ * privateKey: pemEncodedPrivateKey,
118
+ * algorithm: 'RS256'
119
+ * });
120
+ *
121
+ * const transport = new StreamableHTTPClientTransport(serverUrl, {
122
+ * authProvider: provider
123
+ * });
124
+ */
125
+ export declare class PrivateKeyJwtProvider implements OAuthClientProvider {
126
+ private _tokens?;
127
+ private _clientInfo;
128
+ private _clientMetadata;
129
+ addClientAuthentication: AddClientAuthentication;
130
+ constructor(options: PrivateKeyJwtProviderOptions);
131
+ get redirectUrl(): undefined;
132
+ get clientMetadata(): OAuthClientMetadata;
133
+ clientInformation(): OAuthClientInformation;
134
+ saveClientInformation(info: OAuthClientInformation): void;
135
+ tokens(): OAuthTokens | undefined;
136
+ saveTokens(tokens: OAuthTokens): void;
137
+ redirectToAuthorization(): void;
138
+ saveCodeVerifier(): void;
139
+ codeVerifier(): string;
140
+ prepareTokenRequest(scope?: string): URLSearchParams;
141
+ }
142
+ /**
143
+ * Options for creating a StaticPrivateKeyJwtProvider.
144
+ */
145
+ export interface StaticPrivateKeyJwtProviderOptions {
146
+ /**
147
+ * The client_id for this OAuth client.
148
+ */
149
+ clientId: string;
150
+ /**
151
+ * A pre-built JWT client assertion to use for authentication.
152
+ *
153
+ * This token should already contain the appropriate claims
154
+ * (iss, sub, aud, exp, etc.) and be signed by the client's key.
155
+ */
156
+ jwtBearerAssertion: string;
157
+ /**
158
+ * Optional client name for metadata.
159
+ */
160
+ clientName?: string;
161
+ /**
162
+ * Space-separated scopes values requested by the client.
163
+ */
164
+ scope?: string;
165
+ }
166
+ /**
167
+ * OAuth provider for client_credentials grant with a static private_key_jwt assertion.
168
+ *
169
+ * This provider mirrors {@link PrivateKeyJwtProvider} but instead of constructing and
170
+ * signing a JWT on each request, it accepts a pre-built JWT assertion string and
171
+ * uses it directly for authentication.
172
+ */
173
+ export declare class StaticPrivateKeyJwtProvider implements OAuthClientProvider {
174
+ private _tokens?;
175
+ private _clientInfo;
176
+ private _clientMetadata;
177
+ addClientAuthentication: AddClientAuthentication;
178
+ constructor(options: StaticPrivateKeyJwtProviderOptions);
179
+ get redirectUrl(): undefined;
180
+ get clientMetadata(): OAuthClientMetadata;
181
+ clientInformation(): OAuthClientInformation;
182
+ saveClientInformation(info: OAuthClientInformation): void;
183
+ tokens(): OAuthTokens | undefined;
184
+ saveTokens(tokens: OAuthTokens): void;
185
+ redirectToAuthorization(): void;
186
+ saveCodeVerifier(): void;
187
+ codeVerifier(): string;
188
+ prepareTokenRequest(scope?: string): URLSearchParams;
189
+ }
190
+ //# sourceMappingURL=auth-extensions.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"auth-extensions.d.ts","sourceRoot":"","sources":["../../../src/client/auth-extensions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEzE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,E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,IAAI;IAIzD,MAAM,IAAI,WAAW,GAAG,SAAS;IAIjC,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAIrC,uBAAuB,IAAI,IAAI;IAI/B,gBAAgB,IAAI,IAAI;IAIxB,YAAY,IAAI,MAAM;IAItB,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe;CAKvD"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ /**
3
+ * OAuth provider extensions for specialized authentication flows.
4
+ *
5
+ * This module provides ready-to-use OAuthClientProvider implementations
6
+ * for common machine-to-machine authentication scenarios.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.StaticPrivateKeyJwtProvider = exports.PrivateKeyJwtProvider = exports.ClientCredentialsProvider = void 0;
33
+ exports.createPrivateKeyJwtAuth = createPrivateKeyJwtAuth;
34
+ /**
35
+ * Helper to produce a private_key_jwt client authentication function.
36
+ *
37
+ * Usage:
38
+ * const addClientAuth = createPrivateKeyJwtAuth({ issuer, subject, privateKey, alg, audience? });
39
+ * // pass addClientAuth as provider.addClientAuthentication implementation
40
+ */
41
+ function createPrivateKeyJwtAuth(options) {
42
+ return async (_headers, params, url, metadata) => {
43
+ // Lazy import to avoid heavy dependency unless used
44
+ if (typeof globalThis.crypto === 'undefined') {
45
+ throw new TypeError('crypto is not available, please ensure you add have Web Crypto API support for older Node.js versions (see https://github.com/modelcontextprotocol/typescript-sdk#nodejs-web-crypto-globalthiscrypto-compatibility)');
46
+ }
47
+ const jose = await Promise.resolve().then(() => __importStar(require('jose')));
48
+ const audience = String(options.audience ?? metadata?.issuer ?? url);
49
+ const lifetimeSeconds = options.lifetimeSeconds ?? 300;
50
+ const now = Math.floor(Date.now() / 1000);
51
+ const jti = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
52
+ const baseClaims = {
53
+ iss: options.issuer,
54
+ sub: options.subject,
55
+ aud: audience,
56
+ exp: now + lifetimeSeconds,
57
+ iat: now,
58
+ jti
59
+ };
60
+ const claims = options.claims ? { ...baseClaims, ...options.claims } : baseClaims;
61
+ // Import key for the requested algorithm
62
+ const alg = options.alg;
63
+ let key;
64
+ if (typeof options.privateKey === 'string') {
65
+ if (alg.startsWith('RS') || alg.startsWith('ES') || alg.startsWith('PS')) {
66
+ key = await jose.importPKCS8(options.privateKey, alg);
67
+ }
68
+ else if (alg.startsWith('HS')) {
69
+ key = new TextEncoder().encode(options.privateKey);
70
+ }
71
+ else {
72
+ throw new Error(`Unsupported algorithm ${alg}`);
73
+ }
74
+ }
75
+ else if (options.privateKey instanceof Uint8Array) {
76
+ if (alg.startsWith('HS')) {
77
+ key = options.privateKey;
78
+ }
79
+ else {
80
+ // Assume PKCS#8 DER in Uint8Array for asymmetric algorithms
81
+ key = await jose.importPKCS8(new TextDecoder().decode(options.privateKey), alg);
82
+ }
83
+ }
84
+ else {
85
+ // Treat as JWK
86
+ key = await jose.importJWK(options.privateKey, alg);
87
+ }
88
+ // Sign JWT
89
+ const assertion = await new jose.SignJWT(claims)
90
+ .setProtectedHeader({ alg, typ: 'JWT' })
91
+ .setIssuer(options.issuer)
92
+ .setSubject(options.subject)
93
+ .setAudience(audience)
94
+ .setIssuedAt(now)
95
+ .setExpirationTime(now + lifetimeSeconds)
96
+ .setJti(jti)
97
+ .sign(key);
98
+ params.set('client_assertion', assertion);
99
+ params.set('client_assertion_type', 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer');
100
+ };
101
+ }
102
+ /**
103
+ * OAuth provider for client_credentials grant with client_secret_basic authentication.
104
+ *
105
+ * This provider is designed for machine-to-machine authentication where
106
+ * the client authenticates using a client_id and client_secret.
107
+ *
108
+ * @example
109
+ * const provider = new ClientCredentialsProvider({
110
+ * clientId: 'my-client',
111
+ * clientSecret: 'my-secret'
112
+ * });
113
+ *
114
+ * const transport = new StreamableHTTPClientTransport(serverUrl, {
115
+ * authProvider: provider
116
+ * });
117
+ */
118
+ class ClientCredentialsProvider {
119
+ constructor(options) {
120
+ this._clientInfo = {
121
+ client_id: options.clientId,
122
+ client_secret: options.clientSecret
123
+ };
124
+ this._clientMetadata = {
125
+ client_name: options.clientName ?? 'client-credentials-client',
126
+ redirect_uris: [],
127
+ grant_types: ['client_credentials'],
128
+ token_endpoint_auth_method: 'client_secret_basic',
129
+ scope: options.scope
130
+ };
131
+ }
132
+ get redirectUrl() {
133
+ return undefined;
134
+ }
135
+ get clientMetadata() {
136
+ return this._clientMetadata;
137
+ }
138
+ clientInformation() {
139
+ return this._clientInfo;
140
+ }
141
+ saveClientInformation(info) {
142
+ this._clientInfo = info;
143
+ }
144
+ tokens() {
145
+ return this._tokens;
146
+ }
147
+ saveTokens(tokens) {
148
+ this._tokens = tokens;
149
+ }
150
+ redirectToAuthorization() {
151
+ throw new Error('redirectToAuthorization is not used for client_credentials flow');
152
+ }
153
+ saveCodeVerifier() {
154
+ // Not used for client_credentials
155
+ }
156
+ codeVerifier() {
157
+ throw new Error('codeVerifier is not used for client_credentials flow');
158
+ }
159
+ prepareTokenRequest(scope) {
160
+ const params = new URLSearchParams({ grant_type: 'client_credentials' });
161
+ if (scope)
162
+ params.set('scope', scope);
163
+ return params;
164
+ }
165
+ }
166
+ exports.ClientCredentialsProvider = ClientCredentialsProvider;
167
+ /**
168
+ * OAuth provider for client_credentials grant with private_key_jwt authentication.
169
+ *
170
+ * This provider is designed for machine-to-machine authentication where
171
+ * the client authenticates using a signed JWT assertion (RFC 7523 Section 2.2).
172
+ *
173
+ * @example
174
+ * const provider = new PrivateKeyJwtProvider({
175
+ * clientId: 'my-client',
176
+ * privateKey: pemEncodedPrivateKey,
177
+ * algorithm: 'RS256'
178
+ * });
179
+ *
180
+ * const transport = new StreamableHTTPClientTransport(serverUrl, {
181
+ * authProvider: provider
182
+ * });
183
+ */
184
+ class PrivateKeyJwtProvider {
185
+ constructor(options) {
186
+ this._clientInfo = {
187
+ client_id: options.clientId
188
+ };
189
+ this._clientMetadata = {
190
+ client_name: options.clientName ?? 'private-key-jwt-client',
191
+ redirect_uris: [],
192
+ grant_types: ['client_credentials'],
193
+ token_endpoint_auth_method: 'private_key_jwt',
194
+ scope: options.scope
195
+ };
196
+ this.addClientAuthentication = createPrivateKeyJwtAuth({
197
+ issuer: options.clientId,
198
+ subject: options.clientId,
199
+ privateKey: options.privateKey,
200
+ alg: options.algorithm,
201
+ lifetimeSeconds: options.jwtLifetimeSeconds
202
+ });
203
+ }
204
+ get redirectUrl() {
205
+ return undefined;
206
+ }
207
+ get clientMetadata() {
208
+ return this._clientMetadata;
209
+ }
210
+ clientInformation() {
211
+ return this._clientInfo;
212
+ }
213
+ saveClientInformation(info) {
214
+ this._clientInfo = info;
215
+ }
216
+ tokens() {
217
+ return this._tokens;
218
+ }
219
+ saveTokens(tokens) {
220
+ this._tokens = tokens;
221
+ }
222
+ redirectToAuthorization() {
223
+ throw new Error('redirectToAuthorization is not used for client_credentials flow');
224
+ }
225
+ saveCodeVerifier() {
226
+ // Not used for client_credentials
227
+ }
228
+ codeVerifier() {
229
+ throw new Error('codeVerifier is not used for client_credentials flow');
230
+ }
231
+ prepareTokenRequest(scope) {
232
+ const params = new URLSearchParams({ grant_type: 'client_credentials' });
233
+ if (scope)
234
+ params.set('scope', scope);
235
+ return params;
236
+ }
237
+ }
238
+ exports.PrivateKeyJwtProvider = PrivateKeyJwtProvider;
239
+ /**
240
+ * OAuth provider for client_credentials grant with a static private_key_jwt assertion.
241
+ *
242
+ * This provider mirrors {@link PrivateKeyJwtProvider} but instead of constructing and
243
+ * signing a JWT on each request, it accepts a pre-built JWT assertion string and
244
+ * uses it directly for authentication.
245
+ */
246
+ class StaticPrivateKeyJwtProvider {
247
+ constructor(options) {
248
+ this._clientInfo = {
249
+ client_id: options.clientId
250
+ };
251
+ this._clientMetadata = {
252
+ client_name: options.clientName ?? 'static-private-key-jwt-client',
253
+ redirect_uris: [],
254
+ grant_types: ['client_credentials'],
255
+ token_endpoint_auth_method: 'private_key_jwt',
256
+ scope: options.scope
257
+ };
258
+ const assertion = options.jwtBearerAssertion;
259
+ this.addClientAuthentication = async (_headers, params) => {
260
+ params.set('client_assertion', assertion);
261
+ params.set('client_assertion_type', 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer');
262
+ };
263
+ }
264
+ get redirectUrl() {
265
+ return undefined;
266
+ }
267
+ get clientMetadata() {
268
+ return this._clientMetadata;
269
+ }
270
+ clientInformation() {
271
+ return this._clientInfo;
272
+ }
273
+ saveClientInformation(info) {
274
+ this._clientInfo = info;
275
+ }
276
+ tokens() {
277
+ return this._tokens;
278
+ }
279
+ saveTokens(tokens) {
280
+ this._tokens = tokens;
281
+ }
282
+ redirectToAuthorization() {
283
+ throw new Error('redirectToAuthorization is not used for client_credentials flow');
284
+ }
285
+ saveCodeVerifier() {
286
+ // Not used for client_credentials
287
+ }
288
+ codeVerifier() {
289
+ throw new Error('codeVerifier is not used for client_credentials flow');
290
+ }
291
+ prepareTokenRequest(scope) {
292
+ const params = new URLSearchParams({ grant_type: 'client_credentials' });
293
+ if (scope)
294
+ params.set('scope', scope);
295
+ return params;
296
+ }
297
+ }
298
+ exports.StaticPrivateKeyJwtProvider = StaticPrivateKeyJwtProvider;
299
+ //# sourceMappingURL=auth-extensions.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"auth-extensions.js","sourceRoot":"","sources":["../../../src/client/auth-extensions.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;AAaH,0DAwEC;AA/ED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CAAC,OAQvC;IACG,OAAO,K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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens, OAuthMetadata, OAuthClientInformationFull, OAuthProtectedResourceMetadata, AuthorizationServerMetadata } from '../shared/auth.js';
2
+ import { OAuthError } from '../server/auth/errors.js';
3
+ import { FetchLike } from '../shared/transport.js';
4
+ /**
5
+ * Function type for adding client authentication to token requests.
6
+ */
7
+ export type AddClientAuthentication = (headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata) => void | Promise<void>;
8
+ /**
9
+ * Implements an end-to-end OAuth client to be used with one MCP server.
10
+ *
11
+ * This client relies upon a concept of an authorized "session," the exact
12
+ * meaning of which is application-defined. Tokens, authorization codes, and
13
+ * code verifiers should not cross different sessions.
14
+ */
15
+ export interface OAuthClientProvider {
16
+ /**
17
+ * The URL to redirect the user agent to after authorization.
18
+ * Return undefined for non-interactive flows that don't require user interaction
19
+ * (e.g., client_credentials, jwt-bearer).
20
+ */
21
+ get redirectUrl(): string | URL | undefined;
22
+ /**
23
+ * External URL the server should use to fetch client metadata document
24
+ */
25
+ clientMetadataUrl?: string;
26
+ /**
27
+ * Metadata about this OAuth client.
28
+ */
29
+ get clientMetadata(): OAuthClientMetadata;
30
+ /**
31
+ * Returns a OAuth2 state parameter.
32
+ */
33
+ state?(): string | Promise<string>;
34
+ /**
35
+ * Loads information about this OAuth client, as registered already with the
36
+ * server, or returns `undefined` if the client is not registered with the
37
+ * server.
38
+ */
39
+ clientInformation(): OAuthClientInformationMixed | undefined | Promise<OAuthClientInformationMixed | undefined>;
40
+ /**
41
+ * If implemented, this permits the OAuth client to dynamically register with
42
+ * the server. Client information saved this way should later be read via
43
+ * `clientInformation()`.
44
+ *
45
+ * This method is not required to be implemented if client information is
46
+ * statically known (e.g., pre-registered).
47
+ */
48
+ saveClientInformation?(clientInformation: OAuthClientInformationMixed): void | Promise<void>;
49
+ /**
50
+ * Loads any existing OAuth tokens for the current session, or returns
51
+ * `undefined` if there are no saved tokens.
52
+ */
53
+ tokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;
54
+ /**
55
+ * Stores new OAuth tokens for the current session, after a successful
56
+ * authorization.
57
+ */
58
+ saveTokens(tokens: OAuthTokens): void | Promise<void>;
59
+ /**
60
+ * Invoked to redirect the user agent to the given URL to begin the authorization flow.
61
+ */
62
+ redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
63
+ /**
64
+ * Saves a PKCE code verifier for the current session, before redirecting to
65
+ * the authorization flow.
66
+ */
67
+ saveCodeVerifier(codeVerifier: string): void | Promise<void>;
68
+ /**
69
+ * Loads the PKCE code verifier for the current session, necessary to validate
70
+ * the authorization result.
71
+ */
72
+ codeVerifier(): string | Promise<string>;
73
+ /**
74
+ * Adds custom client authentication to OAuth token requests.
75
+ *
76
+ * This optional method allows implementations to customize how client credentials
77
+ * are included in token exchange and refresh requests. When provided, this method
78
+ * is called instead of the default authentication logic, giving full control over
79
+ * the authentication mechanism.
80
+ *
81
+ * Common use cases include:
82
+ * - Supporting authentication methods beyond the standard OAuth 2.0 methods
83
+ * - Adding custom headers for proprietary authentication schemes
84
+ * - Implementing client assertion-based authentication (e.g., JWT bearer tokens)
85
+ *
86
+ * @param headers - The request headers (can be modified to add authentication)
87
+ * @param params - The request body parameters (can be modified to add credentials)
88
+ * @param url - The token endpoint URL being called
89
+ * @param metadata - Optional OAuth metadata for the server, which may include supported authentication methods
90
+ */
91
+ addClientAuthentication?: AddClientAuthentication;
92
+ /**
93
+ * If defined, overrides the selection and validation of the
94
+ * RFC 8707 Resource Indicator. If left undefined, default
95
+ * validation behavior will be used.
96
+ *
97
+ * Implementations must verify the returned resource matches the MCP server.
98
+ */
99
+ validateResourceURL?(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
100
+ /**
101
+ * If implemented, provides a way for the client to invalidate (e.g. delete) the specified
102
+ * credentials, in the case where the server has indicated that they are no longer valid.
103
+ * This avoids requiring the user to intervene manually.
104
+ */
105
+ invalidateCredentials?(scope: 'all' | 'client' | 'tokens' | 'verifier' | 'discovery'): void | Promise<void>;
106
+ /**
107
+ * Prepares grant-specific parameters for a token request.
108
+ *
109
+ * This optional method allows providers to customize the token request based on
110
+ * the grant type they support. When implemented, it returns the grant type and
111
+ * any grant-specific parameters needed for the token exchange.
112
+ *
113
+ * If not implemented, the default behavior depends on the flow:
114
+ * - For authorization code flow: uses code, code_verifier, and redirect_uri
115
+ * - For client_credentials: detected via grant_types in clientMetadata
116
+ *
117
+ * @param scope - Optional scope to request
118
+ * @returns Grant type and parameters, or undefined to use default behavior
119
+ *
120
+ * @example
121
+ * // For client_credentials grant:
122
+ * prepareTokenRequest(scope) {
123
+ * return {
124
+ * grantType: 'client_credentials',
125
+ * params: scope ? { scope } : {}
126
+ * };
127
+ * }
128
+ *
129
+ * @example
130
+ * // For authorization_code grant (default behavior):
131
+ * async prepareTokenRequest() {
132
+ * return {
133
+ * grantType: 'authorization_code',
134
+ * params: {
135
+ * code: this.authorizationCode,
136
+ * code_verifier: await this.codeVerifier(),
137
+ * redirect_uri: String(this.redirectUrl)
138
+ * }
139
+ * };
140
+ * }
141
+ */
142
+ prepareTokenRequest?(scope?: string): URLSearchParams | Promise<URLSearchParams | undefined> | undefined;
143
+ /**
144
+ * Saves the OAuth discovery state after RFC 9728 and authorization server metadata
145
+ * discovery. Providers can persist this state to avoid redundant discovery requests
146
+ * on subsequent {@linkcode auth} calls.
147
+ *
148
+ * This state can also be provided out-of-band (e.g., from a previous session or
149
+ * external configuration) to bootstrap the OAuth flow without discovery.
150
+ *
151
+ * Called by {@linkcode auth} after successful discovery.
152
+ */
153
+ saveDiscoveryState?(state: OAuthDiscoveryState): void | Promise<void>;
154
+ /**
155
+ * Returns previously saved discovery state, or `undefined` if none is cached.
156
+ *
157
+ * When available, {@linkcode auth} restores the discovery state (authorization server
158
+ * URL, resource metadata, etc.) instead of performing RFC 9728 discovery, reducing
159
+ * latency on subsequent calls.
160
+ *
161
+ * Providers should clear cached discovery state on repeated authentication failures
162
+ * (via {@linkcode invalidateCredentials} with scope `'discovery'` or `'all'`) to allow
163
+ * re-discovery in case the authorization server has changed.
164
+ */
165
+ discoveryState?(): OAuthDiscoveryState | undefined | Promise<OAuthDiscoveryState | undefined>;
166
+ }
167
+ /**
168
+ * Discovery state that can be persisted across sessions by an {@linkcode OAuthClientProvider}.
169
+ *
170
+ * Contains the results of RFC 9728 protected resource metadata discovery and
171
+ * authorization server metadata discovery. Persisting this state avoids
172
+ * redundant discovery HTTP requests on subsequent {@linkcode auth} calls.
173
+ */
174
+ export interface OAuthDiscoveryState extends OAuthServerInfo {
175
+ /** The URL at which the protected resource metadata was found, if available. */
176
+ resourceMetadataUrl?: string;
177
+ }
178
+ export type AuthResult = 'AUTHORIZED' | 'REDIRECT';
179
+ export declare class UnauthorizedError extends Error {
180
+ constructor(message?: string);
181
+ }
182
+ type ClientAuthMethod = 'client_secret_basic' | 'client_secret_post' | 'none';
183
+ /**
184
+ * Determines the best client authentication method to use based on server support and client configuration.
185
+ *
186
+ * Priority order (highest to lowest):
187
+ * 1. client_secret_basic (if client secret is available)
188
+ * 2. client_secret_post (if client secret is available)
189
+ * 3. none (for public clients)
190
+ *
191
+ * @param clientInformation - OAuth client information containing credentials
192
+ * @param supportedMethods - Authentication methods supported by the authorization server
193
+ * @returns The selected authentication method
194
+ */
195
+ export declare function selectClientAuthMethod(clientInformation: OAuthClientInformationMixed, supportedMethods: string[]): ClientAuthMethod;
196
+ /**
197
+ * Parses an OAuth error response from a string or Response object.
198
+ *
199
+ * If the input is a standard OAuth2.0 error response, it will be parsed according to the spec
200
+ * and an instance of the appropriate OAuthError subclass will be returned.
201
+ * If parsing fails, it falls back to a generic ServerError that includes
202
+ * the response status (if available) and original content.
203
+ *
204
+ * @param input - A Response object or string containing the error response
205
+ * @returns A Promise that resolves to an OAuthError instance
206
+ */
207
+ export declare function parseErrorResponse(input: Response | string): Promise<OAuthError>;
208
+ /**
209
+ * Orchestrates the full auth flow with a server.
210
+ *
211
+ * This can be used as a single entry point for all authorization functionality,
212
+ * instead of linking together the other lower-level functions in this module.
213
+ */
214
+ export declare function auth(provider: OAuthClientProvider, options: {
215
+ serverUrl: string | URL;
216
+ authorizationCode?: string;
217
+ scope?: string;
218
+ resourceMetadataUrl?: URL;
219
+ fetchFn?: FetchLike;
220
+ }): Promise<AuthResult>;
221
+ /**
222
+ * SEP-991: URL-based Client IDs
223
+ * Validate that the client_id is a valid URL with https scheme
224
+ */
225
+ export declare function isHttpsUrl(value?: string): boolean;
226
+ export declare function selectResourceURL(serverUrl: string | URL, provider: OAuthClientProvider, resourceMetadata?: OAuthProtectedResourceMetadata): Promise<URL | undefined>;
227
+ /**
228
+ * Extract resource_metadata, scope, and error from WWW-Authenticate header.
229
+ */
230
+ export declare function extractWWWAuthenticateParams(res: Response): {
231
+ resourceMetadataUrl?: URL;
232
+ scope?: string;
233
+ error?: string;
234
+ };
235
+ /**
236
+ * Extract resource_metadata from response header.
237
+ * @deprecated Use `extractWWWAuthenticateParams` instead.
238
+ */
239
+ export declare function extractResourceMetadataUrl(res: Response): URL | undefined;
240
+ /**
241
+ * Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.
242
+ *
243
+ * If the server returns a 404 for the well-known endpoint, this function will
244
+ * return `undefined`. Any other errors will be thrown as exceptions.
245
+ */
246
+ export declare function discoverOAuthProtectedResourceMetadata(serverUrl: string | URL, opts?: {
247
+ protocolVersion?: string;
248
+ resourceMetadataUrl?: string | URL;
249
+ }, fetchFn?: FetchLike): Promise<OAuthProtectedResourceMetadata>;
250
+ /**
251
+ * Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.
252
+ *
253
+ * If the server returns a 404 for the well-known endpoint, this function will
254
+ * return `undefined`. Any other errors will be thrown as exceptions.
255
+ *
256
+ * @deprecated This function is deprecated in favor of `discoverAuthorizationServerMetadata`.
257
+ */
258
+ export declare function discoverOAuthMetadata(issuer: string | URL, { authorizationServerUrl, protocolVersion }?: {
259
+ authorizationServerUrl?: string | URL;
260
+ protocolVersion?: string;
261
+ }, fetchFn?: FetchLike): Promise<OAuthMetadata | undefined>;
262
+ /**
263
+ * Builds a list of discovery URLs to try for authorization server metadata.
264
+ * URLs are returned in priority order:
265
+ * 1. OAuth metadata at the given URL
266
+ * 2. OIDC metadata endpoints at the given URL
267
+ */
268
+ export declare function buildDiscoveryUrls(authorizationServerUrl: string | URL): {
269
+ url: URL;
270
+ type: 'oauth' | 'oidc';
271
+ }[];
272
+ /**
273
+ * Discovers authorization server metadata with support for RFC 8414 OAuth 2.0 Authorization Server Metadata
274
+ * and OpenID Connect Discovery 1.0 specifications.
275
+ *
276
+ * This function implements a fallback strategy for authorization server discovery:
277
+ * 1. Attempts RFC 8414 OAuth metadata discovery first
278
+ * 2. If OAuth discovery fails, falls back to OpenID Connect Discovery
279
+ *
280
+ * @param authorizationServerUrl - The authorization server URL obtained from the MCP Server's
281
+ * protected resource metadata, or the MCP server's URL if the
282
+ * metadata was not found.
283
+ * @param options - Configuration options
284
+ * @param options.fetchFn - Optional fetch function for making HTTP requests, defaults to global fetch
285
+ * @param options.protocolVersion - MCP protocol version to use, defaults to LATEST_PROTOCOL_VERSION
286
+ * @returns Promise resolving to authorization server metadata, or undefined if discovery fails
287
+ */
288
+ export declare function discoverAuthorizationServerMetadata(authorizationServerUrl: string | URL, { fetchFn, protocolVersion }?: {
289
+ fetchFn?: FetchLike;
290
+ protocolVersion?: string;
291
+ }): Promise<AuthorizationServerMetadata | undefined>;
292
+ /**
293
+ * Result of {@linkcode discoverOAuthServerInfo}.
294
+ */
295
+ export interface OAuthServerInfo {
296
+ /**
297
+ * The authorization server URL, either discovered via RFC 9728
298
+ * or derived from the MCP server URL as a fallback.
299
+ */
300
+ authorizationServerUrl: string;
301
+ /**
302
+ * The authorization server metadata (endpoints, capabilities),
303
+ * or `undefined` if metadata discovery failed.
304
+ */
305
+ authorizationServerMetadata?: AuthorizationServerMetadata;
306
+ /**
307
+ * The OAuth 2.0 Protected Resource Metadata from RFC 9728,
308
+ * or `undefined` if the server does not support it.
309
+ */
310
+ resourceMetadata?: OAuthProtectedResourceMetadata;
311
+ }
312
+ /**
313
+ * Discovers the authorization server for an MCP server following
314
+ * {@link https://datatracker.ietf.org/doc/html/rfc9728 | RFC 9728} (OAuth 2.0 Protected
315
+ * Resource Metadata), with fallback to treating the server URL as the
316
+ * authorization server.
317
+ *
318
+ * This function combines two discovery steps into one call:
319
+ * 1. Probes `/.well-known/oauth-protected-resource` on the MCP server to find the
320
+ * authorization server URL (RFC 9728).
321
+ * 2. Fetches authorization server metadata from that URL (RFC 8414 / OpenID Connect Discovery).
322
+ *
323
+ * Use this when you need the authorization server metadata for operations outside the
324
+ * {@linkcode auth} orchestrator, such as token refresh or token revocation.
325
+ *
326
+ * @param serverUrl - The MCP resource server URL
327
+ * @param opts - Optional configuration
328
+ * @param opts.resourceMetadataUrl - Override URL for the protected resource metadata endpoint
329
+ * @param opts.fetchFn - Custom fetch function for HTTP requests
330
+ * @returns Authorization server URL, metadata, and resource metadata (if available)
331
+ */
332
+ export declare function discoverOAuthServerInfo(serverUrl: string | URL, opts?: {
333
+ resourceMetadataUrl?: URL;
334
+ fetchFn?: FetchLike;
335
+ }): Promise<OAuthServerInfo>;
336
+ /**
337
+ * Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.
338
+ */
339
+ export declare function startAuthorization(authorizationServerUrl: string | URL, { metadata, clientInformation, redirectUrl, scope, state, resource }: {
340
+ metadata?: AuthorizationServerMetadata;
341
+ clientInformation: OAuthClientInformationMixed;
342
+ redirectUrl: string | URL;
343
+ scope?: string;
344
+ state?: string;
345
+ resource?: URL;
346
+ }): Promise<{
347
+ authorizationUrl: URL;
348
+ codeVerifier: string;
349
+ }>;
350
+ /**
351
+ * Prepares token request parameters for an authorization code exchange.
352
+ *
353
+ * This is the default implementation used by fetchToken when the provider
354
+ * doesn't implement prepareTokenRequest.
355
+ *
356
+ * @param authorizationCode - The authorization code received from the authorization endpoint
357
+ * @param codeVerifier - The PKCE code verifier
358
+ * @param redirectUri - The redirect URI used in the authorization request
359
+ * @returns URLSearchParams for the authorization_code grant
360
+ */
361
+ export declare function prepareAuthorizationCodeRequest(authorizationCode: string, codeVerifier: string, redirectUri: string | URL): URLSearchParams;
362
+ /**
363
+ * Exchanges an authorization code for an access token with the given server.
364
+ *
365
+ * Supports multiple client authentication methods as specified in OAuth 2.1:
366
+ * - Automatically selects the best authentication method based on server support
367
+ * - Falls back to appropriate defaults when server metadata is unavailable
368
+ *
369
+ * @param authorizationServerUrl - The authorization server's base URL
370
+ * @param options - Configuration object containing client info, auth code, etc.
371
+ * @returns Promise resolving to OAuth tokens
372
+ * @throws {Error} When token exchange fails or authentication is invalid
373
+ */
374
+ export declare function exchangeAuthorization(authorizationServerUrl: string | URL, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication, fetchFn }: {
375
+ metadata?: AuthorizationServerMetadata;
376
+ clientInformation: OAuthClientInformationMixed;
377
+ authorizationCode: string;
378
+ codeVerifier: string;
379
+ redirectUri: string | URL;
380
+ resource?: URL;
381
+ addClientAuthentication?: OAuthClientProvider['addClientAuthentication'];
382
+ fetchFn?: FetchLike;
383
+ }): Promise<OAuthTokens>;
384
+ /**
385
+ * Exchange a refresh token for an updated access token.
386
+ *
387
+ * Supports multiple client authentication methods as specified in OAuth 2.1:
388
+ * - Automatically selects the best authentication method based on server support
389
+ * - Preserves the original refresh token if a new one is not returned
390
+ *
391
+ * @param authorizationServerUrl - The authorization server's base URL
392
+ * @param options - Configuration object containing client info, refresh token, etc.
393
+ * @returns Promise resolving to OAuth tokens (preserves original refresh_token if not replaced)
394
+ * @throws {Error} When token refresh fails or authentication is invalid
395
+ */
396
+ export declare function refreshAuthorization(authorizationServerUrl: string | URL, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }: {
397
+ metadata?: AuthorizationServerMetadata;
398
+ clientInformation: OAuthClientInformationMixed;
399
+ refreshToken: string;
400
+ resource?: URL;
401
+ addClientAuthentication?: OAuthClientProvider['addClientAuthentication'];
402
+ fetchFn?: FetchLike;
403
+ }): Promise<OAuthTokens>;
404
+ /**
405
+ * Unified token fetching that works with any grant type via provider.prepareTokenRequest().
406
+ *
407
+ * This function provides a single entry point for obtaining tokens regardless of the
408
+ * OAuth grant type. The provider's prepareTokenRequest() method determines which grant
409
+ * to use and supplies the grant-specific parameters.
410
+ *
411
+ * @param provider - OAuth client provider that implements prepareTokenRequest()
412
+ * @param authorizationServerUrl - The authorization server's base URL
413
+ * @param options - Configuration for the token request
414
+ * @returns Promise resolving to OAuth tokens
415
+ * @throws {Error} When provider doesn't implement prepareTokenRequest or token fetch fails
416
+ *
417
+ * @example
418
+ * // Provider for client_credentials:
419
+ * class MyProvider implements OAuthClientProvider {
420
+ * prepareTokenRequest(scope) {
421
+ * const params = new URLSearchParams({ grant_type: 'client_credentials' });
422
+ * if (scope) params.set('scope', scope);
423
+ * return params;
424
+ * }
425
+ * // ... other methods
426
+ * }
427
+ *
428
+ * const tokens = await fetchToken(provider, authServerUrl, { metadata });
429
+ */
430
+ export declare function fetchToken(provider: OAuthClientProvider, authorizationServerUrl: string | URL, { metadata, resource, authorizationCode, fetchFn }?: {
431
+ metadata?: AuthorizationServerMetadata;
432
+ resource?: URL;
433
+ /** Authorization code for the default authorization_code grant flow */
434
+ authorizationCode?: string;
435
+ fetchFn?: FetchLike;
436
+ }): Promise<OAuthTokens>;
437
+ /**
438
+ * Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.
439
+ *
440
+ * If `scope` is provided, it overrides `clientMetadata.scope` in the registration
441
+ * request body. This allows callers to apply the Scope Selection Strategy (SEP-835)
442
+ * consistently across both DCR and the subsequent authorization request.
443
+ */
444
+ export declare function registerClient(authorizationServerUrl: string | URL, { metadata, clientMetadata, scope, fetchFn }: {
445
+ metadata?: AuthorizationServerMetadata;
446
+ clientMetadata: OAuthClientMetadata;
447
+ scope?: string;
448
+ fetchFn?: FetchLike;
449
+ }): Promise<OAuthClientInformationFull>;
450
+ export {};
451
+ //# sourceMappingURL=auth.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/client/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,mBAAmB,EAEnB,2BAA2B,EAC3B,WAAW,EACX,aAAa,EACb,0BAA0B,EAC1B,8BAA8B,EAE9B,2BAA2B,EAE9B,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAKH,UAAU,EAGb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAClC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UnauthorizedError = void 0;
7
+ exports.selectClientAuthMethod = selectClientAuthMethod;
8
+ exports.parseErrorResponse = parseErrorResponse;
9
+ exports.auth = auth;
10
+ exports.isHttpsUrl = isHttpsUrl;
11
+ exports.selectResourceURL = selectResourceURL;
12
+ exports.extractWWWAuthenticateParams = extractWWWAuthenticateParams;
13
+ exports.extractResourceMetadataUrl = extractResourceMetadataUrl;
14
+ exports.discoverOAuthProtectedResourceMetadata = discoverOAuthProtectedResourceMetadata;
15
+ exports.discoverOAuthMetadata = discoverOAuthMetadata;
16
+ exports.buildDiscoveryUrls = buildDiscoveryUrls;
17
+ exports.discoverAuthorizationServerMetadata = discoverAuthorizationServerMetadata;
18
+ exports.discoverOAuthServerInfo = discoverOAuthServerInfo;
19
+ exports.startAuthorization = startAuthorization;
20
+ exports.prepareAuthorizationCodeRequest = prepareAuthorizationCodeRequest;
21
+ exports.exchangeAuthorization = exchangeAuthorization;
22
+ exports.refreshAuthorization = refreshAuthorization;
23
+ exports.fetchToken = fetchToken;
24
+ exports.registerClient = registerClient;
25
+ const pkce_challenge_1 = __importDefault(require("pkce-challenge"));
26
+ const types_js_1 = require("../types.js");
27
+ const auth_js_1 = require("../shared/auth.js");
28
+ const auth_js_2 = require("../shared/auth.js");
29
+ const auth_utils_js_1 = require("../shared/auth-utils.js");
30
+ const errors_js_1 = require("../server/auth/errors.js");
31
+ class UnauthorizedError extends Error {
32
+ constructor(message) {
33
+ super(message ?? 'Unauthorized');
34
+ }
35
+ }
36
+ exports.UnauthorizedError = UnauthorizedError;
37
+ function isClientAuthMethod(method) {
38
+ return ['client_secret_basic', 'client_secret_post', 'none'].includes(method);
39
+ }
40
+ const AUTHORIZATION_CODE_RESPONSE_TYPE = 'code';
41
+ const AUTHORIZATION_CODE_CHALLENGE_METHOD = 'S256';
42
+ /**
43
+ * Determines the best client authentication method to use based on server support and client configuration.
44
+ *
45
+ * Priority order (highest to lowest):
46
+ * 1. client_secret_basic (if client secret is available)
47
+ * 2. client_secret_post (if client secret is available)
48
+ * 3. none (for public clients)
49
+ *
50
+ * @param clientInformation - OAuth client information containing credentials
51
+ * @param supportedMethods - Authentication methods supported by the authorization server
52
+ * @returns The selected authentication method
53
+ */
54
+ function selectClientAuthMethod(clientInformation, supportedMethods) {
55
+ const hasClientSecret = clientInformation.client_secret !== undefined;
56
+ // Prefer the method returned by the server during client registration, if valid.
57
+ // When server metadata is present we also require the method to be listed as supported;
58
+ // when supportedMethods is empty (metadata omitted the field) the DCR hint stands alone.
59
+ if ('token_endpoint_auth_method' in clientInformation &&
60
+ clientInformation.token_endpoint_auth_method &&
61
+ isClientAuthMethod(clientInformation.token_endpoint_auth_method) &&
62
+ (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method))) {
63
+ return clientInformation.token_endpoint_auth_method;
64
+ }
65
+ // If server metadata omits token_endpoint_auth_methods_supported, RFC 8414 §2 says the
66
+ // default is client_secret_basic. RFC 6749 §2.3.1 also requires servers to support HTTP
67
+ // Basic authentication for clients with a secret, making it the safest default.
68
+ if (supportedMethods.length === 0) {
69
+ return hasClientSecret ? 'client_secret_basic' : 'none';
70
+ }
71
+ // Try methods in priority order (most secure first)
72
+ if (hasClientSecret && supportedMethods.includes('client_secret_basic')) {
73
+ return 'client_secret_basic';
74
+ }
75
+ if (hasClientSecret && supportedMethods.includes('client_secret_post')) {
76
+ return 'client_secret_post';
77
+ }
78
+ if (supportedMethods.includes('none')) {
79
+ return 'none';
80
+ }
81
+ // Fallback: use what we have
82
+ return hasClientSecret ? 'client_secret_post' : 'none';
83
+ }
84
+ /**
85
+ * Applies client authentication to the request based on the specified method.
86
+ *
87
+ * Implements OAuth 2.1 client authentication methods:
88
+ * - client_secret_basic: HTTP Basic authentication (RFC 6749 Section 2.3.1)
89
+ * - client_secret_post: Credentials in request body (RFC 6749 Section 2.3.1)
90
+ * - none: Public client authentication (RFC 6749 Section 2.1)
91
+ *
92
+ * @param method - The authentication method to use
93
+ * @param clientInformation - OAuth client information containing credentials
94
+ * @param headers - HTTP headers object to modify
95
+ * @param params - URL search parameters to modify
96
+ * @throws {Error} When required credentials are missing
97
+ */
98
+ function applyClientAuthentication(method, clientInformation, headers, params) {
99
+ const { client_id, client_secret } = clientInformation;
100
+ switch (method) {
101
+ case 'client_secret_basic':
102
+ applyBasicAuth(client_id, client_secret, headers);
103
+ return;
104
+ case 'client_secret_post':
105
+ applyPostAuth(client_id, client_secret, params);
106
+ return;
107
+ case 'none':
108
+ applyPublicAuth(client_id, params);
109
+ return;
110
+ default:
111
+ throw new Error(`Unsupported client authentication method: ${method}`);
112
+ }
113
+ }
114
+ /**
115
+ * Applies HTTP Basic authentication (RFC 6749 Section 2.3.1)
116
+ */
117
+ function applyBasicAuth(clientId, clientSecret, headers) {
118
+ if (!clientSecret) {
119
+ throw new Error('client_secret_basic authentication requires a client_secret');
120
+ }
121
+ const credentials = btoa(`${clientId}:${clientSecret}`);
122
+ headers.set('Authorization', `Basic ${credentials}`);
123
+ }
124
+ /**
125
+ * Applies POST body authentication (RFC 6749 Section 2.3.1)
126
+ */
127
+ function applyPostAuth(clientId, clientSecret, params) {
128
+ params.set('client_id', clientId);
129
+ if (clientSecret) {
130
+ params.set('client_secret', clientSecret);
131
+ }
132
+ }
133
+ /**
134
+ * Applies public client authentication (RFC 6749 Section 2.1)
135
+ */
136
+ function applyPublicAuth(clientId, params) {
137
+ params.set('client_id', clientId);
138
+ }
139
+ /**
140
+ * Parses an OAuth error response from a string or Response object.
141
+ *
142
+ * If the input is a standard OAuth2.0 error response, it will be parsed according to the spec
143
+ * and an instance of the appropriate OAuthError subclass will be returned.
144
+ * If parsing fails, it falls back to a generic ServerError that includes
145
+ * the response status (if available) and original content.
146
+ *
147
+ * @param input - A Response object or string containing the error response
148
+ * @returns A Promise that resolves to an OAuthError instance
149
+ */
150
+ async function parseErrorResponse(input) {
151
+ const statusCode = input instanceof Response ? input.status : undefined;
152
+ const body = input instanceof Response ? await input.text() : input;
153
+ try {
154
+ const result = auth_js_1.OAuthErrorResponseSchema.parse(JSON.parse(body));
155
+ const { error, error_description, error_uri } = result;
156
+ const errorClass = errors_js_1.OAUTH_ERRORS[error] || errors_js_1.ServerError;
157
+ return new errorClass(error_description || '', error_uri);
158
+ }
159
+ catch (error) {
160
+ // Not a valid OAuth error response, but try to inform the user of the raw data anyway
161
+ const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ''}Invalid OAuth error response: ${error}. Raw body: ${body}`;
162
+ return new errors_js_1.ServerError(errorMessage);
163
+ }
164
+ }
165
+ /**
166
+ * Orchestrates the full auth flow with a server.
167
+ *
168
+ * This can be used as a single entry point for all authorization functionality,
169
+ * instead of linking together the other lower-level functions in this module.
170
+ */
171
+ async function auth(provider, options) {
172
+ try {
173
+ return await authInternal(provider, options);
174
+ }
175
+ catch (error) {
176
+ // Handle recoverable error types by invalidating credentials and retrying
177
+ if (error instanceof errors_js_1.InvalidClientError || error instanceof errors_js_1.UnauthorizedClientError) {
178
+ await provider.invalidateCredentials?.('all');
179
+ return await authInternal(provider, options);
180
+ }
181
+ else if (error instanceof errors_js_1.InvalidGrantError) {
182
+ await provider.invalidateCredentials?.('tokens');
183
+ return await authInternal(provider, options);
184
+ }
185
+ // Throw otherwise
186
+ throw error;
187
+ }
188
+ }
189
+ async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
190
+ // Check if the provider has cached discovery state to skip discovery
191
+ const cachedState = await provider.discoveryState?.();
192
+ let resourceMetadata;
193
+ let authorizationServerUrl;
194
+ let metadata;
195
+ // If resourceMetadataUrl is not provided, try to load it from cached state
196
+ // This handles browser redirects where the URL was saved before navigation
197
+ let effectiveResourceMetadataUrl = resourceMetadataUrl;
198
+ if (!effectiveResourceMetadataUrl && cachedState?.resourceMetadataUrl) {
199
+ effectiveResourceMetadataUrl = new URL(cachedState.resourceMetadataUrl);
200
+ }
201
+ if (cachedState?.authorizationServerUrl) {
202
+ // Restore discovery state from cache
203
+ authorizationServerUrl = cachedState.authorizationServerUrl;
204
+ resourceMetadata = cachedState.resourceMetadata;
205
+ metadata =
206
+ cachedState.authorizationServerMetadata ?? (await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn }));
207
+ // If resource metadata wasn't cached, try to fetch it for selectResourceURL
208
+ if (!resourceMetadata) {
209
+ try {
210
+ resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl }, fetchFn);
211
+ }
212
+ catch {
213
+ // RFC 9728 not available — selectResourceURL will handle undefined
214
+ }
215
+ }
216
+ // Re-save if we enriched the cached state with missing metadata
217
+ if (metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) {
218
+ await provider.saveDiscoveryState?.({
219
+ authorizationServerUrl: String(authorizationServerUrl),
220
+ resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
221
+ resourceMetadata,
222
+ authorizationServerMetadata: metadata
223
+ });
224
+ }
225
+ }
226
+ else {
227
+ // Full discovery via RFC 9728
228
+ const serverInfo = await discoverOAuthServerInfo(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl, fetchFn });
229
+ authorizationServerUrl = serverInfo.authorizationServerUrl;
230
+ metadata = serverInfo.authorizationServerMetadata;
231
+ resourceMetadata = serverInfo.resourceMetadata;
232
+ // Persist discovery state for future use
233
+ // TODO: resourceMetadataUrl is only populated when explicitly provided via options
234
+ // or loaded from cached state. The URL derived internally by
235
+ // discoverOAuthProtectedResourceMetadata() is not captured back here.
236
+ await provider.saveDiscoveryState?.({
237
+ authorizationServerUrl: String(authorizationServerUrl),
238
+ resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
239
+ resourceMetadata,
240
+ authorizationServerMetadata: metadata
241
+ });
242
+ }
243
+ const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
244
+ // Apply scope selection strategy (SEP-835):
245
+ // 1. WWW-Authenticate scope (passed via `scope` param)
246
+ // 2. PRM scopes_supported
247
+ // 3. Client metadata scope (user-configured fallback)
248
+ // The resolved scope is used consistently for both DCR and the authorization request.
249
+ const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(' ') || provider.clientMetadata.scope;
250
+ // Handle client registration if needed
251
+ let clientInformation = await Promise.resolve(provider.clientInformation());
252
+ if (!clientInformation) {
253
+ if (authorizationCode !== undefined) {
254
+ throw new Error('Existing OAuth client information is required when exchanging an authorization code');
255
+ }
256
+ const supportsUrlBasedClientId = metadata?.client_id_metadata_document_supported === true;
257
+ const clientMetadataUrl = provider.clientMetadataUrl;
258
+ if (clientMetadataUrl && !isHttpsUrl(clientMetadataUrl)) {
259
+ throw new errors_js_1.InvalidClientMetadataError(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${clientMetadataUrl}`);
260
+ }
261
+ const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
262
+ if (shouldUseUrlBasedClientId) {
263
+ // SEP-991: URL-based Client IDs
264
+ clientInformation = {
265
+ client_id: clientMetadataUrl
266
+ };
267
+ await provider.saveClientInformation?.(clientInformation);
268
+ }
269
+ else {
270
+ // Fallback to dynamic registration
271
+ if (!provider.saveClientInformation) {
272
+ throw new Error('OAuth client information must be saveable for dynamic registration');
273
+ }
274
+ const fullInformation = await registerClient(authorizationServerUrl, {
275
+ metadata,
276
+ clientMetadata: provider.clientMetadata,
277
+ scope: resolvedScope,
278
+ fetchFn
279
+ });
280
+ await provider.saveClientInformation(fullInformation);
281
+ clientInformation = fullInformation;
282
+ }
283
+ }
284
+ // Non-interactive flows (e.g., client_credentials, jwt-bearer) don't need a redirect URL
285
+ const nonInteractiveFlow = !provider.redirectUrl;
286
+ // Exchange authorization code for tokens, or fetch tokens directly for non-interactive flows
287
+ if (authorizationCode !== undefined || nonInteractiveFlow) {
288
+ const tokens = await fetchToken(provider, authorizationServerUrl, {
289
+ metadata,
290
+ resource,
291
+ authorizationCode,
292
+ fetchFn
293
+ });
294
+ await provider.saveTokens(tokens);
295
+ return 'AUTHORIZED';
296
+ }
297
+ const tokens = await provider.tokens();
298
+ // Handle token refresh or new authorization
299
+ if (tokens?.refresh_token) {
300
+ try {
301
+ // Attempt to refresh the token
302
+ const newTokens = await refreshAuthorization(authorizationServerUrl, {
303
+ metadata,
304
+ clientInformation,
305
+ refreshToken: tokens.refresh_token,
306
+ resource,
307
+ addClientAuthentication: provider.addClientAuthentication,
308
+ fetchFn
309
+ });
310
+ await provider.saveTokens(newTokens);
311
+ return 'AUTHORIZED';
312
+ }
313
+ catch (error) {
314
+ // If this is a ServerError, or an unknown type, log it out and try to continue. Otherwise, escalate so we can fix things and retry.
315
+ if (!(error instanceof errors_js_1.OAuthError) || error instanceof errors_js_1.ServerError) {
316
+ // Could not refresh OAuth tokens
317
+ }
318
+ else {
319
+ // Refresh failed for another reason, re-throw
320
+ throw error;
321
+ }
322
+ }
323
+ }
324
+ const state = provider.state ? await provider.state() : undefined;
325
+ // Start new authorization flow
326
+ const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {
327
+ metadata,
328
+ clientInformation,
329
+ state,
330
+ redirectUrl: provider.redirectUrl,
331
+ scope: resolvedScope,
332
+ resource
333
+ });
334
+ await provider.saveCodeVerifier(codeVerifier);
335
+ await provider.redirectToAuthorization(authorizationUrl);
336
+ return 'REDIRECT';
337
+ }
338
+ /**
339
+ * SEP-991: URL-based Client IDs
340
+ * Validate that the client_id is a valid URL with https scheme
341
+ */
342
+ function isHttpsUrl(value) {
343
+ if (!value)
344
+ return false;
345
+ try {
346
+ const url = new URL(value);
347
+ return url.protocol === 'https:' && url.pathname !== '/';
348
+ }
349
+ catch {
350
+ return false;
351
+ }
352
+ }
353
+ async function selectResourceURL(serverUrl, provider, resourceMetadata) {
354
+ const defaultResource = (0, auth_utils_js_1.resourceUrlFromServerUrl)(serverUrl);
355
+ // If provider has custom validation, delegate to it
356
+ if (provider.validateResourceURL) {
357
+ return await provider.validateResourceURL(defaultResource, resourceMetadata?.resource);
358
+ }
359
+ // Only include resource parameter when Protected Resource Metadata is present
360
+ if (!resourceMetadata) {
361
+ return undefined;
362
+ }
363
+ // Validate that the metadata's resource is compatible with our request
364
+ if (!(0, auth_utils_js_1.checkResourceAllowed)({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {
365
+ throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);
366
+ }
367
+ // Prefer the resource from metadata since it's what the server is telling us to request
368
+ return new URL(resourceMetadata.resource);
369
+ }
370
+ /**
371
+ * Extract resource_metadata, scope, and error from WWW-Authenticate header.
372
+ */
373
+ function extractWWWAuthenticateParams(res) {
374
+ const authenticateHeader = res.headers.get('WWW-Authenticate');
375
+ if (!authenticateHeader) {
376
+ return {};
377
+ }
378
+ const [type, scheme] = authenticateHeader.split(' ');
379
+ if (type.toLowerCase() !== 'bearer' || !scheme) {
380
+ return {};
381
+ }
382
+ const resourceMetadataMatch = extractFieldFromWwwAuth(res, 'resource_metadata') || undefined;
383
+ let resourceMetadataUrl;
384
+ if (resourceMetadataMatch) {
385
+ try {
386
+ resourceMetadataUrl = new URL(resourceMetadataMatch);
387
+ }
388
+ catch {
389
+ // Ignore invalid URL
390
+ }
391
+ }
392
+ const scope = extractFieldFromWwwAuth(res, 'scope') || undefined;
393
+ const error = extractFieldFromWwwAuth(res, 'error') || undefined;
394
+ return {
395
+ resourceMetadataUrl,
396
+ scope,
397
+ error
398
+ };
399
+ }
400
+ /**
401
+ * Extracts a specific field's value from the WWW-Authenticate header string.
402
+ *
403
+ * @param response The HTTP response object containing the headers.
404
+ * @param fieldName The name of the field to extract (e.g., "realm", "nonce").
405
+ * @returns The field value
406
+ */
407
+ function extractFieldFromWwwAuth(response, fieldName) {
408
+ const wwwAuthHeader = response.headers.get('WWW-Authenticate');
409
+ if (!wwwAuthHeader) {
410
+ return null;
411
+ }
412
+ const pattern = new RegExp(`${fieldName}=(?:"([^"]+)"|([^\\s,]+))`);
413
+ const match = wwwAuthHeader.match(pattern);
414
+ if (match) {
415
+ // Pattern matches: field_name="value" or field_name=value (unquoted)
416
+ return match[1] || match[2];
417
+ }
418
+ return null;
419
+ }
420
+ /**
421
+ * Extract resource_metadata from response header.
422
+ * @deprecated Use `extractWWWAuthenticateParams` instead.
423
+ */
424
+ function extractResourceMetadataUrl(res) {
425
+ const authenticateHeader = res.headers.get('WWW-Authenticate');
426
+ if (!authenticateHeader) {
427
+ return undefined;
428
+ }
429
+ const [type, scheme] = authenticateHeader.split(' ');
430
+ if (type.toLowerCase() !== 'bearer' || !scheme) {
431
+ return undefined;
432
+ }
433
+ const regex = /resource_metadata="([^"]*)"/;
434
+ const match = regex.exec(authenticateHeader);
435
+ if (!match) {
436
+ return undefined;
437
+ }
438
+ try {
439
+ return new URL(match[1]);
440
+ }
441
+ catch {
442
+ return undefined;
443
+ }
444
+ }
445
+ /**
446
+ * Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.
447
+ *
448
+ * If the server returns a 404 for the well-known endpoint, this function will
449
+ * return `undefined`. Any other errors will be thrown as exceptions.
450
+ */
451
+ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
452
+ const response = await discoverMetadataWithFallback(serverUrl, 'oauth-protected-resource', fetchFn, {
453
+ protocolVersion: opts?.protocolVersion,
454
+ metadataUrl: opts?.resourceMetadataUrl
455
+ });
456
+ if (!response || response.status === 404) {
457
+ await response?.body?.cancel();
458
+ throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
459
+ }
460
+ if (!response.ok) {
461
+ await response.body?.cancel();
462
+ throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
463
+ }
464
+ return auth_js_2.OAuthProtectedResourceMetadataSchema.parse(await response.json());
465
+ }
466
+ /**
467
+ * Helper function to handle fetch with CORS retry logic
468
+ */
469
+ async function fetchWithCorsRetry(url, headers, fetchFn = fetch) {
470
+ try {
471
+ return await fetchFn(url, { headers });
472
+ }
473
+ catch (error) {
474
+ if (error instanceof TypeError) {
475
+ if (headers) {
476
+ // CORS errors come back as TypeError, retry without headers
477
+ return fetchWithCorsRetry(url, undefined, fetchFn);
478
+ }
479
+ else {
480
+ // We're getting CORS errors on retry too, return undefined
481
+ return undefined;
482
+ }
483
+ }
484
+ throw error;
485
+ }
486
+ }
487
+ /**
488
+ * Constructs the well-known path for auth-related metadata discovery
489
+ */
490
+ function buildWellKnownPath(wellKnownPrefix, pathname = '', options = {}) {
491
+ // Strip trailing slash from pathname to avoid double slashes
492
+ if (pathname.endsWith('/')) {
493
+ pathname = pathname.slice(0, -1);
494
+ }
495
+ return options.prependPathname ? `${pathname}/.well-known/${wellKnownPrefix}` : `/.well-known/${wellKnownPrefix}${pathname}`;
496
+ }
497
+ /**
498
+ * Tries to discover OAuth metadata at a specific URL
499
+ */
500
+ async function tryMetadataDiscovery(url, protocolVersion, fetchFn = fetch) {
501
+ const headers = {
502
+ 'MCP-Protocol-Version': protocolVersion
503
+ };
504
+ return await fetchWithCorsRetry(url, headers, fetchFn);
505
+ }
506
+ /**
507
+ * Determines if fallback to root discovery should be attempted
508
+ */
509
+ function shouldAttemptFallback(response, pathname) {
510
+ return !response || (response.status >= 400 && response.status < 500 && pathname !== '/');
511
+ }
512
+ /**
513
+ * Generic function for discovering OAuth metadata with fallback support
514
+ */
515
+ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
516
+ const issuer = new URL(serverUrl);
517
+ const protocolVersion = opts?.protocolVersion ?? types_js_1.LATEST_PROTOCOL_VERSION;
518
+ let url;
519
+ if (opts?.metadataUrl) {
520
+ url = new URL(opts.metadataUrl);
521
+ }
522
+ else {
523
+ // Try path-aware discovery first
524
+ const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
525
+ url = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
526
+ url.search = issuer.search;
527
+ }
528
+ let response = await tryMetadataDiscovery(url, protocolVersion, fetchFn);
529
+ // If path-aware discovery fails with 404 and we're not already at root, try fallback to root discovery
530
+ if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) {
531
+ const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
532
+ response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);
533
+ }
534
+ return response;
535
+ }
536
+ /**
537
+ * Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.
538
+ *
539
+ * If the server returns a 404 for the well-known endpoint, this function will
540
+ * return `undefined`. Any other errors will be thrown as exceptions.
541
+ *
542
+ * @deprecated This function is deprecated in favor of `discoverAuthorizationServerMetadata`.
543
+ */
544
+ async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolVersion } = {}, fetchFn = fetch) {
545
+ if (typeof issuer === 'string') {
546
+ issuer = new URL(issuer);
547
+ }
548
+ if (!authorizationServerUrl) {
549
+ authorizationServerUrl = issuer;
550
+ }
551
+ if (typeof authorizationServerUrl === 'string') {
552
+ authorizationServerUrl = new URL(authorizationServerUrl);
553
+ }
554
+ protocolVersion ?? (protocolVersion = types_js_1.LATEST_PROTOCOL_VERSION);
555
+ const response = await discoverMetadataWithFallback(authorizationServerUrl, 'oauth-authorization-server', fetchFn, {
556
+ protocolVersion,
557
+ metadataServerUrl: authorizationServerUrl
558
+ });
559
+ if (!response || response.status === 404) {
560
+ await response?.body?.cancel();
561
+ return undefined;
562
+ }
563
+ if (!response.ok) {
564
+ await response.body?.cancel();
565
+ throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);
566
+ }
567
+ return auth_js_2.OAuthMetadataSchema.parse(await response.json());
568
+ }
569
+ /**
570
+ * Builds a list of discovery URLs to try for authorization server metadata.
571
+ * URLs are returned in priority order:
572
+ * 1. OAuth metadata at the given URL
573
+ * 2. OIDC metadata endpoints at the given URL
574
+ */
575
+ function buildDiscoveryUrls(authorizationServerUrl) {
576
+ const url = typeof authorizationServerUrl === 'string' ? new URL(authorizationServerUrl) : authorizationServerUrl;
577
+ const hasPath = url.pathname !== '/';
578
+ const urlsToTry = [];
579
+ if (!hasPath) {
580
+ // Root path: https://example.com/.well-known/oauth-authorization-server
581
+ urlsToTry.push({
582
+ url: new URL('/.well-known/oauth-authorization-server', url.origin),
583
+ type: 'oauth'
584
+ });
585
+ // OIDC: https://example.com/.well-known/openid-configuration
586
+ urlsToTry.push({
587
+ url: new URL(`/.well-known/openid-configuration`, url.origin),
588
+ type: 'oidc'
589
+ });
590
+ return urlsToTry;
591
+ }
592
+ // Strip trailing slash from pathname to avoid double slashes
593
+ let pathname = url.pathname;
594
+ if (pathname.endsWith('/')) {
595
+ pathname = pathname.slice(0, -1);
596
+ }
597
+ // 1. OAuth metadata at the given URL
598
+ // Insert well-known before the path: https://example.com/.well-known/oauth-authorization-server/tenant1
599
+ urlsToTry.push({
600
+ url: new URL(`/.well-known/oauth-authorization-server${pathname}`, url.origin),
601
+ type: 'oauth'
602
+ });
603
+ // 2. OIDC metadata endpoints
604
+ // RFC 8414 style: Insert /.well-known/openid-configuration before the path
605
+ urlsToTry.push({
606
+ url: new URL(`/.well-known/openid-configuration${pathname}`, url.origin),
607
+ type: 'oidc'
608
+ });
609
+ // OIDC Discovery 1.0 style: Append /.well-known/openid-configuration after the path
610
+ urlsToTry.push({
611
+ url: new URL(`${pathname}/.well-known/openid-configuration`, url.origin),
612
+ type: 'oidc'
613
+ });
614
+ return urlsToTry;
615
+ }
616
+ /**
617
+ * Discovers authorization server metadata with support for RFC 8414 OAuth 2.0 Authorization Server Metadata
618
+ * and OpenID Connect Discovery 1.0 specifications.
619
+ *
620
+ * This function implements a fallback strategy for authorization server discovery:
621
+ * 1. Attempts RFC 8414 OAuth metadata discovery first
622
+ * 2. If OAuth discovery fails, falls back to OpenID Connect Discovery
623
+ *
624
+ * @param authorizationServerUrl - The authorization server URL obtained from the MCP Server's
625
+ * protected resource metadata, or the MCP server's URL if the
626
+ * metadata was not found.
627
+ * @param options - Configuration options
628
+ * @param options.fetchFn - Optional fetch function for making HTTP requests, defaults to global fetch
629
+ * @param options.protocolVersion - MCP protocol version to use, defaults to LATEST_PROTOCOL_VERSION
630
+ * @returns Promise resolving to authorization server metadata, or undefined if discovery fails
631
+ */
632
+ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = types_js_1.LATEST_PROTOCOL_VERSION } = {}) {
633
+ const headers = {
634
+ 'MCP-Protocol-Version': protocolVersion,
635
+ Accept: 'application/json'
636
+ };
637
+ // Get the list of URLs to try
638
+ const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
639
+ // Try each URL in order
640
+ for (const { url: endpointUrl, type } of urlsToTry) {
641
+ const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);
642
+ if (!response) {
643
+ /**
644
+ * CORS error occurred - don't throw as the endpoint may not allow CORS,
645
+ * continue trying other possible endpoints
646
+ */
647
+ continue;
648
+ }
649
+ if (!response.ok) {
650
+ await response.body?.cancel();
651
+ // Continue looking for any 4xx response code.
652
+ if (response.status >= 400 && response.status < 500) {
653
+ continue; // Try next URL
654
+ }
655
+ throw new Error(`HTTP ${response.status} trying to load ${type === 'oauth' ? 'OAuth' : 'OpenID provider'} metadata from ${endpointUrl}`);
656
+ }
657
+ // Parse and validate based on type
658
+ if (type === 'oauth') {
659
+ return auth_js_2.OAuthMetadataSchema.parse(await response.json());
660
+ }
661
+ else {
662
+ return auth_js_1.OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
663
+ }
664
+ }
665
+ return undefined;
666
+ }
667
+ /**
668
+ * Discovers the authorization server for an MCP server following
669
+ * {@link https://datatracker.ietf.org/doc/html/rfc9728 | RFC 9728} (OAuth 2.0 Protected
670
+ * Resource Metadata), with fallback to treating the server URL as the
671
+ * authorization server.
672
+ *
673
+ * This function combines two discovery steps into one call:
674
+ * 1. Probes `/.well-known/oauth-protected-resource` on the MCP server to find the
675
+ * authorization server URL (RFC 9728).
676
+ * 2. Fetches authorization server metadata from that URL (RFC 8414 / OpenID Connect Discovery).
677
+ *
678
+ * Use this when you need the authorization server metadata for operations outside the
679
+ * {@linkcode auth} orchestrator, such as token refresh or token revocation.
680
+ *
681
+ * @param serverUrl - The MCP resource server URL
682
+ * @param opts - Optional configuration
683
+ * @param opts.resourceMetadataUrl - Override URL for the protected resource metadata endpoint
684
+ * @param opts.fetchFn - Custom fetch function for HTTP requests
685
+ * @returns Authorization server URL, metadata, and resource metadata (if available)
686
+ */
687
+ async function discoverOAuthServerInfo(serverUrl, opts) {
688
+ let resourceMetadata;
689
+ let authorizationServerUrl;
690
+ try {
691
+ resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn);
692
+ if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
693
+ authorizationServerUrl = resourceMetadata.authorization_servers[0];
694
+ }
695
+ }
696
+ catch {
697
+ // RFC 9728 not supported -- fall back to treating the server URL as the authorization server
698
+ }
699
+ // If we don't get a valid authorization server from protected resource metadata,
700
+ // fall back to the legacy MCP spec behavior: MCP server base URL acts as the authorization server
701
+ if (!authorizationServerUrl) {
702
+ authorizationServerUrl = String(new URL('/', serverUrl));
703
+ }
704
+ const authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
705
+ return {
706
+ authorizationServerUrl,
707
+ authorizationServerMetadata,
708
+ resourceMetadata
709
+ };
710
+ }
711
+ /**
712
+ * Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.
713
+ */
714
+ async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
715
+ let authorizationUrl;
716
+ if (metadata) {
717
+ authorizationUrl = new URL(metadata.authorization_endpoint);
718
+ if (!metadata.response_types_supported.includes(AUTHORIZATION_CODE_RESPONSE_TYPE)) {
719
+ throw new Error(`Incompatible auth server: does not support response type ${AUTHORIZATION_CODE_RESPONSE_TYPE}`);
720
+ }
721
+ if (metadata.code_challenge_methods_supported &&
722
+ !metadata.code_challenge_methods_supported.includes(AUTHORIZATION_CODE_CHALLENGE_METHOD)) {
723
+ throw new Error(`Incompatible auth server: does not support code challenge method ${AUTHORIZATION_CODE_CHALLENGE_METHOD}`);
724
+ }
725
+ }
726
+ else {
727
+ authorizationUrl = new URL('/authorize', authorizationServerUrl);
728
+ }
729
+ // Generate PKCE challenge
730
+ const challenge = await (0, pkce_challenge_1.default)();
731
+ const codeVerifier = challenge.code_verifier;
732
+ const codeChallenge = challenge.code_challenge;
733
+ authorizationUrl.searchParams.set('response_type', AUTHORIZATION_CODE_RESPONSE_TYPE);
734
+ authorizationUrl.searchParams.set('client_id', clientInformation.client_id);
735
+ authorizationUrl.searchParams.set('code_challenge', codeChallenge);
736
+ authorizationUrl.searchParams.set('code_challenge_method', AUTHORIZATION_CODE_CHALLENGE_METHOD);
737
+ authorizationUrl.searchParams.set('redirect_uri', String(redirectUrl));
738
+ if (state) {
739
+ authorizationUrl.searchParams.set('state', state);
740
+ }
741
+ if (scope) {
742
+ authorizationUrl.searchParams.set('scope', scope);
743
+ }
744
+ if (scope?.includes('offline_access')) {
745
+ // if the request includes the OIDC-only "offline_access" scope,
746
+ // we need to set the prompt to "consent" to ensure the user is prompted to grant offline access
747
+ // https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess
748
+ authorizationUrl.searchParams.append('prompt', 'consent');
749
+ }
750
+ if (resource) {
751
+ authorizationUrl.searchParams.set('resource', resource.href);
752
+ }
753
+ return { authorizationUrl, codeVerifier };
754
+ }
755
+ /**
756
+ * Prepares token request parameters for an authorization code exchange.
757
+ *
758
+ * This is the default implementation used by fetchToken when the provider
759
+ * doesn't implement prepareTokenRequest.
760
+ *
761
+ * @param authorizationCode - The authorization code received from the authorization endpoint
762
+ * @param codeVerifier - The PKCE code verifier
763
+ * @param redirectUri - The redirect URI used in the authorization request
764
+ * @returns URLSearchParams for the authorization_code grant
765
+ */
766
+ function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri) {
767
+ return new URLSearchParams({
768
+ grant_type: 'authorization_code',
769
+ code: authorizationCode,
770
+ code_verifier: codeVerifier,
771
+ redirect_uri: String(redirectUri)
772
+ });
773
+ }
774
+ /**
775
+ * Internal helper to execute a token request with the given parameters.
776
+ * Used by exchangeAuthorization, refreshAuthorization, and fetchToken.
777
+ */
778
+ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
779
+ const tokenUrl = metadata?.token_endpoint ? new URL(metadata.token_endpoint) : new URL('/token', authorizationServerUrl);
780
+ const headers = new Headers({
781
+ 'Content-Type': 'application/x-www-form-urlencoded',
782
+ Accept: 'application/json'
783
+ });
784
+ if (resource) {
785
+ tokenRequestParams.set('resource', resource.href);
786
+ }
787
+ if (addClientAuthentication) {
788
+ await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
789
+ }
790
+ else if (clientInformation) {
791
+ const supportedMethods = metadata?.token_endpoint_auth_methods_supported ?? [];
792
+ const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
793
+ applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
794
+ }
795
+ const response = await (fetchFn ?? fetch)(tokenUrl, {
796
+ method: 'POST',
797
+ headers,
798
+ body: tokenRequestParams
799
+ });
800
+ if (!response.ok) {
801
+ throw await parseErrorResponse(response);
802
+ }
803
+ return auth_js_2.OAuthTokensSchema.parse(await response.json());
804
+ }
805
+ /**
806
+ * Exchanges an authorization code for an access token with the given server.
807
+ *
808
+ * Supports multiple client authentication methods as specified in OAuth 2.1:
809
+ * - Automatically selects the best authentication method based on server support
810
+ * - Falls back to appropriate defaults when server metadata is unavailable
811
+ *
812
+ * @param authorizationServerUrl - The authorization server's base URL
813
+ * @param options - Configuration object containing client info, auth code, etc.
814
+ * @returns Promise resolving to OAuth tokens
815
+ * @throws {Error} When token exchange fails or authentication is invalid
816
+ */
817
+ async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication, fetchFn }) {
818
+ const tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri);
819
+ return executeTokenRequest(authorizationServerUrl, {
820
+ metadata,
821
+ tokenRequestParams,
822
+ clientInformation,
823
+ addClientAuthentication,
824
+ resource,
825
+ fetchFn
826
+ });
827
+ }
828
+ /**
829
+ * Exchange a refresh token for an updated access token.
830
+ *
831
+ * Supports multiple client authentication methods as specified in OAuth 2.1:
832
+ * - Automatically selects the best authentication method based on server support
833
+ * - Preserves the original refresh token if a new one is not returned
834
+ *
835
+ * @param authorizationServerUrl - The authorization server's base URL
836
+ * @param options - Configuration object containing client info, refresh token, etc.
837
+ * @returns Promise resolving to OAuth tokens (preserves original refresh_token if not replaced)
838
+ * @throws {Error} When token refresh fails or authentication is invalid
839
+ */
840
+ async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
841
+ const tokenRequestParams = new URLSearchParams({
842
+ grant_type: 'refresh_token',
843
+ refresh_token: refreshToken
844
+ });
845
+ const tokens = await executeTokenRequest(authorizationServerUrl, {
846
+ metadata,
847
+ tokenRequestParams,
848
+ clientInformation,
849
+ addClientAuthentication,
850
+ resource,
851
+ fetchFn
852
+ });
853
+ // Preserve original refresh token if server didn't return a new one
854
+ return { refresh_token: refreshToken, ...tokens };
855
+ }
856
+ /**
857
+ * Unified token fetching that works with any grant type via provider.prepareTokenRequest().
858
+ *
859
+ * This function provides a single entry point for obtaining tokens regardless of the
860
+ * OAuth grant type. The provider's prepareTokenRequest() method determines which grant
861
+ * to use and supplies the grant-specific parameters.
862
+ *
863
+ * @param provider - OAuth client provider that implements prepareTokenRequest()
864
+ * @param authorizationServerUrl - The authorization server's base URL
865
+ * @param options - Configuration for the token request
866
+ * @returns Promise resolving to OAuth tokens
867
+ * @throws {Error} When provider doesn't implement prepareTokenRequest or token fetch fails
868
+ *
869
+ * @example
870
+ * // Provider for client_credentials:
871
+ * class MyProvider implements OAuthClientProvider {
872
+ * prepareTokenRequest(scope) {
873
+ * const params = new URLSearchParams({ grant_type: 'client_credentials' });
874
+ * if (scope) params.set('scope', scope);
875
+ * return params;
876
+ * }
877
+ * // ... other methods
878
+ * }
879
+ *
880
+ * const tokens = await fetchToken(provider, authServerUrl, { metadata });
881
+ */
882
+ async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
883
+ const scope = provider.clientMetadata.scope;
884
+ // Use provider's prepareTokenRequest if available, otherwise fall back to authorization_code
885
+ let tokenRequestParams;
886
+ if (provider.prepareTokenRequest) {
887
+ tokenRequestParams = await provider.prepareTokenRequest(scope);
888
+ }
889
+ // Default to authorization_code grant if no custom prepareTokenRequest
890
+ if (!tokenRequestParams) {
891
+ if (!authorizationCode) {
892
+ throw new Error('Either provider.prepareTokenRequest() or authorizationCode is required');
893
+ }
894
+ if (!provider.redirectUrl) {
895
+ throw new Error('redirectUrl is required for authorization_code flow');
896
+ }
897
+ const codeVerifier = await provider.codeVerifier();
898
+ tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
899
+ }
900
+ const clientInformation = await provider.clientInformation();
901
+ return executeTokenRequest(authorizationServerUrl, {
902
+ metadata,
903
+ tokenRequestParams,
904
+ clientInformation: clientInformation ?? undefined,
905
+ addClientAuthentication: provider.addClientAuthentication,
906
+ resource,
907
+ fetchFn
908
+ });
909
+ }
910
+ /**
911
+ * Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.
912
+ *
913
+ * If `scope` is provided, it overrides `clientMetadata.scope` in the registration
914
+ * request body. This allows callers to apply the Scope Selection Strategy (SEP-835)
915
+ * consistently across both DCR and the subsequent authorization request.
916
+ */
917
+ async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
918
+ let registrationUrl;
919
+ if (metadata) {
920
+ if (!metadata.registration_endpoint) {
921
+ throw new Error('Incompatible auth server: does not support dynamic client registration');
922
+ }
923
+ registrationUrl = new URL(metadata.registration_endpoint);
924
+ }
925
+ else {
926
+ registrationUrl = new URL('/register', authorizationServerUrl);
927
+ }
928
+ const response = await (fetchFn ?? fetch)(registrationUrl, {
929
+ method: 'POST',
930
+ headers: {
931
+ 'Content-Type': 'application/json'
932
+ },
933
+ body: JSON.stringify({
934
+ ...clientMetadata,
935
+ ...(scope !== undefined ? { scope } : {})
936
+ })
937
+ });
938
+ if (!response.ok) {
939
+ throw await parseErrorResponse(response);
940
+ }
941
+ return auth_js_2.OAuthClientInformationFullSchema.parse(await response.json());
942
+ }
943
+ //# sourceMappingURL=auth.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/client/auth.ts"],"names":[],"mappings":";;;;;;AAsQA,wDAqCC;AA+ED,gDAcC;AAQD,oBAyBC;AAoMD,gCAQC;AAED,8CAuBC;AAKD,oEA8BC;AA8BD,gEAsBC;AAQD,wFAoBC;AAgGD,sDAsCC;AAQD,gDAgDC;AAkBD,kFAkDC;AA6CD,0DAoCC;AAKD,gDAmEC;AAaD,0EAWC;AAoED,sDAgCC;AAcD,oDAkCC;AA4BD,gCA8CC;AASD,wCA0CC;AAr8CD,oEAA2C;AAC3C,0CAAsD;AACtD,+CAW2B;AAC3B,+CAK2B;AAC3B,2DAAyF;AACzF,wDAQkC;AA8MlC,MAAa,iBAAkB,SAAQ,KAAK;IACxC,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,IAAI,cAAc,CAAC,CAAC;IACrC,CAAC;CACJ;AAJD,8CAIC;AAID,SAAS,kBAAkB,CAAC,MAAc;IACtC,OAAO,CAAC,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,gCAAgC,GAAG,MAAM,CAAC;AAChD,MAAM,mCAAmC,GAAG,MAAM,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,SAAgB,sBAAsB,CAAC,iBAA8C,EAAE,gBAA0B;IAC7G,MAAM,eAAe,GAAG,iBAAiB,CAAC,aAAa,KAAK,SAAS,CAAC;IAEtE,iFAAiF;IACjF,wFAAwF;IACxF,yFAAyF;IACzF,IACI,4BAA4B,IAAI,iBAAiB;QACjD,iBAAiB,CAAC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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Protocol, type ProtocolOptions, type RequestOptions } from '../shared/protocol.js';
2
+ import type { Transport } from '../shared/transport.js';
3
+ import { type CallToolRequest, CallToolResultSchema, type ClientCapabilities, type ClientNotification, type ClientRequest, type ClientResult, type CompatibilityCallToolResultSchema, type CompleteRequest, type GetPromptRequest, type Implementation, type ListPromptsRequest, type ListResourcesRequest, type ListResourceTemplatesRequest, type ListToolsRequest, type LoggingLevel, type ReadResourceRequest, type ServerCapabilities, type SubscribeRequest, type UnsubscribeRequest, type ListChangedHandlers, type Request, type Notification, type Result } from '../types.js';
4
+ import type { jsonSchemaValidator } from '../validation/types.js';
5
+ import { AnyObjectSchema, SchemaOutput } from '../server/zod-compat.js';
6
+ import type { RequestHandlerExtra } from '../shared/protocol.js';
7
+ import { ExperimentalClientTasks } from '../experimental/tasks/client.js';
8
+ /**
9
+ * Determines which elicitation modes are supported based on declared client capabilities.
10
+ *
11
+ * According to the spec:
12
+ * - An empty elicitation capability object defaults to form mode support (backwards compatibility)
13
+ * - URL mode is only supported if explicitly declared
14
+ *
15
+ * @param capabilities - The client's elicitation capabilities
16
+ * @returns An object indicating which modes are supported
17
+ */
18
+ export declare function getSupportedElicitationModes(capabilities: ClientCapabilities['elicitation']): {
19
+ supportsFormMode: boolean;
20
+ supportsUrlMode: boolean;
21
+ };
22
+ export type ClientOptions = ProtocolOptions & {
23
+ /**
24
+ * Capabilities to advertise as being supported by this client.
25
+ */
26
+ capabilities?: ClientCapabilities;
27
+ /**
28
+ * JSON Schema validator for tool output validation.
29
+ *
30
+ * The validator is used to validate structured content returned by tools
31
+ * against their declared output schemas.
32
+ *
33
+ * @default AjvJsonSchemaValidator
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * // ajv
38
+ * const client = new Client(
39
+ * { name: 'my-client', version: '1.0.0' },
40
+ * {
41
+ * capabilities: {},
42
+ * jsonSchemaValidator: new AjvJsonSchemaValidator()
43
+ * }
44
+ * );
45
+ *
46
+ * // @cfworker/json-schema
47
+ * const client = new Client(
48
+ * { name: 'my-client', version: '1.0.0' },
49
+ * {
50
+ * capabilities: {},
51
+ * jsonSchemaValidator: new CfWorkerJsonSchemaValidator()
52
+ * }
53
+ * );
54
+ * ```
55
+ */
56
+ jsonSchemaValidator?: jsonSchemaValidator;
57
+ /**
58
+ * Configure handlers for list changed notifications (tools, prompts, resources).
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const client = new Client(
63
+ * { name: 'my-client', version: '1.0.0' },
64
+ * {
65
+ * listChanged: {
66
+ * tools: {
67
+ * onChanged: (error, tools) => {
68
+ * if (error) {
69
+ * console.error('Failed to refresh tools:', error);
70
+ * return;
71
+ * }
72
+ * console.log('Tools updated:', tools);
73
+ * }
74
+ * },
75
+ * prompts: {
76
+ * onChanged: (error, prompts) => console.log('Prompts updated:', prompts)
77
+ * }
78
+ * }
79
+ * }
80
+ * );
81
+ * ```
82
+ */
83
+ listChanged?: ListChangedHandlers;
84
+ };
85
+ /**
86
+ * An MCP client on top of a pluggable transport.
87
+ *
88
+ * The client will automatically begin the initialization flow with the server when connect() is called.
89
+ *
90
+ * To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:
91
+ *
92
+ * ```typescript
93
+ * // Custom schemas
94
+ * const CustomRequestSchema = RequestSchema.extend({...})
95
+ * const CustomNotificationSchema = NotificationSchema.extend({...})
96
+ * const CustomResultSchema = ResultSchema.extend({...})
97
+ *
98
+ * // Type aliases
99
+ * type CustomRequest = z.infer<typeof CustomRequestSchema>
100
+ * type CustomNotification = z.infer<typeof CustomNotificationSchema>
101
+ * type CustomResult = z.infer<typeof CustomResultSchema>
102
+ *
103
+ * // Create typed client
104
+ * const client = new Client<CustomRequest, CustomNotification, CustomResult>({
105
+ * name: "CustomClient",
106
+ * version: "1.0.0"
107
+ * })
108
+ * ```
109
+ */
110
+ export declare class Client<RequestT extends Request = Request, NotificationT extends Notification = Notification, ResultT extends Result = Result> extends Protocol<ClientRequest | RequestT, ClientNotification | NotificationT, ClientResult | ResultT> {
111
+ private _clientInfo;
112
+ private _serverCapabilities?;
113
+ private _serverVersion?;
114
+ private _capabilities;
115
+ private _instructions?;
116
+ private _jsonSchemaValidator;
117
+ private _cachedToolOutputValidators;
118
+ private _cachedKnownTaskTools;
119
+ private _cachedRequiredTaskTools;
120
+ private _experimental?;
121
+ private _listChangedDebounceTimers;
122
+ private _pendingListChangedConfig?;
123
+ /**
124
+ * Initializes this client with the given name and version information.
125
+ */
126
+ constructor(_clientInfo: Implementation, options?: ClientOptions);
127
+ /**
128
+ * Set up handlers for list changed notifications based on config and server capabilities.
129
+ * This should only be called after initialization when server capabilities are known.
130
+ * Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
131
+ * @internal
132
+ */
133
+ private _setupListChangedHandlers;
134
+ /**
135
+ * Access experimental features.
136
+ *
137
+ * WARNING: These APIs are experimental and may change without notice.
138
+ *
139
+ * @experimental
140
+ */
141
+ get experimental(): {
142
+ tasks: ExperimentalClientTasks<RequestT, NotificationT, ResultT>;
143
+ };
144
+ /**
145
+ * Registers new capabilities. This can only be called before connecting to a transport.
146
+ *
147
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
148
+ */
149
+ registerCapabilities(capabilities: ClientCapabilities): void;
150
+ /**
151
+ * Override request handler registration to enforce client-side validation for elicitation.
152
+ */
153
+ setRequestHandler<T extends AnyObjectSchema>(requestSchema: T, handler: (request: SchemaOutput<T>, extra: RequestHandlerExtra<ClientRequest | RequestT, ClientNotification | NotificationT>) => ClientResult | ResultT | Promise<ClientResult | ResultT>): void;
154
+ protected assertCapability(capability: keyof ServerCapabilities, method: string): void;
155
+ connect(transport: Transport, options?: RequestOptions): Promise<void>;
156
+ /**
157
+ * After initialization has completed, this will be populated with the server's reported capabilities.
158
+ */
159
+ getServerCapabilities(): ServerCapabilities | undefined;
160
+ /**
161
+ * After initialization has completed, this will be populated with information about the server's name and version.
162
+ */
163
+ getServerVersion(): Implementation | undefined;
164
+ /**
165
+ * After initialization has completed, this may be populated with information about the server's instructions.
166
+ */
167
+ getInstructions(): string | undefined;
168
+ protected assertCapabilityForMethod(method: RequestT['method']): void;
169
+ protected assertNotificationCapability(method: NotificationT['method']): void;
170
+ protected assertRequestHandlerCapability(method: string): void;
171
+ protected assertTaskCapability(method: string): void;
172
+ protected assertTaskHandlerCapability(method: string): void;
173
+ ping(options?: RequestOptions): Promise<{
174
+ _meta?: {
175
+ [x: string]: unknown;
176
+ progressToken?: string | number | undefined;
177
+ "io.modelcontextprotocol/related-task"?: {
178
+ taskId: string;
179
+ } | undefined;
180
+ } | undefined;
181
+ }>;
182
+ complete(params: CompleteRequest['params'], options?: RequestOptions): Promise<{
183
+ [x: string]: unknown;
184
+ completion: {
185
+ [x: string]: unknown;
186
+ values: string[];
187
+ total?: number | undefined;
188
+ hasMore?: boolean | undefined;
189
+ };
190
+ _meta?: {
191
+ [x: string]: unknown;
192
+ progressToken?: string | number | undefined;
193
+ "io.modelcontextprotocol/related-task"?: {
194
+ taskId: string;
195
+ } | undefined;
196
+ } | undefined;
197
+ }>;
198
+ setLoggingLevel(level: LoggingLevel, options?: RequestOptions): Promise<{
199
+ _meta?: {
200
+ [x: string]: unknown;
201
+ progressToken?: string | number | undefined;
202
+ "io.modelcontextprotocol/related-task"?: {
203
+ taskId: string;
204
+ } | undefined;
205
+ } | undefined;
206
+ }>;
207
+ getPrompt(params: GetPromptRequest['params'], options?: RequestOptions): Promise<{
208
+ [x: string]: unknown;
209
+ messages: {
210
+ role: "user" | "assistant";
211
+ content: {
212
+ type: "text";
213
+ text: string;
214
+ annotations?: {
215
+ audience?: ("user" | "assistant")[] | undefined;
216
+ priority?: number | undefined;
217
+ lastModified?: string | undefined;
218
+ } | undefined;
219
+ _meta?: Record<string, unknown> | undefined;
220
+ } | {
221
+ type: "image";
222
+ data: string;
223
+ mimeType: string;
224
+ annotations?: {
225
+ audience?: ("user" | "assistant")[] | undefined;
226
+ priority?: number | undefined;
227
+ lastModified?: string | undefined;
228
+ } | undefined;
229
+ _meta?: Record<string, unknown> | undefined;
230
+ } | {
231
+ type: "audio";
232
+ data: string;
233
+ mimeType: string;
234
+ annotations?: {
235
+ audience?: ("user" | "assistant")[] | undefined;
236
+ priority?: number | undefined;
237
+ lastModified?: string | undefined;
238
+ } | undefined;
239
+ _meta?: Record<string, unknown> | undefined;
240
+ } | {
241
+ type: "resource";
242
+ resource: {
243
+ uri: string;
244
+ text: string;
245
+ mimeType?: string | undefined;
246
+ _meta?: Record<string, unknown> | undefined;
247
+ } | {
248
+ uri: string;
249
+ blob: string;
250
+ mimeType?: string | undefined;
251
+ _meta?: Record<string, unknown> | undefined;
252
+ };
253
+ annotations?: {
254
+ audience?: ("user" | "assistant")[] | undefined;
255
+ priority?: number | undefined;
256
+ lastModified?: string | undefined;
257
+ } | undefined;
258
+ _meta?: Record<string, unknown> | undefined;
259
+ } | {
260
+ uri: string;
261
+ name: string;
262
+ type: "resource_link";
263
+ description?: string | undefined;
264
+ mimeType?: string | undefined;
265
+ size?: number | undefined;
266
+ annotations?: {
267
+ audience?: ("user" | "assistant")[] | undefined;
268
+ priority?: number | undefined;
269
+ lastModified?: string | undefined;
270
+ } | undefined;
271
+ _meta?: {
272
+ [x: string]: unknown;
273
+ } | undefined;
274
+ icons?: {
275
+ src: string;
276
+ mimeType?: string | undefined;
277
+ sizes?: string[] | undefined;
278
+ theme?: "light" | "dark" | undefined;
279
+ }[] | undefined;
280
+ title?: string | undefined;
281
+ };
282
+ }[];
283
+ _meta?: {
284
+ [x: string]: unknown;
285
+ progressToken?: string | number | undefined;
286
+ "io.modelcontextprotocol/related-task"?: {
287
+ taskId: string;
288
+ } | undefined;
289
+ } | undefined;
290
+ description?: string | undefined;
291
+ }>;
292
+ listPrompts(params?: ListPromptsRequest['params'], options?: RequestOptions): Promise<{
293
+ [x: string]: unknown;
294
+ prompts: {
295
+ name: string;
296
+ description?: string | undefined;
297
+ arguments?: {
298
+ name: string;
299
+ description?: string | undefined;
300
+ required?: boolean | undefined;
301
+ }[] | undefined;
302
+ _meta?: {
303
+ [x: string]: unknown;
304
+ } | undefined;
305
+ icons?: {
306
+ src: string;
307
+ mimeType?: string | undefined;
308
+ sizes?: string[] | undefined;
309
+ theme?: "light" | "dark" | undefined;
310
+ }[] | undefined;
311
+ title?: string | undefined;
312
+ }[];
313
+ _meta?: {
314
+ [x: string]: unknown;
315
+ progressToken?: string | number | undefined;
316
+ "io.modelcontextprotocol/related-task"?: {
317
+ taskId: string;
318
+ } | undefined;
319
+ } | undefined;
320
+ nextCursor?: string | undefined;
321
+ }>;
322
+ listResources(params?: ListResourcesRequest['params'], options?: RequestOptions): Promise<{
323
+ [x: string]: unknown;
324
+ resources: {
325
+ uri: string;
326
+ name: string;
327
+ description?: string | undefined;
328
+ mimeType?: string | undefined;
329
+ size?: number | undefined;
330
+ annotations?: {
331
+ audience?: ("user" | "assistant")[] | undefined;
332
+ priority?: number | undefined;
333
+ lastModified?: string | undefined;
334
+ } | undefined;
335
+ _meta?: {
336
+ [x: string]: unknown;
337
+ } | undefined;
338
+ icons?: {
339
+ src: string;
340
+ mimeType?: string | undefined;
341
+ sizes?: string[] | undefined;
342
+ theme?: "light" | "dark" | undefined;
343
+ }[] | undefined;
344
+ title?: string | undefined;
345
+ }[];
346
+ _meta?: {
347
+ [x: string]: unknown;
348
+ progressToken?: string | number | undefined;
349
+ "io.modelcontextprotocol/related-task"?: {
350
+ taskId: string;
351
+ } | undefined;
352
+ } | undefined;
353
+ nextCursor?: string | undefined;
354
+ }>;
355
+ listResourceTemplates(params?: ListResourceTemplatesRequest['params'], options?: RequestOptions): Promise<{
356
+ [x: string]: unknown;
357
+ resourceTemplates: {
358
+ uriTemplate: string;
359
+ name: string;
360
+ description?: string | undefined;
361
+ mimeType?: string | undefined;
362
+ annotations?: {
363
+ audience?: ("user" | "assistant")[] | undefined;
364
+ priority?: number | undefined;
365
+ lastModified?: string | undefined;
366
+ } | undefined;
367
+ _meta?: {
368
+ [x: string]: unknown;
369
+ } | undefined;
370
+ icons?: {
371
+ src: string;
372
+ mimeType?: string | undefined;
373
+ sizes?: string[] | undefined;
374
+ theme?: "light" | "dark" | undefined;
375
+ }[] | undefined;
376
+ title?: string | undefined;
377
+ }[];
378
+ _meta?: {
379
+ [x: string]: unknown;
380
+ progressToken?: string | number | undefined;
381
+ "io.modelcontextprotocol/related-task"?: {
382
+ taskId: string;
383
+ } | undefined;
384
+ } | undefined;
385
+ nextCursor?: string | undefined;
386
+ }>;
387
+ readResource(params: ReadResourceRequest['params'], options?: RequestOptions): Promise<{
388
+ [x: string]: unknown;
389
+ contents: ({
390
+ uri: string;
391
+ text: string;
392
+ mimeType?: string | undefined;
393
+ _meta?: Record<string, unknown> | undefined;
394
+ } | {
395
+ uri: string;
396
+ blob: string;
397
+ mimeType?: string | undefined;
398
+ _meta?: Record<string, unknown> | undefined;
399
+ })[];
400
+ _meta?: {
401
+ [x: string]: unknown;
402
+ progressToken?: string | number | undefined;
403
+ "io.modelcontextprotocol/related-task"?: {
404
+ taskId: string;
405
+ } | undefined;
406
+ } | undefined;
407
+ }>;
408
+ subscribeResource(params: SubscribeRequest['params'], options?: RequestOptions): Promise<{
409
+ _meta?: {
410
+ [x: string]: unknown;
411
+ progressToken?: string | number | undefined;
412
+ "io.modelcontextprotocol/related-task"?: {
413
+ taskId: string;
414
+ } | undefined;
415
+ } | undefined;
416
+ }>;
417
+ unsubscribeResource(params: UnsubscribeRequest['params'], options?: RequestOptions): Promise<{
418
+ _meta?: {
419
+ [x: string]: unknown;
420
+ progressToken?: string | number | undefined;
421
+ "io.modelcontextprotocol/related-task"?: {
422
+ taskId: string;
423
+ } | undefined;
424
+ } | undefined;
425
+ }>;
426
+ /**
427
+ * Calls a tool and waits for the result. Automatically validates structured output if the tool has an outputSchema.
428
+ *
429
+ * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
430
+ */
431
+ callTool(params: CallToolRequest['params'], resultSchema?: typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema, options?: RequestOptions): Promise<{
432
+ [x: string]: unknown;
433
+ content: ({
434
+ type: "text";
435
+ text: string;
436
+ annotations?: {
437
+ audience?: ("user" | "assistant")[] | undefined;
438
+ priority?: number | undefined;
439
+ lastModified?: string | undefined;
440
+ } | undefined;
441
+ _meta?: Record<string, unknown> | undefined;
442
+ } | {
443
+ type: "image";
444
+ data: string;
445
+ mimeType: string;
446
+ annotations?: {
447
+ audience?: ("user" | "assistant")[] | undefined;
448
+ priority?: number | undefined;
449
+ lastModified?: string | undefined;
450
+ } | undefined;
451
+ _meta?: Record<string, unknown> | undefined;
452
+ } | {
453
+ type: "audio";
454
+ data: string;
455
+ mimeType: string;
456
+ annotations?: {
457
+ audience?: ("user" | "assistant")[] | undefined;
458
+ priority?: number | undefined;
459
+ lastModified?: string | undefined;
460
+ } | undefined;
461
+ _meta?: Record<string, unknown> | undefined;
462
+ } | {
463
+ type: "resource";
464
+ resource: {
465
+ uri: string;
466
+ text: string;
467
+ mimeType?: string | undefined;
468
+ _meta?: Record<string, unknown> | undefined;
469
+ } | {
470
+ uri: string;
471
+ blob: string;
472
+ mimeType?: string | undefined;
473
+ _meta?: Record<string, unknown> | undefined;
474
+ };
475
+ annotations?: {
476
+ audience?: ("user" | "assistant")[] | undefined;
477
+ priority?: number | undefined;
478
+ lastModified?: string | undefined;
479
+ } | undefined;
480
+ _meta?: Record<string, unknown> | undefined;
481
+ } | {
482
+ uri: string;
483
+ name: string;
484
+ type: "resource_link";
485
+ description?: string | undefined;
486
+ mimeType?: string | undefined;
487
+ size?: number | undefined;
488
+ annotations?: {
489
+ audience?: ("user" | "assistant")[] | undefined;
490
+ priority?: number | undefined;
491
+ lastModified?: string | undefined;
492
+ } | undefined;
493
+ _meta?: {
494
+ [x: string]: unknown;
495
+ } | undefined;
496
+ icons?: {
497
+ src: string;
498
+ mimeType?: string | undefined;
499
+ sizes?: string[] | undefined;
500
+ theme?: "light" | "dark" | undefined;
501
+ }[] | undefined;
502
+ title?: string | undefined;
503
+ })[];
504
+ _meta?: {
505
+ [x: string]: unknown;
506
+ progressToken?: string | number | undefined;
507
+ "io.modelcontextprotocol/related-task"?: {
508
+ taskId: string;
509
+ } | undefined;
510
+ } | undefined;
511
+ structuredContent?: Record<string, unknown> | undefined;
512
+ isError?: boolean | undefined;
513
+ } | {
514
+ [x: string]: unknown;
515
+ toolResult: unknown;
516
+ _meta?: {
517
+ [x: string]: unknown;
518
+ progressToken?: string | number | undefined;
519
+ "io.modelcontextprotocol/related-task"?: {
520
+ taskId: string;
521
+ } | undefined;
522
+ } | undefined;
523
+ }>;
524
+ private isToolTask;
525
+ /**
526
+ * Check if a tool requires task-based execution.
527
+ * Unlike isToolTask which includes 'optional' tools, this only checks for 'required'.
528
+ */
529
+ private isToolTaskRequired;
530
+ /**
531
+ * Cache validators for tool output schemas.
532
+ * Called after listTools() to pre-compile validators for better performance.
533
+ */
534
+ private cacheToolMetadata;
535
+ /**
536
+ * Get cached validator for a tool
537
+ */
538
+ private getToolOutputValidator;
539
+ listTools(params?: ListToolsRequest['params'], options?: RequestOptions): Promise<{
540
+ [x: string]: unknown;
541
+ tools: {
542
+ inputSchema: {
543
+ [x: string]: unknown;
544
+ type: "object";
545
+ properties?: Record<string, object> | undefined;
546
+ required?: string[] | undefined;
547
+ };
548
+ name: string;
549
+ description?: string | undefined;
550
+ outputSchema?: {
551
+ [x: string]: unknown;
552
+ type: "object";
553
+ properties?: Record<string, object> | undefined;
554
+ required?: string[] | undefined;
555
+ } | undefined;
556
+ annotations?: {
557
+ title?: string | undefined;
558
+ readOnlyHint?: boolean | undefined;
559
+ destructiveHint?: boolean | undefined;
560
+ idempotentHint?: boolean | undefined;
561
+ openWorldHint?: boolean | undefined;
562
+ } | undefined;
563
+ execution?: {
564
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
565
+ } | undefined;
566
+ _meta?: Record<string, unknown> | undefined;
567
+ icons?: {
568
+ src: string;
569
+ mimeType?: string | undefined;
570
+ sizes?: string[] | undefined;
571
+ theme?: "light" | "dark" | undefined;
572
+ }[] | undefined;
573
+ title?: string | undefined;
574
+ }[];
575
+ _meta?: {
576
+ [x: string]: unknown;
577
+ progressToken?: string | number | undefined;
578
+ "io.modelcontextprotocol/related-task"?: {
579
+ taskId: string;
580
+ } | undefined;
581
+ } | undefined;
582
+ nextCursor?: string | undefined;
583
+ }>;
584
+ /**
585
+ * Set up a single list changed handler.
586
+ * @internal
587
+ */
588
+ private _setupListChangedHandler;
589
+ sendRootsListChanged(): Promise<void>;
590
+ }
591
+ //# sourceMappingURL=index.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = void 0;
4
+ exports.getSupportedElicitationModes = getSupportedElicitationModes;
5
+ const protocol_js_1 = require("../shared/protocol.js");
6
+ const types_js_1 = require("../types.js");
7
+ const ajv_provider_js_1 = require("../validation/ajv-provider.js");
8
+ const zod_compat_js_1 = require("../server/zod-compat.js");
9
+ const client_js_1 = require("../experimental/tasks/client.js");
10
+ const helpers_js_1 = require("../experimental/tasks/helpers.js");
11
+ /**
12
+ * Elicitation default application helper. Applies defaults to the data based on the schema.
13
+ *
14
+ * @param schema - The schema to apply defaults to.
15
+ * @param data - The data to apply defaults to.
16
+ */
17
+ function applyElicitationDefaults(schema, data) {
18
+ if (!schema || data === null || typeof data !== 'object')
19
+ return;
20
+ // Handle object properties
21
+ if (schema.type === 'object' && schema.properties && typeof schema.properties === 'object') {
22
+ const obj = data;
23
+ const props = schema.properties;
24
+ for (const key of Object.keys(props)) {
25
+ const propSchema = props[key];
26
+ // If missing or explicitly undefined, apply default if present
27
+ if (obj[key] === undefined && Object.prototype.hasOwnProperty.call(propSchema, 'default')) {
28
+ obj[key] = propSchema.default;
29
+ }
30
+ // Recurse into existing nested objects/arrays
31
+ if (obj[key] !== undefined) {
32
+ applyElicitationDefaults(propSchema, obj[key]);
33
+ }
34
+ }
35
+ }
36
+ if (Array.isArray(schema.anyOf)) {
37
+ for (const sub of schema.anyOf) {
38
+ // Skip boolean schemas (true/false are valid JSON Schemas but have no defaults)
39
+ if (typeof sub !== 'boolean') {
40
+ applyElicitationDefaults(sub, data);
41
+ }
42
+ }
43
+ }
44
+ // Combine schemas
45
+ if (Array.isArray(schema.oneOf)) {
46
+ for (const sub of schema.oneOf) {
47
+ // Skip boolean schemas (true/false are valid JSON Schemas but have no defaults)
48
+ if (typeof sub !== 'boolean') {
49
+ applyElicitationDefaults(sub, data);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Determines which elicitation modes are supported based on declared client capabilities.
56
+ *
57
+ * According to the spec:
58
+ * - An empty elicitation capability object defaults to form mode support (backwards compatibility)
59
+ * - URL mode is only supported if explicitly declared
60
+ *
61
+ * @param capabilities - The client's elicitation capabilities
62
+ * @returns An object indicating which modes are supported
63
+ */
64
+ function getSupportedElicitationModes(capabilities) {
65
+ if (!capabilities) {
66
+ return { supportsFormMode: false, supportsUrlMode: false };
67
+ }
68
+ const hasFormCapability = capabilities.form !== undefined;
69
+ const hasUrlCapability = capabilities.url !== undefined;
70
+ // If neither form nor url are explicitly declared, form mode is supported (backwards compatibility)
71
+ const supportsFormMode = hasFormCapability || (!hasFormCapability && !hasUrlCapability);
72
+ const supportsUrlMode = hasUrlCapability;
73
+ return { supportsFormMode, supportsUrlMode };
74
+ }
75
+ /**
76
+ * An MCP client on top of a pluggable transport.
77
+ *
78
+ * The client will automatically begin the initialization flow with the server when connect() is called.
79
+ *
80
+ * To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:
81
+ *
82
+ * ```typescript
83
+ * // Custom schemas
84
+ * const CustomRequestSchema = RequestSchema.extend({...})
85
+ * const CustomNotificationSchema = NotificationSchema.extend({...})
86
+ * const CustomResultSchema = ResultSchema.extend({...})
87
+ *
88
+ * // Type aliases
89
+ * type CustomRequest = z.infer<typeof CustomRequestSchema>
90
+ * type CustomNotification = z.infer<typeof CustomNotificationSchema>
91
+ * type CustomResult = z.infer<typeof CustomResultSchema>
92
+ *
93
+ * // Create typed client
94
+ * const client = new Client<CustomRequest, CustomNotification, CustomResult>({
95
+ * name: "CustomClient",
96
+ * version: "1.0.0"
97
+ * })
98
+ * ```
99
+ */
100
+ class Client extends protocol_js_1.Protocol {
101
+ /**
102
+ * Initializes this client with the given name and version information.
103
+ */
104
+ constructor(_clientInfo, options) {
105
+ super(options);
106
+ this._clientInfo = _clientInfo;
107
+ this._cachedToolOutputValidators = new Map();
108
+ this._cachedKnownTaskTools = new Set();
109
+ this._cachedRequiredTaskTools = new Set();
110
+ this._listChangedDebounceTimers = new Map();
111
+ this._capabilities = options?.capabilities ?? {};
112
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new ajv_provider_js_1.AjvJsonSchemaValidator();
113
+ // Store list changed config for setup after connection (when we know server capabilities)
114
+ if (options?.listChanged) {
115
+ this._pendingListChangedConfig = options.listChanged;
116
+ }
117
+ }
118
+ /**
119
+ * Set up handlers for list changed notifications based on config and server capabilities.
120
+ * This should only be called after initialization when server capabilities are known.
121
+ * Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
122
+ * @internal
123
+ */
124
+ _setupListChangedHandlers(config) {
125
+ if (config.tools && this._serverCapabilities?.tools?.listChanged) {
126
+ this._setupListChangedHandler('tools', types_js_1.ToolListChangedNotificationSchema, config.tools, async () => {
127
+ const result = await this.listTools();
128
+ return result.tools;
129
+ });
130
+ }
131
+ if (config.prompts && this._serverCapabilities?.prompts?.listChanged) {
132
+ this._setupListChangedHandler('prompts', types_js_1.PromptListChangedNotificationSchema, config.prompts, async () => {
133
+ const result = await this.listPrompts();
134
+ return result.prompts;
135
+ });
136
+ }
137
+ if (config.resources && this._serverCapabilities?.resources?.listChanged) {
138
+ this._setupListChangedHandler('resources', types_js_1.ResourceListChangedNotificationSchema, config.resources, async () => {
139
+ const result = await this.listResources();
140
+ return result.resources;
141
+ });
142
+ }
143
+ }
144
+ /**
145
+ * Access experimental features.
146
+ *
147
+ * WARNING: These APIs are experimental and may change without notice.
148
+ *
149
+ * @experimental
150
+ */
151
+ get experimental() {
152
+ if (!this._experimental) {
153
+ this._experimental = {
154
+ tasks: new client_js_1.ExperimentalClientTasks(this)
155
+ };
156
+ }
157
+ return this._experimental;
158
+ }
159
+ /**
160
+ * Registers new capabilities. This can only be called before connecting to a transport.
161
+ *
162
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
163
+ */
164
+ registerCapabilities(capabilities) {
165
+ if (this.transport) {
166
+ throw new Error('Cannot register capabilities after connecting to transport');
167
+ }
168
+ this._capabilities = (0, protocol_js_1.mergeCapabilities)(this._capabilities, capabilities);
169
+ }
170
+ /**
171
+ * Override request handler registration to enforce client-side validation for elicitation.
172
+ */
173
+ setRequestHandler(requestSchema, handler) {
174
+ const shape = (0, zod_compat_js_1.getObjectShape)(requestSchema);
175
+ const methodSchema = shape?.method;
176
+ if (!methodSchema) {
177
+ throw new Error('Schema is missing a method literal');
178
+ }
179
+ // Extract literal value using type-safe property access
180
+ let methodValue;
181
+ if ((0, zod_compat_js_1.isZ4Schema)(methodSchema)) {
182
+ const v4Schema = methodSchema;
183
+ const v4Def = v4Schema._zod?.def;
184
+ methodValue = v4Def?.value ?? v4Schema.value;
185
+ }
186
+ else {
187
+ const v3Schema = methodSchema;
188
+ const legacyDef = v3Schema._def;
189
+ methodValue = legacyDef?.value ?? v3Schema.value;
190
+ }
191
+ if (typeof methodValue !== 'string') {
192
+ throw new Error('Schema method literal must be a string');
193
+ }
194
+ const method = methodValue;
195
+ if (method === 'elicitation/create') {
196
+ const wrappedHandler = async (request, extra) => {
197
+ const validatedRequest = (0, zod_compat_js_1.safeParse)(types_js_1.ElicitRequestSchema, request);
198
+ if (!validatedRequest.success) {
199
+ // Type guard: if success is false, error is guaranteed to exist
200
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
201
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
202
+ }
203
+ const { params } = validatedRequest.data;
204
+ params.mode = params.mode ?? 'form';
205
+ const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
206
+ if (params.mode === 'form' && !supportsFormMode) {
207
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Client does not support form-mode elicitation requests');
208
+ }
209
+ if (params.mode === 'url' && !supportsUrlMode) {
210
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Client does not support URL-mode elicitation requests');
211
+ }
212
+ const result = await Promise.resolve(handler(request, extra));
213
+ // When task creation is requested, validate and return CreateTaskResult
214
+ if (params.task) {
215
+ const taskValidationResult = (0, zod_compat_js_1.safeParse)(types_js_1.CreateTaskResultSchema, result);
216
+ if (!taskValidationResult.success) {
217
+ const errorMessage = taskValidationResult.error instanceof Error
218
+ ? taskValidationResult.error.message
219
+ : String(taskValidationResult.error);
220
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
221
+ }
222
+ return taskValidationResult.data;
223
+ }
224
+ // For non-task requests, validate against ElicitResultSchema
225
+ const validationResult = (0, zod_compat_js_1.safeParse)(types_js_1.ElicitResultSchema, result);
226
+ if (!validationResult.success) {
227
+ // Type guard: if success is false, error is guaranteed to exist
228
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
229
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
230
+ }
231
+ const validatedResult = validationResult.data;
232
+ const requestedSchema = params.mode === 'form' ? params.requestedSchema : undefined;
233
+ if (params.mode === 'form' && validatedResult.action === 'accept' && validatedResult.content && requestedSchema) {
234
+ if (this._capabilities.elicitation?.form?.applyDefaults) {
235
+ try {
236
+ applyElicitationDefaults(requestedSchema, validatedResult.content);
237
+ }
238
+ catch {
239
+ // gracefully ignore errors in default application
240
+ }
241
+ }
242
+ }
243
+ return validatedResult;
244
+ };
245
+ // Install the wrapped handler
246
+ return super.setRequestHandler(requestSchema, wrappedHandler);
247
+ }
248
+ if (method === 'sampling/createMessage') {
249
+ const wrappedHandler = async (request, extra) => {
250
+ const validatedRequest = (0, zod_compat_js_1.safeParse)(types_js_1.CreateMessageRequestSchema, request);
251
+ if (!validatedRequest.success) {
252
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
253
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Invalid sampling request: ${errorMessage}`);
254
+ }
255
+ const { params } = validatedRequest.data;
256
+ const result = await Promise.resolve(handler(request, extra));
257
+ // When task creation is requested, validate and return CreateTaskResult
258
+ if (params.task) {
259
+ const taskValidationResult = (0, zod_compat_js_1.safeParse)(types_js_1.CreateTaskResultSchema, result);
260
+ if (!taskValidationResult.success) {
261
+ const errorMessage = taskValidationResult.error instanceof Error
262
+ ? taskValidationResult.error.message
263
+ : String(taskValidationResult.error);
264
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
265
+ }
266
+ return taskValidationResult.data;
267
+ }
268
+ // For non-task requests, validate against appropriate schema based on tools presence
269
+ const hasTools = params.tools || params.toolChoice;
270
+ const resultSchema = hasTools ? types_js_1.CreateMessageResultWithToolsSchema : types_js_1.CreateMessageResultSchema;
271
+ const validationResult = (0, zod_compat_js_1.safeParse)(resultSchema, result);
272
+ if (!validationResult.success) {
273
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
274
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
275
+ }
276
+ return validationResult.data;
277
+ };
278
+ // Install the wrapped handler
279
+ return super.setRequestHandler(requestSchema, wrappedHandler);
280
+ }
281
+ // Other handlers use default behavior
282
+ return super.setRequestHandler(requestSchema, handler);
283
+ }
284
+ assertCapability(capability, method) {
285
+ if (!this._serverCapabilities?.[capability]) {
286
+ throw new Error(`Server does not support ${capability} (required for ${method})`);
287
+ }
288
+ }
289
+ async connect(transport, options) {
290
+ await super.connect(transport);
291
+ // When transport sessionId is already set this means we are trying to reconnect.
292
+ // In this case we don't need to initialize again.
293
+ if (transport.sessionId !== undefined) {
294
+ return;
295
+ }
296
+ try {
297
+ const result = await this.request({
298
+ method: 'initialize',
299
+ params: {
300
+ protocolVersion: types_js_1.LATEST_PROTOCOL_VERSION,
301
+ capabilities: this._capabilities,
302
+ clientInfo: this._clientInfo
303
+ }
304
+ }, types_js_1.InitializeResultSchema, options);
305
+ if (result === undefined) {
306
+ throw new Error(`Server sent invalid initialize result: ${result}`);
307
+ }
308
+ if (!types_js_1.SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
309
+ throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
310
+ }
311
+ this._serverCapabilities = result.capabilities;
312
+ this._serverVersion = result.serverInfo;
313
+ // HTTP transports must set the protocol version in each header after initialization.
314
+ if (transport.setProtocolVersion) {
315
+ transport.setProtocolVersion(result.protocolVersion);
316
+ }
317
+ this._instructions = result.instructions;
318
+ await this.notification({
319
+ method: 'notifications/initialized'
320
+ });
321
+ // Set up list changed handlers now that we know server capabilities
322
+ if (this._pendingListChangedConfig) {
323
+ this._setupListChangedHandlers(this._pendingListChangedConfig);
324
+ this._pendingListChangedConfig = undefined;
325
+ }
326
+ }
327
+ catch (error) {
328
+ // Disconnect if initialization fails.
329
+ void this.close();
330
+ throw error;
331
+ }
332
+ }
333
+ /**
334
+ * After initialization has completed, this will be populated with the server's reported capabilities.
335
+ */
336
+ getServerCapabilities() {
337
+ return this._serverCapabilities;
338
+ }
339
+ /**
340
+ * After initialization has completed, this will be populated with information about the server's name and version.
341
+ */
342
+ getServerVersion() {
343
+ return this._serverVersion;
344
+ }
345
+ /**
346
+ * After initialization has completed, this may be populated with information about the server's instructions.
347
+ */
348
+ getInstructions() {
349
+ return this._instructions;
350
+ }
351
+ assertCapabilityForMethod(method) {
352
+ switch (method) {
353
+ case 'logging/setLevel':
354
+ if (!this._serverCapabilities?.logging) {
355
+ throw new Error(`Server does not support logging (required for ${method})`);
356
+ }
357
+ break;
358
+ case 'prompts/get':
359
+ case 'prompts/list':
360
+ if (!this._serverCapabilities?.prompts) {
361
+ throw new Error(`Server does not support prompts (required for ${method})`);
362
+ }
363
+ break;
364
+ case 'resources/list':
365
+ case 'resources/templates/list':
366
+ case 'resources/read':
367
+ case 'resources/subscribe':
368
+ case 'resources/unsubscribe':
369
+ if (!this._serverCapabilities?.resources) {
370
+ throw new Error(`Server does not support resources (required for ${method})`);
371
+ }
372
+ if (method === 'resources/subscribe' && !this._serverCapabilities.resources.subscribe) {
373
+ throw new Error(`Server does not support resource subscriptions (required for ${method})`);
374
+ }
375
+ break;
376
+ case 'tools/call':
377
+ case 'tools/list':
378
+ if (!this._serverCapabilities?.tools) {
379
+ throw new Error(`Server does not support tools (required for ${method})`);
380
+ }
381
+ break;
382
+ case 'completion/complete':
383
+ if (!this._serverCapabilities?.completions) {
384
+ throw new Error(`Server does not support completions (required for ${method})`);
385
+ }
386
+ break;
387
+ case 'initialize':
388
+ // No specific capability required for initialize
389
+ break;
390
+ case 'ping':
391
+ // No specific capability required for ping
392
+ break;
393
+ }
394
+ }
395
+ assertNotificationCapability(method) {
396
+ switch (method) {
397
+ case 'notifications/roots/list_changed':
398
+ if (!this._capabilities.roots?.listChanged) {
399
+ throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
400
+ }
401
+ break;
402
+ case 'notifications/initialized':
403
+ // No specific capability required for initialized
404
+ break;
405
+ case 'notifications/cancelled':
406
+ // Cancellation notifications are always allowed
407
+ break;
408
+ case 'notifications/progress':
409
+ // Progress notifications are always allowed
410
+ break;
411
+ }
412
+ }
413
+ assertRequestHandlerCapability(method) {
414
+ // Task handlers are registered in Protocol constructor before _capabilities is initialized
415
+ // Skip capability check for task methods during initialization
416
+ if (!this._capabilities) {
417
+ return;
418
+ }
419
+ switch (method) {
420
+ case 'sampling/createMessage':
421
+ if (!this._capabilities.sampling) {
422
+ throw new Error(`Client does not support sampling capability (required for ${method})`);
423
+ }
424
+ break;
425
+ case 'elicitation/create':
426
+ if (!this._capabilities.elicitation) {
427
+ throw new Error(`Client does not support elicitation capability (required for ${method})`);
428
+ }
429
+ break;
430
+ case 'roots/list':
431
+ if (!this._capabilities.roots) {
432
+ throw new Error(`Client does not support roots capability (required for ${method})`);
433
+ }
434
+ break;
435
+ case 'tasks/get':
436
+ case 'tasks/list':
437
+ case 'tasks/result':
438
+ case 'tasks/cancel':
439
+ if (!this._capabilities.tasks) {
440
+ throw new Error(`Client does not support tasks capability (required for ${method})`);
441
+ }
442
+ break;
443
+ case 'ping':
444
+ // No specific capability required for ping
445
+ break;
446
+ }
447
+ }
448
+ assertTaskCapability(method) {
449
+ (0, helpers_js_1.assertToolsCallTaskCapability)(this._serverCapabilities?.tasks?.requests, method, 'Server');
450
+ }
451
+ assertTaskHandlerCapability(method) {
452
+ // Task handlers are registered in Protocol constructor before _capabilities is initialized
453
+ // Skip capability check for task methods during initialization
454
+ if (!this._capabilities) {
455
+ return;
456
+ }
457
+ (0, helpers_js_1.assertClientRequestTaskCapability)(this._capabilities.tasks?.requests, method, 'Client');
458
+ }
459
+ async ping(options) {
460
+ return this.request({ method: 'ping' }, types_js_1.EmptyResultSchema, options);
461
+ }
462
+ async complete(params, options) {
463
+ return this.request({ method: 'completion/complete', params }, types_js_1.CompleteResultSchema, options);
464
+ }
465
+ async setLoggingLevel(level, options) {
466
+ return this.request({ method: 'logging/setLevel', params: { level } }, types_js_1.EmptyResultSchema, options);
467
+ }
468
+ async getPrompt(params, options) {
469
+ return this.request({ method: 'prompts/get', params }, types_js_1.GetPromptResultSchema, options);
470
+ }
471
+ async listPrompts(params, options) {
472
+ return this.request({ method: 'prompts/list', params }, types_js_1.ListPromptsResultSchema, options);
473
+ }
474
+ async listResources(params, options) {
475
+ return this.request({ method: 'resources/list', params }, types_js_1.ListResourcesResultSchema, options);
476
+ }
477
+ async listResourceTemplates(params, options) {
478
+ return this.request({ method: 'resources/templates/list', params }, types_js_1.ListResourceTemplatesResultSchema, options);
479
+ }
480
+ async readResource(params, options) {
481
+ return this.request({ method: 'resources/read', params }, types_js_1.ReadResourceResultSchema, options);
482
+ }
483
+ async subscribeResource(params, options) {
484
+ return this.request({ method: 'resources/subscribe', params }, types_js_1.EmptyResultSchema, options);
485
+ }
486
+ async unsubscribeResource(params, options) {
487
+ return this.request({ method: 'resources/unsubscribe', params }, types_js_1.EmptyResultSchema, options);
488
+ }
489
+ /**
490
+ * Calls a tool and waits for the result. Automatically validates structured output if the tool has an outputSchema.
491
+ *
492
+ * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
493
+ */
494
+ async callTool(params, resultSchema = types_js_1.CallToolResultSchema, options) {
495
+ // Guard: required-task tools need experimental API
496
+ if (this.isToolTaskRequired(params.name)) {
497
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidRequest, `Tool "${params.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);
498
+ }
499
+ const result = await this.request({ method: 'tools/call', params }, resultSchema, options);
500
+ // Check if the tool has an outputSchema
501
+ const validator = this.getToolOutputValidator(params.name);
502
+ if (validator) {
503
+ // If tool has outputSchema, it MUST return structuredContent (unless it's an error)
504
+ if (!result.structuredContent && !result.isError) {
505
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`);
506
+ }
507
+ // Only validate structured content if present (not when there's an error)
508
+ if (result.structuredContent) {
509
+ try {
510
+ // Validate the structured content against the schema
511
+ const validationResult = validator(result.structuredContent);
512
+ if (!validationResult.valid) {
513
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`);
514
+ }
515
+ }
516
+ catch (error) {
517
+ if (error instanceof types_js_1.McpError) {
518
+ throw error;
519
+ }
520
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Failed to validate structured content: ${error instanceof Error ? error.message : String(error)}`);
521
+ }
522
+ }
523
+ }
524
+ return result;
525
+ }
526
+ isToolTask(toolName) {
527
+ if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
528
+ return false;
529
+ }
530
+ return this._cachedKnownTaskTools.has(toolName);
531
+ }
532
+ /**
533
+ * Check if a tool requires task-based execution.
534
+ * Unlike isToolTask which includes 'optional' tools, this only checks for 'required'.
535
+ */
536
+ isToolTaskRequired(toolName) {
537
+ return this._cachedRequiredTaskTools.has(toolName);
538
+ }
539
+ /**
540
+ * Cache validators for tool output schemas.
541
+ * Called after listTools() to pre-compile validators for better performance.
542
+ */
543
+ cacheToolMetadata(tools) {
544
+ this._cachedToolOutputValidators.clear();
545
+ this._cachedKnownTaskTools.clear();
546
+ this._cachedRequiredTaskTools.clear();
547
+ for (const tool of tools) {
548
+ // If the tool has an outputSchema, create and cache the validator
549
+ if (tool.outputSchema) {
550
+ const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
551
+ this._cachedToolOutputValidators.set(tool.name, toolValidator);
552
+ }
553
+ // If the tool supports task-based execution, cache that information
554
+ const taskSupport = tool.execution?.taskSupport;
555
+ if (taskSupport === 'required' || taskSupport === 'optional') {
556
+ this._cachedKnownTaskTools.add(tool.name);
557
+ }
558
+ if (taskSupport === 'required') {
559
+ this._cachedRequiredTaskTools.add(tool.name);
560
+ }
561
+ }
562
+ }
563
+ /**
564
+ * Get cached validator for a tool
565
+ */
566
+ getToolOutputValidator(toolName) {
567
+ return this._cachedToolOutputValidators.get(toolName);
568
+ }
569
+ async listTools(params, options) {
570
+ const result = await this.request({ method: 'tools/list', params }, types_js_1.ListToolsResultSchema, options);
571
+ // Cache the tools and their output schemas for future validation
572
+ this.cacheToolMetadata(result.tools);
573
+ return result;
574
+ }
575
+ /**
576
+ * Set up a single list changed handler.
577
+ * @internal
578
+ */
579
+ _setupListChangedHandler(listType, notificationSchema, options, fetcher) {
580
+ // Validate options using Zod schema (validates autoRefresh and debounceMs)
581
+ const parseResult = types_js_1.ListChangedOptionsBaseSchema.safeParse(options);
582
+ if (!parseResult.success) {
583
+ throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
584
+ }
585
+ // Validate callback
586
+ if (typeof options.onChanged !== 'function') {
587
+ throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
588
+ }
589
+ const { autoRefresh, debounceMs } = parseResult.data;
590
+ const { onChanged } = options;
591
+ const refresh = async () => {
592
+ if (!autoRefresh) {
593
+ onChanged(null, null);
594
+ return;
595
+ }
596
+ try {
597
+ const items = await fetcher();
598
+ onChanged(null, items);
599
+ }
600
+ catch (e) {
601
+ const error = e instanceof Error ? e : new Error(String(e));
602
+ onChanged(error, null);
603
+ }
604
+ };
605
+ const handler = () => {
606
+ if (debounceMs) {
607
+ // Clear any pending debounce timer for this list type
608
+ const existingTimer = this._listChangedDebounceTimers.get(listType);
609
+ if (existingTimer) {
610
+ clearTimeout(existingTimer);
611
+ }
612
+ // Set up debounced refresh
613
+ const timer = setTimeout(refresh, debounceMs);
614
+ this._listChangedDebounceTimers.set(listType, timer);
615
+ }
616
+ else {
617
+ // No debounce, refresh immediately
618
+ refresh();
619
+ }
620
+ };
621
+ // Register notification handler
622
+ this.setNotificationHandler(notificationSchema, handler);
623
+ }
624
+ async sendRootsListChanged() {
625
+ return this.notification({ method: 'notifications/roots/list_changed' });
626
+ }
627
+ }
628
+ exports.Client = Client;
629
+ //# sourceMappingURL=index.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { OAuthClientProvider } from './auth.js';
2
+ import { FetchLike } from '../shared/transport.js';
3
+ /**
4
+ * Middleware function that wraps and enhances fetch functionality.
5
+ * Takes a fetch handler and returns an enhanced fetch handler.
6
+ */
7
+ export type Middleware = (next: FetchLike) => FetchLike;
8
+ /**
9
+ * Creates a fetch wrapper that handles OAuth authentication automatically.
10
+ *
11
+ * This wrapper will:
12
+ * - Add Authorization headers with access tokens
13
+ * - Handle 401 responses by attempting re-authentication
14
+ * - Retry the original request after successful auth
15
+ * - Handle OAuth errors appropriately (InvalidClientError, etc.)
16
+ *
17
+ * The baseUrl parameter is optional and defaults to using the domain from the request URL.
18
+ * However, you should explicitly provide baseUrl when:
19
+ * - Making requests to multiple subdomains (e.g., api.example.com, cdn.example.com)
20
+ * - Using API paths that differ from OAuth discovery paths (e.g., requesting /api/v1/data but OAuth is at /)
21
+ * - The OAuth server is on a different domain than your API requests
22
+ * - You want to ensure consistent OAuth behavior regardless of request URLs
23
+ *
24
+ * For MCP transports, set baseUrl to the same URL you pass to the transport constructor.
25
+ *
26
+ * Note: This wrapper is designed for general-purpose fetch operations.
27
+ * MCP transports (SSE and StreamableHTTP) already have built-in OAuth handling
28
+ * and should not need this wrapper.
29
+ *
30
+ * @param provider - OAuth client provider for authentication
31
+ * @param baseUrl - Base URL for OAuth server discovery (defaults to request URL domain)
32
+ * @returns A fetch middleware function
33
+ */
34
+ export declare const withOAuth: (provider: OAuthClientProvider, baseUrl?: string | URL) => Middleware;
35
+ /**
36
+ * Logger function type for HTTP requests
37
+ */
38
+ export type RequestLogger = (input: {
39
+ method: string;
40
+ url: string | URL;
41
+ status: number;
42
+ statusText: string;
43
+ duration: number;
44
+ requestHeaders?: Headers;
45
+ responseHeaders?: Headers;
46
+ error?: Error;
47
+ }) => void;
48
+ /**
49
+ * Configuration options for the logging middleware
50
+ */
51
+ export type LoggingOptions = {
52
+ /**
53
+ * Custom logger function, defaults to console logging
54
+ */
55
+ logger?: RequestLogger;
56
+ /**
57
+ * Whether to include request headers in logs
58
+ * @default false
59
+ */
60
+ includeRequestHeaders?: boolean;
61
+ /**
62
+ * Whether to include response headers in logs
63
+ * @default false
64
+ */
65
+ includeResponseHeaders?: boolean;
66
+ /**
67
+ * Status level filter - only log requests with status >= this value
68
+ * Set to 0 to log all requests, 400 to log only errors
69
+ * @default 0
70
+ */
71
+ statusLevel?: number;
72
+ };
73
+ /**
74
+ * Creates a fetch middleware that logs HTTP requests and responses.
75
+ *
76
+ * When called without arguments `withLogging()`, it uses the default logger that:
77
+ * - Logs successful requests (2xx) to `console.log`
78
+ * - Logs error responses (4xx/5xx) and network errors to `console.error`
79
+ * - Logs all requests regardless of status (statusLevel: 0)
80
+ * - Does not include request or response headers in logs
81
+ * - Measures and displays request duration in milliseconds
82
+ *
83
+ * Important: the default logger uses both `console.log` and `console.error` so it should not be used with
84
+ * `stdio` transports and applications.
85
+ *
86
+ * @param options - Logging configuration options
87
+ * @returns A fetch middleware function
88
+ */
89
+ export declare const withLogging: (options?: LoggingOptions) => Middleware;
90
+ /**
91
+ * Composes multiple fetch middleware functions into a single middleware pipeline.
92
+ * Middleware are applied in the order they appear, creating a chain of handlers.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * // Create a middleware pipeline that handles both OAuth and logging
97
+ * const enhancedFetch = applyMiddlewares(
98
+ * withOAuth(oauthProvider, 'https://api.example.com'),
99
+ * withLogging({ statusLevel: 400 })
100
+ * )(fetch);
101
+ *
102
+ * // Use the enhanced fetch - it will handle auth and log errors
103
+ * const response = await enhancedFetch('https://api.example.com/data');
104
+ * ```
105
+ *
106
+ * @param middleware - Array of fetch middleware to compose into a pipeline
107
+ * @returns A single composed middleware function
108
+ */
109
+ export declare const applyMiddlewares: (...middleware: Middleware[]) => Middleware;
110
+ /**
111
+ * Helper function to create custom fetch middleware with cleaner syntax.
112
+ * Provides the next handler and request details as separate parameters for easier access.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * // Create custom authentication middleware
117
+ * const customAuthMiddleware = createMiddleware(async (next, input, init) => {
118
+ * const headers = new Headers(init?.headers);
119
+ * headers.set('X-Custom-Auth', 'my-token');
120
+ *
121
+ * const response = await next(input, { ...init, headers });
122
+ *
123
+ * if (response.status === 401) {
124
+ * console.log('Authentication failed');
125
+ * }
126
+ *
127
+ * return response;
128
+ * });
129
+ *
130
+ * // Create conditional middleware
131
+ * const conditionalMiddleware = createMiddleware(async (next, input, init) => {
132
+ * const url = typeof input === 'string' ? input : input.toString();
133
+ *
134
+ * // Only add headers for API routes
135
+ * if (url.includes('/api/')) {
136
+ * const headers = new Headers(init?.headers);
137
+ * headers.set('X-API-Version', 'v2');
138
+ * return next(input, { ...init, headers });
139
+ * }
140
+ *
141
+ * // Pass through for non-API routes
142
+ * return next(input, init);
143
+ * });
144
+ *
145
+ * // Create caching middleware
146
+ * const cacheMiddleware = createMiddleware(async (next, input, init) => {
147
+ * const cacheKey = typeof input === 'string' ? input : input.toString();
148
+ *
149
+ * // Check cache first
150
+ * const cached = await getFromCache(cacheKey);
151
+ * if (cached) {
152
+ * return new Response(cached, { status: 200 });
153
+ * }
154
+ *
155
+ * // Make request and cache result
156
+ * const response = await next(input, init);
157
+ * if (response.ok) {
158
+ * await saveToCache(cacheKey, await response.clone().text());
159
+ * }
160
+ *
161
+ * return response;
162
+ * });
163
+ * ```
164
+ *
165
+ * @param handler - Function that receives the next handler and request parameters
166
+ * @returns A fetch middleware function
167
+ */
168
+ export declare const createMiddleware: (handler: (next: FetchLike, input: string | URL, init?: RequestInit) => Promise<Response>) => Middleware;
169
+ //# sourceMappingURL=middleware.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/middleware.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/client/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,mBAAmB,EAAqB,MAAM,WAAW,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,SAAS,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,SAAS,aACP,mBAAmB,YAAY,MAAM,GAAG,GAAG,KAAG,UA0DxD,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;CACjB,KAAK,IAAI,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,aAAa,cAAc,KAAQ,UA6E1D,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,kBAAmB,UAAU,EAAE,KAAG,UAI9D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,eAAO,MAAM,gBAAgB,YAAa,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,KAAG,UAE3H,CAAC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/middleware.js ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMiddleware = exports.applyMiddlewares = exports.withLogging = exports.withOAuth = void 0;
4
+ const auth_js_1 = require("./auth.js");
5
+ /**
6
+ * Creates a fetch wrapper that handles OAuth authentication automatically.
7
+ *
8
+ * This wrapper will:
9
+ * - Add Authorization headers with access tokens
10
+ * - Handle 401 responses by attempting re-authentication
11
+ * - Retry the original request after successful auth
12
+ * - Handle OAuth errors appropriately (InvalidClientError, etc.)
13
+ *
14
+ * The baseUrl parameter is optional and defaults to using the domain from the request URL.
15
+ * However, you should explicitly provide baseUrl when:
16
+ * - Making requests to multiple subdomains (e.g., api.example.com, cdn.example.com)
17
+ * - Using API paths that differ from OAuth discovery paths (e.g., requesting /api/v1/data but OAuth is at /)
18
+ * - The OAuth server is on a different domain than your API requests
19
+ * - You want to ensure consistent OAuth behavior regardless of request URLs
20
+ *
21
+ * For MCP transports, set baseUrl to the same URL you pass to the transport constructor.
22
+ *
23
+ * Note: This wrapper is designed for general-purpose fetch operations.
24
+ * MCP transports (SSE and StreamableHTTP) already have built-in OAuth handling
25
+ * and should not need this wrapper.
26
+ *
27
+ * @param provider - OAuth client provider for authentication
28
+ * @param baseUrl - Base URL for OAuth server discovery (defaults to request URL domain)
29
+ * @returns A fetch middleware function
30
+ */
31
+ const withOAuth = (provider, baseUrl) => next => {
32
+ return async (input, init) => {
33
+ const makeRequest = async () => {
34
+ const headers = new Headers(init?.headers);
35
+ // Add authorization header if tokens are available
36
+ const tokens = await provider.tokens();
37
+ if (tokens) {
38
+ headers.set('Authorization', `Bearer ${tokens.access_token}`);
39
+ }
40
+ return await next(input, { ...init, headers });
41
+ };
42
+ let response = await makeRequest();
43
+ // Handle 401 responses by attempting re-authentication
44
+ if (response.status === 401) {
45
+ try {
46
+ const { resourceMetadataUrl, scope } = (0, auth_js_1.extractWWWAuthenticateParams)(response);
47
+ // Use provided baseUrl or extract from request URL
48
+ const serverUrl = baseUrl || (typeof input === 'string' ? new URL(input).origin : input.origin);
49
+ const result = await (0, auth_js_1.auth)(provider, {
50
+ serverUrl,
51
+ resourceMetadataUrl,
52
+ scope,
53
+ fetchFn: next
54
+ });
55
+ if (result === 'REDIRECT') {
56
+ throw new auth_js_1.UnauthorizedError('Authentication requires user authorization - redirect initiated');
57
+ }
58
+ if (result !== 'AUTHORIZED') {
59
+ throw new auth_js_1.UnauthorizedError(`Authentication failed with result: ${result}`);
60
+ }
61
+ // Retry the request with fresh tokens
62
+ response = await makeRequest();
63
+ }
64
+ catch (error) {
65
+ if (error instanceof auth_js_1.UnauthorizedError) {
66
+ throw error;
67
+ }
68
+ throw new auth_js_1.UnauthorizedError(`Failed to re-authenticate: ${error instanceof Error ? error.message : String(error)}`);
69
+ }
70
+ }
71
+ // If we still have a 401 after re-auth attempt, throw an error
72
+ if (response.status === 401) {
73
+ const url = typeof input === 'string' ? input : input.toString();
74
+ throw new auth_js_1.UnauthorizedError(`Authentication failed for ${url}`);
75
+ }
76
+ return response;
77
+ };
78
+ };
79
+ exports.withOAuth = withOAuth;
80
+ /**
81
+ * Creates a fetch middleware that logs HTTP requests and responses.
82
+ *
83
+ * When called without arguments `withLogging()`, it uses the default logger that:
84
+ * - Logs successful requests (2xx) to `console.log`
85
+ * - Logs error responses (4xx/5xx) and network errors to `console.error`
86
+ * - Logs all requests regardless of status (statusLevel: 0)
87
+ * - Does not include request or response headers in logs
88
+ * - Measures and displays request duration in milliseconds
89
+ *
90
+ * Important: the default logger uses both `console.log` and `console.error` so it should not be used with
91
+ * `stdio` transports and applications.
92
+ *
93
+ * @param options - Logging configuration options
94
+ * @returns A fetch middleware function
95
+ */
96
+ const withLogging = (options = {}) => {
97
+ const { logger, includeRequestHeaders = false, includeResponseHeaders = false, statusLevel = 0 } = options;
98
+ const defaultLogger = input => {
99
+ const { method, url, status, statusText, duration, requestHeaders, responseHeaders, error } = input;
100
+ let message = error
101
+ ? `HTTP ${method} ${url} failed: ${error.message} (${duration}ms)`
102
+ : `HTTP ${method} ${url} ${status} ${statusText} (${duration}ms)`;
103
+ // Add headers to message if requested
104
+ if (includeRequestHeaders && requestHeaders) {
105
+ const reqHeaders = Array.from(requestHeaders.entries())
106
+ .map(([key, value]) => `${key}: ${value}`)
107
+ .join(', ');
108
+ message += `\n Request Headers: {${reqHeaders}}`;
109
+ }
110
+ if (includeResponseHeaders && responseHeaders) {
111
+ const resHeaders = Array.from(responseHeaders.entries())
112
+ .map(([key, value]) => `${key}: ${value}`)
113
+ .join(', ');
114
+ message += `\n Response Headers: {${resHeaders}}`;
115
+ }
116
+ if (error || status >= 400) {
117
+ // eslint-disable-next-line no-console
118
+ console.error(message);
119
+ }
120
+ else {
121
+ // eslint-disable-next-line no-console
122
+ console.log(message);
123
+ }
124
+ };
125
+ const logFn = logger || defaultLogger;
126
+ return next => async (input, init) => {
127
+ const startTime = performance.now();
128
+ const method = init?.method || 'GET';
129
+ const url = typeof input === 'string' ? input : input.toString();
130
+ const requestHeaders = includeRequestHeaders ? new Headers(init?.headers) : undefined;
131
+ try {
132
+ const response = await next(input, init);
133
+ const duration = performance.now() - startTime;
134
+ // Only log if status meets the log level threshold
135
+ if (response.status >= statusLevel) {
136
+ logFn({
137
+ method,
138
+ url,
139
+ status: response.status,
140
+ statusText: response.statusText,
141
+ duration,
142
+ requestHeaders,
143
+ responseHeaders: includeResponseHeaders ? response.headers : undefined
144
+ });
145
+ }
146
+ return response;
147
+ }
148
+ catch (error) {
149
+ const duration = performance.now() - startTime;
150
+ // Always log errors regardless of log level
151
+ logFn({
152
+ method,
153
+ url,
154
+ status: 0,
155
+ statusText: 'Network Error',
156
+ duration,
157
+ requestHeaders,
158
+ error: error
159
+ });
160
+ throw error;
161
+ }
162
+ };
163
+ };
164
+ exports.withLogging = withLogging;
165
+ /**
166
+ * Composes multiple fetch middleware functions into a single middleware pipeline.
167
+ * Middleware are applied in the order they appear, creating a chain of handlers.
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * // Create a middleware pipeline that handles both OAuth and logging
172
+ * const enhancedFetch = applyMiddlewares(
173
+ * withOAuth(oauthProvider, 'https://api.example.com'),
174
+ * withLogging({ statusLevel: 400 })
175
+ * )(fetch);
176
+ *
177
+ * // Use the enhanced fetch - it will handle auth and log errors
178
+ * const response = await enhancedFetch('https://api.example.com/data');
179
+ * ```
180
+ *
181
+ * @param middleware - Array of fetch middleware to compose into a pipeline
182
+ * @returns A single composed middleware function
183
+ */
184
+ const applyMiddlewares = (...middleware) => {
185
+ return next => {
186
+ return middleware.reduce((handler, mw) => mw(handler), next);
187
+ };
188
+ };
189
+ exports.applyMiddlewares = applyMiddlewares;
190
+ /**
191
+ * Helper function to create custom fetch middleware with cleaner syntax.
192
+ * Provides the next handler and request details as separate parameters for easier access.
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * // Create custom authentication middleware
197
+ * const customAuthMiddleware = createMiddleware(async (next, input, init) => {
198
+ * const headers = new Headers(init?.headers);
199
+ * headers.set('X-Custom-Auth', 'my-token');
200
+ *
201
+ * const response = await next(input, { ...init, headers });
202
+ *
203
+ * if (response.status === 401) {
204
+ * console.log('Authentication failed');
205
+ * }
206
+ *
207
+ * return response;
208
+ * });
209
+ *
210
+ * // Create conditional middleware
211
+ * const conditionalMiddleware = createMiddleware(async (next, input, init) => {
212
+ * const url = typeof input === 'string' ? input : input.toString();
213
+ *
214
+ * // Only add headers for API routes
215
+ * if (url.includes('/api/')) {
216
+ * const headers = new Headers(init?.headers);
217
+ * headers.set('X-API-Version', 'v2');
218
+ * return next(input, { ...init, headers });
219
+ * }
220
+ *
221
+ * // Pass through for non-API routes
222
+ * return next(input, init);
223
+ * });
224
+ *
225
+ * // Create caching middleware
226
+ * const cacheMiddleware = createMiddleware(async (next, input, init) => {
227
+ * const cacheKey = typeof input === 'string' ? input : input.toString();
228
+ *
229
+ * // Check cache first
230
+ * const cached = await getFromCache(cacheKey);
231
+ * if (cached) {
232
+ * return new Response(cached, { status: 200 });
233
+ * }
234
+ *
235
+ * // Make request and cache result
236
+ * const response = await next(input, init);
237
+ * if (response.ok) {
238
+ * await saveToCache(cacheKey, await response.clone().text());
239
+ * }
240
+ *
241
+ * return response;
242
+ * });
243
+ * ```
244
+ *
245
+ * @param handler - Function that receives the next handler and request parameters
246
+ * @returns A fetch middleware function
247
+ */
248
+ const createMiddleware = (handler) => {
249
+ return next => (input, init) => handler(next, input, init);
250
+ };
251
+ exports.createMiddleware = createMiddleware;
252
+ //# sourceMappingURL=middleware.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/middleware.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/client/middleware.ts"],"names":[],"mappings":";;;AAAA,uCAAuG;AASvG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,MAAM,SAAS,GAClB,CAAC,QAA6B,EAAE,OAAsB,EAAc,EAAE,CACtE,IAAI,CAAC,EAAE;IACH,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,WAAW,GAAG,KAAK,IAAuB,EAAE;YAC9C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAE3C,mDAAmD;YACnD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;YACvC,IAAI,MAAM,EAAE,CAAC;gBACT,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;YAClE,CAAC;YAED,OAAO,MAAM,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC;QAEF,IAAI,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;QAEnC,uDAAuD;QACvD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC1B,IAAI,CAAC;gBACD,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,IAAA,sCAA4B,EAAC,QAAQ,CAAC,CAAC;gBAE9E,mDAAmD;gBACnD,MAAM,SAAS,GAAG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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { type ErrorEvent, type EventSourceInit } from 'eventsource';
2
+ import { Transport, FetchLike } from '../shared/transport.js';
3
+ import { JSONRPCMessage } from '../types.js';
4
+ import { OAuthClientProvider } from './auth.js';
5
+ export declare class SseError extends Error {
6
+ readonly code: number | undefined;
7
+ readonly event: ErrorEvent;
8
+ constructor(code: number | undefined, message: string | undefined, event: ErrorEvent);
9
+ }
10
+ /**
11
+ * Configuration options for the `SSEClientTransport`.
12
+ */
13
+ export type SSEClientTransportOptions = {
14
+ /**
15
+ * An OAuth client provider to use for authentication.
16
+ *
17
+ * When an `authProvider` is specified and the SSE connection is started:
18
+ * 1. The connection is attempted with any existing access token from the `authProvider`.
19
+ * 2. If the access token has expired, the `authProvider` is used to refresh the token.
20
+ * 3. If token refresh fails or no access token exists, and auth is required, `OAuthClientProvider.redirectToAuthorization` is called, and an `UnauthorizedError` will be thrown from `connect`/`start`.
21
+ *
22
+ * After the user has finished authorizing via their user agent, and is redirected back to the MCP client application, call `SSEClientTransport.finishAuth` with the authorization code before retrying the connection.
23
+ *
24
+ * If an `authProvider` is not provided, and auth is required, an `UnauthorizedError` will be thrown.
25
+ *
26
+ * `UnauthorizedError` might also be thrown when sending any message over the SSE transport, indicating that the session has expired, and needs to be re-authed and reconnected.
27
+ */
28
+ authProvider?: OAuthClientProvider;
29
+ /**
30
+ * Customizes the initial SSE request to the server (the request that begins the stream).
31
+ *
32
+ * NOTE: Setting this property will prevent an `Authorization` header from
33
+ * being automatically attached to the SSE request, if an `authProvider` is
34
+ * also given. This can be worked around by setting the `Authorization` header
35
+ * manually.
36
+ */
37
+ eventSourceInit?: EventSourceInit;
38
+ /**
39
+ * Customizes recurring POST requests to the server.
40
+ */
41
+ requestInit?: RequestInit;
42
+ /**
43
+ * Custom fetch implementation used for all network requests.
44
+ */
45
+ fetch?: FetchLike;
46
+ };
47
+ /**
48
+ * Client transport for SSE: this will connect to a server using Server-Sent Events for receiving
49
+ * messages and make separate POST requests for sending messages.
50
+ * @deprecated SSEClientTransport is deprecated. Prefer to use StreamableHTTPClientTransport where possible instead. Note that because some servers are still using SSE, clients may need to support both transports during the migration period.
51
+ */
52
+ export declare class SSEClientTransport implements Transport {
53
+ private _eventSource?;
54
+ private _endpoint?;
55
+ private _abortController?;
56
+ private _url;
57
+ private _resourceMetadataUrl?;
58
+ private _scope?;
59
+ private _eventSourceInit?;
60
+ private _requestInit?;
61
+ private _authProvider?;
62
+ private _fetch?;
63
+ private _fetchWithInit;
64
+ private _protocolVersion?;
65
+ onclose?: () => void;
66
+ onerror?: (error: Error) => void;
67
+ onmessage?: (message: JSONRPCMessage) => void;
68
+ constructor(url: URL, opts?: SSEClientTransportOptions);
69
+ private _authThenStart;
70
+ private _commonHeaders;
71
+ private _startOrAuth;
72
+ start(): Promise<void>;
73
+ /**
74
+ * Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
75
+ */
76
+ finishAuth(authorizationCode: string): Promise<void>;
77
+ close(): Promise<void>;
78
+ send(message: JSONRPCMessage): Promise<void>;
79
+ setProtocolVersion(version: string): void;
80
+ }
81
+ //# sourceMappingURL=sse.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/sse.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/client/sse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAyC,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AACnE,OAAO,EAAkD,mBAAmB,EAAqB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Ac;IAoB5B,OAAO,CAAC,YAAY;IAyEd,KAAK;IAQX;;OAEG;IACG,UAAU,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkDlD,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG5C"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/sse.js ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SSEClientTransport = exports.SseError = void 0;
4
+ const eventsource_1 = require("eventsource");
5
+ const transport_js_1 = require("../shared/transport.js");
6
+ const types_js_1 = require("../types.js");
7
+ const auth_js_1 = require("./auth.js");
8
+ class SseError extends Error {
9
+ constructor(code, message, event) {
10
+ super(`SSE error: ${message}`);
11
+ this.code = code;
12
+ this.event = event;
13
+ }
14
+ }
15
+ exports.SseError = SseError;
16
+ /**
17
+ * Client transport for SSE: this will connect to a server using Server-Sent Events for receiving
18
+ * messages and make separate POST requests for sending messages.
19
+ * @deprecated SSEClientTransport is deprecated. Prefer to use StreamableHTTPClientTransport where possible instead. Note that because some servers are still using SSE, clients may need to support both transports during the migration period.
20
+ */
21
+ class SSEClientTransport {
22
+ constructor(url, opts) {
23
+ this._url = url;
24
+ this._resourceMetadataUrl = undefined;
25
+ this._scope = undefined;
26
+ this._eventSourceInit = opts?.eventSourceInit;
27
+ this._requestInit = opts?.requestInit;
28
+ this._authProvider = opts?.authProvider;
29
+ this._fetch = opts?.fetch;
30
+ this._fetchWithInit = (0, transport_js_1.createFetchWithInit)(opts?.fetch, opts?.requestInit);
31
+ }
32
+ async _authThenStart() {
33
+ if (!this._authProvider) {
34
+ throw new auth_js_1.UnauthorizedError('No auth provider');
35
+ }
36
+ let result;
37
+ try {
38
+ result = await (0, auth_js_1.auth)(this._authProvider, {
39
+ serverUrl: this._url,
40
+ resourceMetadataUrl: this._resourceMetadataUrl,
41
+ scope: this._scope,
42
+ fetchFn: this._fetchWithInit
43
+ });
44
+ }
45
+ catch (error) {
46
+ this.onerror?.(error);
47
+ throw error;
48
+ }
49
+ if (result !== 'AUTHORIZED') {
50
+ throw new auth_js_1.UnauthorizedError();
51
+ }
52
+ return await this._startOrAuth();
53
+ }
54
+ async _commonHeaders() {
55
+ const headers = {};
56
+ if (this._authProvider) {
57
+ const tokens = await this._authProvider.tokens();
58
+ if (tokens) {
59
+ headers['Authorization'] = `Bearer ${tokens.access_token}`;
60
+ }
61
+ }
62
+ if (this._protocolVersion) {
63
+ headers['mcp-protocol-version'] = this._protocolVersion;
64
+ }
65
+ const extraHeaders = (0, transport_js_1.normalizeHeaders)(this._requestInit?.headers);
66
+ return new Headers({
67
+ ...headers,
68
+ ...extraHeaders
69
+ });
70
+ }
71
+ _startOrAuth() {
72
+ const fetchImpl = (this?._eventSourceInit?.fetch ?? this._fetch ?? fetch);
73
+ return new Promise((resolve, reject) => {
74
+ this._eventSource = new eventsource_1.EventSource(this._url.href, {
75
+ ...this._eventSourceInit,
76
+ fetch: async (url, init) => {
77
+ const headers = await this._commonHeaders();
78
+ headers.set('Accept', 'text/event-stream');
79
+ const response = await fetchImpl(url, {
80
+ ...init,
81
+ headers
82
+ });
83
+ if (response.status === 401 && response.headers.has('www-authenticate')) {
84
+ const { resourceMetadataUrl, scope } = (0, auth_js_1.extractWWWAuthenticateParams)(response);
85
+ this._resourceMetadataUrl = resourceMetadataUrl;
86
+ this._scope = scope;
87
+ }
88
+ return response;
89
+ }
90
+ });
91
+ this._abortController = new AbortController();
92
+ this._eventSource.onerror = event => {
93
+ if (event.code === 401 && this._authProvider) {
94
+ this._authThenStart().then(resolve, reject);
95
+ return;
96
+ }
97
+ const error = new SseError(event.code, event.message, event);
98
+ reject(error);
99
+ this.onerror?.(error);
100
+ };
101
+ this._eventSource.onopen = () => {
102
+ // The connection is open, but we need to wait for the endpoint to be received.
103
+ };
104
+ this._eventSource.addEventListener('endpoint', (event) => {
105
+ const messageEvent = event;
106
+ try {
107
+ this._endpoint = new URL(messageEvent.data, this._url);
108
+ if (this._endpoint.origin !== this._url.origin) {
109
+ throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
110
+ }
111
+ }
112
+ catch (error) {
113
+ reject(error);
114
+ this.onerror?.(error);
115
+ void this.close();
116
+ return;
117
+ }
118
+ resolve();
119
+ });
120
+ this._eventSource.onmessage = (event) => {
121
+ const messageEvent = event;
122
+ let message;
123
+ try {
124
+ message = types_js_1.JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
125
+ }
126
+ catch (error) {
127
+ this.onerror?.(error);
128
+ return;
129
+ }
130
+ this.onmessage?.(message);
131
+ };
132
+ });
133
+ }
134
+ async start() {
135
+ if (this._eventSource) {
136
+ throw new Error('SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.');
137
+ }
138
+ return await this._startOrAuth();
139
+ }
140
+ /**
141
+ * Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
142
+ */
143
+ async finishAuth(authorizationCode) {
144
+ if (!this._authProvider) {
145
+ throw new auth_js_1.UnauthorizedError('No auth provider');
146
+ }
147
+ const result = await (0, auth_js_1.auth)(this._authProvider, {
148
+ serverUrl: this._url,
149
+ authorizationCode,
150
+ resourceMetadataUrl: this._resourceMetadataUrl,
151
+ scope: this._scope,
152
+ fetchFn: this._fetchWithInit
153
+ });
154
+ if (result !== 'AUTHORIZED') {
155
+ throw new auth_js_1.UnauthorizedError('Failed to authorize');
156
+ }
157
+ }
158
+ async close() {
159
+ this._abortController?.abort();
160
+ this._eventSource?.close();
161
+ this.onclose?.();
162
+ }
163
+ async send(message) {
164
+ if (!this._endpoint) {
165
+ throw new Error('Not connected');
166
+ }
167
+ try {
168
+ const headers = await this._commonHeaders();
169
+ headers.set('content-type', 'application/json');
170
+ const init = {
171
+ ...this._requestInit,
172
+ method: 'POST',
173
+ headers,
174
+ body: JSON.stringify(message),
175
+ signal: this._abortController?.signal
176
+ };
177
+ const response = await (this._fetch ?? fetch)(this._endpoint, init);
178
+ if (!response.ok) {
179
+ const text = await response.text().catch(() => null);
180
+ if (response.status === 401 && this._authProvider) {
181
+ const { resourceMetadataUrl, scope } = (0, auth_js_1.extractWWWAuthenticateParams)(response);
182
+ this._resourceMetadataUrl = resourceMetadataUrl;
183
+ this._scope = scope;
184
+ const result = await (0, auth_js_1.auth)(this._authProvider, {
185
+ serverUrl: this._url,
186
+ resourceMetadataUrl: this._resourceMetadataUrl,
187
+ scope: this._scope,
188
+ fetchFn: this._fetchWithInit
189
+ });
190
+ if (result !== 'AUTHORIZED') {
191
+ throw new auth_js_1.UnauthorizedError();
192
+ }
193
+ // Purposely _not_ awaited, so we don't call onerror twice
194
+ return this.send(message);
195
+ }
196
+ throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
197
+ }
198
+ // Release connection - POST responses don't have content we need
199
+ await response.body?.cancel();
200
+ }
201
+ catch (error) {
202
+ this.onerror?.(error);
203
+ throw error;
204
+ }
205
+ }
206
+ setProtocolVersion(version) {
207
+ this._protocolVersion = version;
208
+ }
209
+ }
210
+ exports.SSEClientTransport = SSEClientTransport;
211
+ //# sourceMappingURL=sse.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/sse.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"sse.js","sourceRoot":"","sources":["../../../src/client/sse.ts"],"names":[],"mappings":";;;AAAA,6CAAiF;AACjF,yDAAqG;AACrG,0CAAmE;AACnE,uCAAmH;AAEnH,MAAa,QAAS,SAAQ,KAAK;IAC/B,YACoB,IAAwB,EACxC,OAA2B,EACX,KAAiB;QAEjC,KAAK,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;QAJf,SAAI,GAAJ,IAAI,CAAoB;QAExB,UAAK,GAAL,KAAK,CAAY;IAGrC,CAAC;CACJ;AARD,4BAQC;AA2CD;;;;GAIG;AACH,MAAa,kBAAkB;IAkB3B,YAAY,GAAQ,EAAE,IAAgC;QAClD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,gBAAgB,GAAG,IAAI,EAAE,eAAe,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,EAAE,WAAW,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,IAAI,EAAE,YAAY,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAA,kCAAmB,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IAC9E,CAAC;IAEO,KAAK,CAAC,cAAc;QACxB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACtB,MAAM,IAAI,2BAAiB,CAAC,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,IAAI,MAAM,KAAK,YAAY,EAAE,CAAC;wBAC1B,MAAM,IAAI,2BAAiB,EAAE,CAAC;oBAClC,CAAC;oBAED,0DAA0D;oBAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC9B,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;YACpF,CAAC;YAED,iEAAiE;YACjE,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,EAAE,CAAC,KAAc,CAAC,CAAC;YAC/B,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED,kBAAkB,CAAC,OAAe;QAC9B,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC;IACpC,CAAC;CACJ;AA1OD,gDA0OC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { IOType } from 'node:child_process';
2
+ import { Stream } from 'node:stream';
3
+ import { Transport } from '../shared/transport.js';
4
+ import { JSONRPCMessage } from '../types.js';
5
+ export type StdioServerParameters = {
6
+ /**
7
+ * The executable to run to start the server.
8
+ */
9
+ command: string;
10
+ /**
11
+ * Command line arguments to pass to the executable.
12
+ */
13
+ args?: string[];
14
+ /**
15
+ * The environment to use when spawning the process.
16
+ *
17
+ * If not specified, the result of getDefaultEnvironment() will be used.
18
+ */
19
+ env?: Record<string, string>;
20
+ /**
21
+ * How to handle stderr of the child process. This matches the semantics of Node's `child_process.spawn`.
22
+ *
23
+ * The default is "inherit", meaning messages to stderr will be printed to the parent process's stderr.
24
+ */
25
+ stderr?: IOType | Stream | number;
26
+ /**
27
+ * The working directory to use when spawning the process.
28
+ *
29
+ * If not specified, the current working directory will be inherited.
30
+ */
31
+ cwd?: string;
32
+ };
33
+ /**
34
+ * Environment variables to inherit by default, if an environment is not explicitly given.
35
+ */
36
+ export declare const DEFAULT_INHERITED_ENV_VARS: string[];
37
+ /**
38
+ * Returns a default environment object including only environment variables deemed safe to inherit.
39
+ */
40
+ export declare function getDefaultEnvironment(): Record<string, string>;
41
+ /**
42
+ * Client transport for stdio: this will connect to a server by spawning a process and communicating with it over stdin/stdout.
43
+ *
44
+ * This transport is only available in Node.js environments.
45
+ */
46
+ export declare class StdioClientTransport implements Transport {
47
+ private _process?;
48
+ private _readBuffer;
49
+ private _serverParams;
50
+ private _stderrStream;
51
+ onclose?: () => void;
52
+ onerror?: (error: Error) => void;
53
+ onmessage?: (message: JSONRPCMessage) => void;
54
+ constructor(server: StdioServerParameters);
55
+ /**
56
+ * Starts the server process and prepares to communicate with it.
57
+ */
58
+ start(): Promise<void>;
59
+ /**
60
+ * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
61
+ *
62
+ * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to
63
+ * attach listeners before the start method is invoked. This prevents loss of any early
64
+ * error output emitted by the child process.
65
+ */
66
+ get stderr(): Stream | null;
67
+ /**
68
+ * The child process pid spawned by this transport.
69
+ *
70
+ * This is only available after the transport has been started.
71
+ */
72
+ get pid(): number | null;
73
+ private processReadBuffer;
74
+ close(): Promise<void>;
75
+ send(message: JSONRPCMessage): Promise<void>;
76
+ }
77
+ //# sourceMappingURL=stdio.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","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;IAED;;;;OAIG;IACH,IAAI,GAAG,IAAI,MAAM,GAAG,IAAI,CAEvB;IAED,OAAO,CAAC,iBAAiB;IAenB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyC5B,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAc/C"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StdioClientTransport = exports.DEFAULT_INHERITED_ENV_VARS = void 0;
7
+ exports.getDefaultEnvironment = getDefaultEnvironment;
8
+ const cross_spawn_1 = __importDefault(require("cross-spawn"));
9
+ const node_process_1 = __importDefault(require("node:process"));
10
+ const node_stream_1 = require("node:stream");
11
+ const stdio_js_1 = require("../shared/stdio.js");
12
+ /**
13
+ * Environment variables to inherit by default, if an environment is not explicitly given.
14
+ */
15
+ exports.DEFAULT_INHERITED_ENV_VARS = node_process_1.default.platform === 'win32'
16
+ ? [
17
+ 'APPDATA',
18
+ 'HOMEDRIVE',
19
+ 'HOMEPATH',
20
+ 'LOCALAPPDATA',
21
+ 'PATH',
22
+ 'PROCESSOR_ARCHITECTURE',
23
+ 'SYSTEMDRIVE',
24
+ 'SYSTEMROOT',
25
+ 'TEMP',
26
+ 'USERNAME',
27
+ 'USERPROFILE',
28
+ 'PROGRAMFILES'
29
+ ]
30
+ : /* list inspired by the default env inheritance of sudo */
31
+ ['HOME', 'LOGNAME', 'PATH', 'SHELL', 'TERM', 'USER'];
32
+ /**
33
+ * Returns a default environment object including only environment variables deemed safe to inherit.
34
+ */
35
+ function getDefaultEnvironment() {
36
+ const env = {};
37
+ for (const key of exports.DEFAULT_INHERITED_ENV_VARS) {
38
+ const value = node_process_1.default.env[key];
39
+ if (value === undefined) {
40
+ continue;
41
+ }
42
+ if (value.startsWith('()')) {
43
+ // Skip functions, which are a security risk.
44
+ continue;
45
+ }
46
+ env[key] = value;
47
+ }
48
+ return env;
49
+ }
50
+ /**
51
+ * Client transport for stdio: this will connect to a server by spawning a process and communicating with it over stdin/stdout.
52
+ *
53
+ * This transport is only available in Node.js environments.
54
+ */
55
+ class StdioClientTransport {
56
+ constructor(server) {
57
+ this._readBuffer = new stdio_js_1.ReadBuffer();
58
+ this._stderrStream = null;
59
+ this._serverParams = server;
60
+ if (server.stderr === 'pipe' || server.stderr === 'overlapped') {
61
+ this._stderrStream = new node_stream_1.PassThrough();
62
+ }
63
+ }
64
+ /**
65
+ * Starts the server process and prepares to communicate with it.
66
+ */
67
+ async start() {
68
+ if (this._process) {
69
+ throw new Error('StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.');
70
+ }
71
+ return new Promise((resolve, reject) => {
72
+ this._process = (0, cross_spawn_1.default)(this._serverParams.command, this._serverParams.args ?? [], {
73
+ // merge default env with server env because mcp server needs some env vars
74
+ env: {
75
+ ...getDefaultEnvironment(),
76
+ ...this._serverParams.env
77
+ },
78
+ stdio: ['pipe', 'pipe', this._serverParams.stderr ?? 'inherit'],
79
+ shell: false,
80
+ windowsHide: node_process_1.default.platform === 'win32',
81
+ cwd: this._serverParams.cwd
82
+ });
83
+ this._process.on('error', error => {
84
+ reject(error);
85
+ this.onerror?.(error);
86
+ });
87
+ this._process.on('spawn', () => {
88
+ resolve();
89
+ });
90
+ this._process.on('close', _code => {
91
+ this._process = undefined;
92
+ this.onclose?.();
93
+ });
94
+ this._process.stdin?.on('error', error => {
95
+ this.onerror?.(error);
96
+ });
97
+ this._process.stdout?.on('data', chunk => {
98
+ this._readBuffer.append(chunk);
99
+ this.processReadBuffer();
100
+ });
101
+ this._process.stdout?.on('error', error => {
102
+ this.onerror?.(error);
103
+ });
104
+ if (this._stderrStream && this._process.stderr) {
105
+ this._process.stderr.pipe(this._stderrStream);
106
+ }
107
+ });
108
+ }
109
+ /**
110
+ * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
111
+ *
112
+ * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to
113
+ * attach listeners before the start method is invoked. This prevents loss of any early
114
+ * error output emitted by the child process.
115
+ */
116
+ get stderr() {
117
+ if (this._stderrStream) {
118
+ return this._stderrStream;
119
+ }
120
+ return this._process?.stderr ?? null;
121
+ }
122
+ /**
123
+ * The child process pid spawned by this transport.
124
+ *
125
+ * This is only available after the transport has been started.
126
+ */
127
+ get pid() {
128
+ return this._process?.pid ?? null;
129
+ }
130
+ processReadBuffer() {
131
+ while (true) {
132
+ try {
133
+ const message = this._readBuffer.readMessage();
134
+ if (message === null) {
135
+ break;
136
+ }
137
+ this.onmessage?.(message);
138
+ }
139
+ catch (error) {
140
+ this.onerror?.(error);
141
+ }
142
+ }
143
+ }
144
+ async close() {
145
+ if (this._process) {
146
+ const processToClose = this._process;
147
+ this._process = undefined;
148
+ const closePromise = new Promise(resolve => {
149
+ processToClose.once('close', () => {
150
+ resolve();
151
+ });
152
+ });
153
+ try {
154
+ processToClose.stdin?.end();
155
+ }
156
+ catch {
157
+ // ignore
158
+ }
159
+ await Promise.race([closePromise, new Promise(resolve => setTimeout(resolve, 2000).unref())]);
160
+ if (processToClose.exitCode === null) {
161
+ try {
162
+ processToClose.kill('SIGTERM');
163
+ }
164
+ catch {
165
+ // ignore
166
+ }
167
+ await Promise.race([closePromise, new Promise(resolve => setTimeout(resolve, 2000).unref())]);
168
+ }
169
+ if (processToClose.exitCode === null) {
170
+ try {
171
+ processToClose.kill('SIGKILL');
172
+ }
173
+ catch {
174
+ // ignore
175
+ }
176
+ }
177
+ }
178
+ this._readBuffer.clear();
179
+ }
180
+ send(message) {
181
+ return new Promise(resolve => {
182
+ if (!this._process?.stdin) {
183
+ throw new Error('Not connected');
184
+ }
185
+ const json = (0, stdio_js_1.serializeMessage)(message);
186
+ if (this._process.stdin.write(json)) {
187
+ resolve();
188
+ }
189
+ else {
190
+ this._process.stdin.once('drain', resolve);
191
+ }
192
+ });
193
+ }
194
+ }
195
+ exports.StdioClientTransport = StdioClientTransport;
196
+ //# sourceMappingURL=stdio.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../../src/client/stdio.ts"],"names":[],"mappings":";;;;;;AAkEA,sDAkBC;AAnFD,8DAAgC;AAChC,gEAAmC;AACnC,6CAAkD;AAClD,iDAAkE;AAqClE;;GAEG;AACU,QAAA,0BAA0B,GACnC,sBAAO,CAAC,QAAQ,KAAK,OAAO;IACxB,CAAC,CAAC;QACI,SAAS;QACT,WAAW;QACX,UAAU;QACV,cAAc;QACd,MAAM;QACN,wBAAwB;QACxB,aAAa;QACb,YAAY;QACZ,MAAM;QACN,UAAU;QACV,aAAa;QACb,cAAc;KACjB;IACH,CAAC,CAAC,0DAA0D;QAC1D,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/D;;GAEG;AACH,SAAg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;YACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClC,OAAO,EAAE,CAAC;YACd,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAvKD,oDAuKC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Transport, FetchLike } from '../shared/transport.js';
2
+ import { JSONRPCMessage } from '../types.js';
3
+ import { OAuthClientProvider } from './auth.js';
4
+ export declare class StreamableHTTPError extends Error {
5
+ readonly code: number | undefined;
6
+ constructor(code: number | undefined, message: string | undefined);
7
+ }
8
+ /**
9
+ * Options for starting or authenticating an SSE connection
10
+ */
11
+ export interface StartSSEOptions {
12
+ /**
13
+ * The resumption token used to continue long-running requests that were interrupted.
14
+ *
15
+ * This allows clients to reconnect and continue from where they left off.
16
+ */
17
+ resumptionToken?: string;
18
+ /**
19
+ * A callback that is invoked when the resumption token changes.
20
+ *
21
+ * This allows clients to persist the latest token for potential reconnection.
22
+ */
23
+ onresumptiontoken?: (token: string) => void;
24
+ /**
25
+ * Override Message ID to associate with the replay message
26
+ * so that response can be associate with the new resumed request.
27
+ */
28
+ replayMessageId?: string | number;
29
+ }
30
+ /**
31
+ * Configuration options for reconnection behavior of the StreamableHTTPClientTransport.
32
+ */
33
+ export interface StreamableHTTPReconnectionOptions {
34
+ /**
35
+ * Maximum backoff time between reconnection attempts in milliseconds.
36
+ * Default is 30000 (30 seconds).
37
+ */
38
+ maxReconnectionDelay: number;
39
+ /**
40
+ * Initial backoff time between reconnection attempts in milliseconds.
41
+ * Default is 1000 (1 second).
42
+ */
43
+ initialReconnectionDelay: number;
44
+ /**
45
+ * The factor by which the reconnection delay increases after each attempt.
46
+ * Default is 1.5.
47
+ */
48
+ reconnectionDelayGrowFactor: number;
49
+ /**
50
+ * Maximum number of reconnection attempts before giving up.
51
+ * Default is 2.
52
+ */
53
+ maxRetries: number;
54
+ }
55
+ /**
56
+ * Configuration options for the `StreamableHTTPClientTransport`.
57
+ */
58
+ export type StreamableHTTPClientTransportOptions = {
59
+ /**
60
+ * An OAuth client provider to use for authentication.
61
+ *
62
+ * When an `authProvider` is specified and the connection is started:
63
+ * 1. The connection is attempted with any existing access token from the `authProvider`.
64
+ * 2. If the access token has expired, the `authProvider` is used to refresh the token.
65
+ * 3. If token refresh fails or no access token exists, and auth is required, `OAuthClientProvider.redirectToAuthorization` is called, and an `UnauthorizedError` will be thrown from `connect`/`start`.
66
+ *
67
+ * After the user has finished authorizing via their user agent, and is redirected back to the MCP client application, call `StreamableHTTPClientTransport.finishAuth` with the authorization code before retrying the connection.
68
+ *
69
+ * If an `authProvider` is not provided, and auth is required, an `UnauthorizedError` will be thrown.
70
+ *
71
+ * `UnauthorizedError` might also be thrown when sending any message over the transport, indicating that the session has expired, and needs to be re-authed and reconnected.
72
+ */
73
+ authProvider?: OAuthClientProvider;
74
+ /**
75
+ * Customizes HTTP requests to the server.
76
+ */
77
+ requestInit?: RequestInit;
78
+ /**
79
+ * Custom fetch implementation used for all network requests.
80
+ */
81
+ fetch?: FetchLike;
82
+ /**
83
+ * Options to configure the reconnection behavior.
84
+ */
85
+ reconnectionOptions?: StreamableHTTPReconnectionOptions;
86
+ /**
87
+ * Session ID for the connection. This is used to identify the session on the server.
88
+ * When not provided and connecting to a server that supports session IDs, the server will generate a new session ID.
89
+ */
90
+ sessionId?: string;
91
+ };
92
+ /**
93
+ * Client transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.
94
+ * It will connect to a server using HTTP POST for sending messages and HTTP GET with Server-Sent Events
95
+ * for receiving messages.
96
+ */
97
+ export declare class StreamableHTTPClientTransport implements Transport {
98
+ private _abortController?;
99
+ private _url;
100
+ private _resourceMetadataUrl?;
101
+ private _scope?;
102
+ private _requestInit?;
103
+ private _authProvider?;
104
+ private _fetch?;
105
+ private _fetchWithInit;
106
+ private _sessionId?;
107
+ private _reconnectionOptions;
108
+ private _protocolVersion?;
109
+ private _hasCompletedAuthFlow;
110
+ private _lastUpscopingHeader?;
111
+ private _serverRetryMs?;
112
+ private _reconnectionTimeout?;
113
+ onclose?: () => void;
114
+ onerror?: (error: Error) => void;
115
+ onmessage?: (message: JSONRPCMessage) => void;
116
+ constructor(url: URL, opts?: StreamableHTTPClientTransportOptions);
117
+ private _authThenStart;
118
+ private _commonHeaders;
119
+ private _startOrAuthSse;
120
+ /**
121
+ * Calculates the next reconnection delay using backoff algorithm
122
+ *
123
+ * @param attempt Current reconnection attempt count for the specific stream
124
+ * @returns Time to wait in milliseconds before next reconnection attempt
125
+ */
126
+ private _getNextReconnectionDelay;
127
+ /**
128
+ * Schedule a reconnection attempt using server-provided retry interval or backoff
129
+ *
130
+ * @param lastEventId The ID of the last received event for resumability
131
+ * @param attemptCount Current reconnection attempt count for this specific stream
132
+ */
133
+ private _scheduleReconnection;
134
+ private _handleSseStream;
135
+ start(): Promise<void>;
136
+ /**
137
+ * Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
138
+ */
139
+ finishAuth(authorizationCode: string): Promise<void>;
140
+ close(): Promise<void>;
141
+ send(message: JSONRPCMessage | JSONRPCMessage[], options?: {
142
+ resumptionToken?: string;
143
+ onresumptiontoken?: (token: string) => void;
144
+ }): Promise<void>;
145
+ get sessionId(): string | undefined;
146
+ /**
147
+ * Terminates the current session by sending a DELETE request to the server.
148
+ *
149
+ * Clients that no longer need a particular session
150
+ * (e.g., because the user is leaving the client application) SHOULD send an
151
+ * HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly
152
+ * terminate the session.
153
+ *
154
+ * The server MAY respond with HTTP 405 Method Not Allowed, indicating that
155
+ * the server does not allow clients to terminate sessions.
156
+ */
157
+ terminateSession(): Promise<void>;
158
+ setProtocolVersion(version: string): void;
159
+ get protocolVersion(): string | undefined;
160
+ /**
161
+ * Resume an SSE stream from a previous event ID.
162
+ * Opens a GET SSE connection with Last-Event-ID header to replay missed events.
163
+ *
164
+ * @param lastEventId The event ID to resume from
165
+ * @param options Optional callback to receive new resumption tokens
166
+ */
167
+ resumeStream(lastEventId: string, options?: {
168
+ onresumptiontoken?: (token: string) => void;
169
+ }): Promise<void>;
170
+ }
171
+ //# sourceMappingURL=streamableHttp.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"streamableHttp.d.ts","sourceRoot":"","sources":["../../../src/client/streamableHttp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAyC,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAwE,cAAc,EAAwB,MAAM,aAAa,CAAC;AACzI,OAAO,EAAkD,mBAAmB,EAAqB,MAAM,WAAW,CAAC;AAWnH,qBAAa,mBAAoB,SAAQ,KAAK;aAEtB,IAAI,EAAE,MAAM,GAAG,SAAS;gBAAxB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxC,O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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamableHTTPClientTransport = exports.StreamableHTTPError = void 0;
4
+ const transport_js_1 = require("../shared/transport.js");
5
+ const types_js_1 = require("../types.js");
6
+ const auth_js_1 = require("./auth.js");
7
+ const stream_1 = require("eventsource-parser/stream");
8
+ // Default reconnection options for StreamableHTTP connections
9
+ const DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
10
+ initialReconnectionDelay: 1000,
11
+ maxReconnectionDelay: 30000,
12
+ reconnectionDelayGrowFactor: 1.5,
13
+ maxRetries: 2
14
+ };
15
+ class StreamableHTTPError extends Error {
16
+ constructor(code, message) {
17
+ super(`Streamable HTTP error: ${message}`);
18
+ this.code = code;
19
+ }
20
+ }
21
+ exports.StreamableHTTPError = StreamableHTTPError;
22
+ /**
23
+ * Client transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.
24
+ * It will connect to a server using HTTP POST for sending messages and HTTP GET with Server-Sent Events
25
+ * for receiving messages.
26
+ */
27
+ class StreamableHTTPClientTransport {
28
+ constructor(url, opts) {
29
+ this._hasCompletedAuthFlow = false; // Circuit breaker: detect auth success followed by immediate 401
30
+ this._url = url;
31
+ this._resourceMetadataUrl = undefined;
32
+ this._scope = undefined;
33
+ this._requestInit = opts?.requestInit;
34
+ this._authProvider = opts?.authProvider;
35
+ this._fetch = opts?.fetch;
36
+ this._fetchWithInit = (0, transport_js_1.createFetchWithInit)(opts?.fetch, opts?.requestInit);
37
+ this._sessionId = opts?.sessionId;
38
+ this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
39
+ }
40
+ async _authThenStart() {
41
+ if (!this._authProvider) {
42
+ throw new auth_js_1.UnauthorizedError('No auth provider');
43
+ }
44
+ let result;
45
+ try {
46
+ result = await (0, auth_js_1.auth)(this._authProvider, {
47
+ serverUrl: this._url,
48
+ resourceMetadataUrl: this._resourceMetadataUrl,
49
+ scope: this._scope,
50
+ fetchFn: this._fetchWithInit
51
+ });
52
+ }
53
+ catch (error) {
54
+ this.onerror?.(error);
55
+ throw error;
56
+ }
57
+ if (result !== 'AUTHORIZED') {
58
+ throw new auth_js_1.UnauthorizedError();
59
+ }
60
+ return await this._startOrAuthSse({ resumptionToken: undefined });
61
+ }
62
+ async _commonHeaders() {
63
+ const headers = {};
64
+ if (this._authProvider) {
65
+ const tokens = await this._authProvider.tokens();
66
+ if (tokens) {
67
+ headers['Authorization'] = `Bearer ${tokens.access_token}`;
68
+ }
69
+ }
70
+ if (this._sessionId) {
71
+ headers['mcp-session-id'] = this._sessionId;
72
+ }
73
+ if (this._protocolVersion) {
74
+ headers['mcp-protocol-version'] = this._protocolVersion;
75
+ }
76
+ const extraHeaders = (0, transport_js_1.normalizeHeaders)(this._requestInit?.headers);
77
+ return new Headers({
78
+ ...headers,
79
+ ...extraHeaders
80
+ });
81
+ }
82
+ async _startOrAuthSse(options) {
83
+ const { resumptionToken } = options;
84
+ try {
85
+ // Try to open an initial SSE stream with GET to listen for server messages
86
+ // This is optional according to the spec - server may not support it
87
+ const headers = await this._commonHeaders();
88
+ headers.set('Accept', 'text/event-stream');
89
+ // Include Last-Event-ID header for resumable streams if provided
90
+ if (resumptionToken) {
91
+ headers.set('last-event-id', resumptionToken);
92
+ }
93
+ const response = await (this._fetch ?? fetch)(this._url, {
94
+ method: 'GET',
95
+ headers,
96
+ signal: this._abortController?.signal
97
+ });
98
+ if (!response.ok) {
99
+ await response.body?.cancel();
100
+ if (response.status === 401 && this._authProvider) {
101
+ // Need to authenticate
102
+ return await this._authThenStart();
103
+ }
104
+ // 405 indicates that the server does not offer an SSE stream at GET endpoint
105
+ // This is an expected case that should not trigger an error
106
+ if (response.status === 405) {
107
+ return;
108
+ }
109
+ throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
110
+ }
111
+ this._handleSseStream(response.body, options, true);
112
+ }
113
+ catch (error) {
114
+ this.onerror?.(error);
115
+ throw error;
116
+ }
117
+ }
118
+ /**
119
+ * Calculates the next reconnection delay using backoff algorithm
120
+ *
121
+ * @param attempt Current reconnection attempt count for the specific stream
122
+ * @returns Time to wait in milliseconds before next reconnection attempt
123
+ */
124
+ _getNextReconnectionDelay(attempt) {
125
+ // Use server-provided retry value if available
126
+ if (this._serverRetryMs !== undefined) {
127
+ return this._serverRetryMs;
128
+ }
129
+ // Fall back to exponential backoff
130
+ const initialDelay = this._reconnectionOptions.initialReconnectionDelay;
131
+ const growFactor = this._reconnectionOptions.reconnectionDelayGrowFactor;
132
+ const maxDelay = this._reconnectionOptions.maxReconnectionDelay;
133
+ // Cap at maximum delay
134
+ return Math.min(initialDelay * Math.pow(growFactor, attempt), maxDelay);
135
+ }
136
+ /**
137
+ * Schedule a reconnection attempt using server-provided retry interval or backoff
138
+ *
139
+ * @param lastEventId The ID of the last received event for resumability
140
+ * @param attemptCount Current reconnection attempt count for this specific stream
141
+ */
142
+ _scheduleReconnection(options, attemptCount = 0) {
143
+ // Use provided options or default options
144
+ const maxRetries = this._reconnectionOptions.maxRetries;
145
+ // Check if we've exceeded maximum retry attempts
146
+ if (attemptCount >= maxRetries) {
147
+ this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
148
+ return;
149
+ }
150
+ // Calculate next delay based on current attempt count
151
+ const delay = this._getNextReconnectionDelay(attemptCount);
152
+ // Schedule the reconnection
153
+ this._reconnectionTimeout = setTimeout(() => {
154
+ // Use the last event ID to resume where we left off
155
+ this._startOrAuthSse(options).catch(error => {
156
+ this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
157
+ // Schedule another attempt if this one failed, incrementing the attempt counter
158
+ this._scheduleReconnection(options, attemptCount + 1);
159
+ });
160
+ }, delay);
161
+ }
162
+ _handleSseStream(stream, options, isReconnectable) {
163
+ if (!stream) {
164
+ return;
165
+ }
166
+ const { onresumptiontoken, replayMessageId } = options;
167
+ let lastEventId;
168
+ // Track whether we've received a priming event (event with ID)
169
+ // Per spec, server SHOULD send a priming event with ID before closing
170
+ let hasPrimingEvent = false;
171
+ // Track whether we've received a response - if so, no need to reconnect
172
+ // Reconnection is for when server disconnects BEFORE sending response
173
+ let receivedResponse = false;
174
+ const processStream = async () => {
175
+ // this is the closest we can get to trying to catch network errors
176
+ // if something happens reader will throw
177
+ try {
178
+ // Create a pipeline: binary stream -> text decoder -> SSE parser
179
+ const reader = stream
180
+ .pipeThrough(new TextDecoderStream())
181
+ .pipeThrough(new stream_1.EventSourceParserStream({
182
+ onRetry: (retryMs) => {
183
+ // Capture server-provided retry value for reconnection timing
184
+ this._serverRetryMs = retryMs;
185
+ }
186
+ }))
187
+ .getReader();
188
+ while (true) {
189
+ const { value: event, done } = await reader.read();
190
+ if (done) {
191
+ break;
192
+ }
193
+ // Update last event ID if provided
194
+ if (event.id) {
195
+ lastEventId = event.id;
196
+ // Mark that we've received a priming event - stream is now resumable
197
+ hasPrimingEvent = true;
198
+ onresumptiontoken?.(event.id);
199
+ }
200
+ // Skip events with no data (priming events, keep-alives)
201
+ if (!event.data) {
202
+ continue;
203
+ }
204
+ if (!event.event || event.event === 'message') {
205
+ try {
206
+ const message = types_js_1.JSONRPCMessageSchema.parse(JSON.parse(event.data));
207
+ if ((0, types_js_1.isJSONRPCResultResponse)(message)) {
208
+ // Mark that we received a response - no need to reconnect for this request
209
+ receivedResponse = true;
210
+ if (replayMessageId !== undefined) {
211
+ message.id = replayMessageId;
212
+ }
213
+ }
214
+ this.onmessage?.(message);
215
+ }
216
+ catch (error) {
217
+ this.onerror?.(error);
218
+ }
219
+ }
220
+ }
221
+ // Handle graceful server-side disconnect
222
+ // Server may close connection after sending event ID and retry field
223
+ // Reconnect if: already reconnectable (GET stream) OR received a priming event (POST stream with event ID)
224
+ // BUT don't reconnect if we already received a response - the request is complete
225
+ const canResume = isReconnectable || hasPrimingEvent;
226
+ const needsReconnect = canResume && !receivedResponse;
227
+ if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
228
+ this._scheduleReconnection({
229
+ resumptionToken: lastEventId,
230
+ onresumptiontoken,
231
+ replayMessageId
232
+ }, 0);
233
+ }
234
+ }
235
+ catch (error) {
236
+ // Handle stream errors - likely a network disconnect
237
+ this.onerror?.(new Error(`SSE stream disconnected: ${error}`));
238
+ // Attempt to reconnect if the stream disconnects unexpectedly and we aren't closing
239
+ // Reconnect if: already reconnectable (GET stream) OR received a priming event (POST stream with event ID)
240
+ // BUT don't reconnect if we already received a response - the request is complete
241
+ const canResume = isReconnectable || hasPrimingEvent;
242
+ const needsReconnect = canResume && !receivedResponse;
243
+ if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
244
+ // Use the exponential backoff reconnection strategy
245
+ try {
246
+ this._scheduleReconnection({
247
+ resumptionToken: lastEventId,
248
+ onresumptiontoken,
249
+ replayMessageId
250
+ }, 0);
251
+ }
252
+ catch (error) {
253
+ this.onerror?.(new Error(`Failed to reconnect: ${error instanceof Error ? error.message : String(error)}`));
254
+ }
255
+ }
256
+ }
257
+ };
258
+ processStream();
259
+ }
260
+ async start() {
261
+ if (this._abortController) {
262
+ throw new Error('StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.');
263
+ }
264
+ this._abortController = new AbortController();
265
+ }
266
+ /**
267
+ * Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
268
+ */
269
+ async finishAuth(authorizationCode) {
270
+ if (!this._authProvider) {
271
+ throw new auth_js_1.UnauthorizedError('No auth provider');
272
+ }
273
+ const result = await (0, auth_js_1.auth)(this._authProvider, {
274
+ serverUrl: this._url,
275
+ authorizationCode,
276
+ resourceMetadataUrl: this._resourceMetadataUrl,
277
+ scope: this._scope,
278
+ fetchFn: this._fetchWithInit
279
+ });
280
+ if (result !== 'AUTHORIZED') {
281
+ throw new auth_js_1.UnauthorizedError('Failed to authorize');
282
+ }
283
+ }
284
+ async close() {
285
+ if (this._reconnectionTimeout) {
286
+ clearTimeout(this._reconnectionTimeout);
287
+ this._reconnectionTimeout = undefined;
288
+ }
289
+ this._abortController?.abort();
290
+ this.onclose?.();
291
+ }
292
+ async send(message, options) {
293
+ try {
294
+ const { resumptionToken, onresumptiontoken } = options || {};
295
+ if (resumptionToken) {
296
+ // If we have at last event ID, we need to reconnect the SSE stream
297
+ this._startOrAuthSse({ resumptionToken, replayMessageId: (0, types_js_1.isJSONRPCRequest)(message) ? message.id : undefined }).catch(err => this.onerror?.(err));
298
+ return;
299
+ }
300
+ const headers = await this._commonHeaders();
301
+ headers.set('content-type', 'application/json');
302
+ headers.set('accept', 'application/json, text/event-stream');
303
+ const init = {
304
+ ...this._requestInit,
305
+ method: 'POST',
306
+ headers,
307
+ body: JSON.stringify(message),
308
+ signal: this._abortController?.signal
309
+ };
310
+ const response = await (this._fetch ?? fetch)(this._url, init);
311
+ // Handle session ID received during initialization
312
+ const sessionId = response.headers.get('mcp-session-id');
313
+ if (sessionId) {
314
+ this._sessionId = sessionId;
315
+ }
316
+ if (!response.ok) {
317
+ const text = await response.text().catch(() => null);
318
+ if (response.status === 401 && this._authProvider) {
319
+ // Prevent infinite recursion when server returns 401 after successful auth
320
+ if (this._hasCompletedAuthFlow) {
321
+ throw new StreamableHTTPError(401, 'Server returned 401 after successful authentication');
322
+ }
323
+ const { resourceMetadataUrl, scope } = (0, auth_js_1.extractWWWAuthenticateParams)(response);
324
+ this._resourceMetadataUrl = resourceMetadataUrl;
325
+ this._scope = scope;
326
+ const result = await (0, auth_js_1.auth)(this._authProvider, {
327
+ serverUrl: this._url,
328
+ resourceMetadataUrl: this._resourceMetadataUrl,
329
+ scope: this._scope,
330
+ fetchFn: this._fetchWithInit
331
+ });
332
+ if (result !== 'AUTHORIZED') {
333
+ throw new auth_js_1.UnauthorizedError();
334
+ }
335
+ // Mark that we completed auth flow
336
+ this._hasCompletedAuthFlow = true;
337
+ // Purposely _not_ awaited, so we don't call onerror twice
338
+ return this.send(message);
339
+ }
340
+ if (response.status === 403 && this._authProvider) {
341
+ const { resourceMetadataUrl, scope, error } = (0, auth_js_1.extractWWWAuthenticateParams)(response);
342
+ if (error === 'insufficient_scope') {
343
+ const wwwAuthHeader = response.headers.get('WWW-Authenticate');
344
+ // Check if we've already tried upscoping with this header to prevent infinite loops.
345
+ if (this._lastUpscopingHeader === wwwAuthHeader) {
346
+ throw new StreamableHTTPError(403, 'Server returned 403 after trying upscoping');
347
+ }
348
+ if (scope) {
349
+ this._scope = scope;
350
+ }
351
+ if (resourceMetadataUrl) {
352
+ this._resourceMetadataUrl = resourceMetadataUrl;
353
+ }
354
+ // Mark that upscoping was tried.
355
+ this._lastUpscopingHeader = wwwAuthHeader ?? undefined;
356
+ const result = await (0, auth_js_1.auth)(this._authProvider, {
357
+ serverUrl: this._url,
358
+ resourceMetadataUrl: this._resourceMetadataUrl,
359
+ scope: this._scope,
360
+ fetchFn: this._fetch
361
+ });
362
+ if (result !== 'AUTHORIZED') {
363
+ throw new auth_js_1.UnauthorizedError();
364
+ }
365
+ return this.send(message);
366
+ }
367
+ }
368
+ throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
369
+ }
370
+ // Reset auth loop flag on successful response
371
+ this._hasCompletedAuthFlow = false;
372
+ this._lastUpscopingHeader = undefined;
373
+ // If the response is 202 Accepted, there's no body to process
374
+ if (response.status === 202) {
375
+ await response.body?.cancel();
376
+ // if the accepted notification is initialized, we start the SSE stream
377
+ // if it's supported by the server
378
+ if ((0, types_js_1.isInitializedNotification)(message)) {
379
+ // Start without a lastEventId since this is a fresh connection
380
+ this._startOrAuthSse({ resumptionToken: undefined }).catch(err => this.onerror?.(err));
381
+ }
382
+ return;
383
+ }
384
+ // Get original message(s) for detecting request IDs
385
+ const messages = Array.isArray(message) ? message : [message];
386
+ const hasRequests = messages.filter(msg => 'method' in msg && 'id' in msg && msg.id !== undefined).length > 0;
387
+ // Check the response type
388
+ const contentType = response.headers.get('content-type');
389
+ if (hasRequests) {
390
+ if (contentType?.includes('text/event-stream')) {
391
+ // Handle SSE stream responses for requests
392
+ // We use the same handler as standalone streams, which now supports
393
+ // reconnection with the last event ID
394
+ this._handleSseStream(response.body, { onresumptiontoken }, false);
395
+ }
396
+ else if (contentType?.includes('application/json')) {
397
+ // For non-streaming servers, we might get direct JSON responses
398
+ const data = await response.json();
399
+ const responseMessages = Array.isArray(data)
400
+ ? data.map(msg => types_js_1.JSONRPCMessageSchema.parse(msg))
401
+ : [types_js_1.JSONRPCMessageSchema.parse(data)];
402
+ for (const msg of responseMessages) {
403
+ this.onmessage?.(msg);
404
+ }
405
+ }
406
+ else {
407
+ await response.body?.cancel();
408
+ throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
409
+ }
410
+ }
411
+ else {
412
+ // No requests in message but got 200 OK - still need to release connection
413
+ await response.body?.cancel();
414
+ }
415
+ }
416
+ catch (error) {
417
+ this.onerror?.(error);
418
+ throw error;
419
+ }
420
+ }
421
+ get sessionId() {
422
+ return this._sessionId;
423
+ }
424
+ /**
425
+ * Terminates the current session by sending a DELETE request to the server.
426
+ *
427
+ * Clients that no longer need a particular session
428
+ * (e.g., because the user is leaving the client application) SHOULD send an
429
+ * HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly
430
+ * terminate the session.
431
+ *
432
+ * The server MAY respond with HTTP 405 Method Not Allowed, indicating that
433
+ * the server does not allow clients to terminate sessions.
434
+ */
435
+ async terminateSession() {
436
+ if (!this._sessionId) {
437
+ return; // No session to terminate
438
+ }
439
+ try {
440
+ const headers = await this._commonHeaders();
441
+ const init = {
442
+ ...this._requestInit,
443
+ method: 'DELETE',
444
+ headers,
445
+ signal: this._abortController?.signal
446
+ };
447
+ const response = await (this._fetch ?? fetch)(this._url, init);
448
+ await response.body?.cancel();
449
+ // We specifically handle 405 as a valid response according to the spec,
450
+ // meaning the server does not support explicit session termination
451
+ if (!response.ok && response.status !== 405) {
452
+ throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
453
+ }
454
+ this._sessionId = undefined;
455
+ }
456
+ catch (error) {
457
+ this.onerror?.(error);
458
+ throw error;
459
+ }
460
+ }
461
+ setProtocolVersion(version) {
462
+ this._protocolVersion = version;
463
+ }
464
+ get protocolVersion() {
465
+ return this._protocolVersion;
466
+ }
467
+ /**
468
+ * Resume an SSE stream from a previous event ID.
469
+ * Opens a GET SSE connection with Last-Event-ID header to replay missed events.
470
+ *
471
+ * @param lastEventId The event ID to resume from
472
+ * @param options Optional callback to receive new resumption tokens
473
+ */
474
+ async resumeStream(lastEventId, options) {
475
+ await this._startOrAuthSse({
476
+ resumptionToken: lastEventId,
477
+ onresumptiontoken: options?.onresumptiontoken
478
+ });
479
+ }
480
+ }
481
+ exports.StreamableHTTPClientTransport = StreamableHTTPClientTransport;
482
+ //# sourceMappingURL=streamableHttp.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"streamableHttp.js","sourceRoot":"","sources":["../../../src/client/streamableHttp.ts"],"names":[],"mappings":";;;AAAA,yDAAqG;AACrG,0CAAyI;AACzI,uCAAmH;AACnH,sDAAoE;AAEpE,8DAA8D;AAC9D,MAAM,4CAA4C,GAAsC;IACpF,wBAAwB,EAAE,IAAI;IAC9B,oBAAoB,EAAE,KAAK;IAC3B,2BAA2B,EAAE,GAAG;IAChC,UAAU,EAAE,CAAC;CAChB,CAAC;AAEF,MAAa,mBAAoB,SAAQ,KAAK;IAC1C,YACoB,IAAwB,EACxC,OAA2B;QAE3B,KAAK,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC;QAH3B,SAAI,GAAJ,IAAI,CAAoB;IAI5C,CAAC;CACJ;AAPD,kDAOC;AAk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AAC,CAAC;IACP,CAAC;CACJ;AAtiBD,sEAsiBC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.d.ts ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Transport } from '../shared/transport.js';
2
+ import { JSONRPCMessage } from '../types.js';
3
+ /**
4
+ * Client transport for WebSocket: this will connect to a server over the WebSocket protocol.
5
+ */
6
+ export declare class WebSocketClientTransport implements Transport {
7
+ private _socket?;
8
+ private _url;
9
+ onclose?: () => void;
10
+ onerror?: (error: Error) => void;
11
+ onmessage?: (message: JSONRPCMessage) => void;
12
+ constructor(url: URL);
13
+ start(): Promise<void>;
14
+ close(): Promise<void>;
15
+ send(message: JSONRPCMessage): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=websocket.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../../src/client/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAInE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,SAAS;IACtD,OAAO,CAAC,OAAO,CAAC,CAAY;IAC5B,OAAO,CAAC,IAAI,CAAM;IAElB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;gBAElC,GAAG,EAAE,GAAG;IAIpB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsChB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAW/C"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.js ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebSocketClientTransport = void 0;
4
+ const types_js_1 = require("../types.js");
5
+ const SUBPROTOCOL = 'mcp';
6
+ /**
7
+ * Client transport for WebSocket: this will connect to a server over the WebSocket protocol.
8
+ */
9
+ class WebSocketClientTransport {
10
+ constructor(url) {
11
+ this._url = url;
12
+ }
13
+ start() {
14
+ if (this._socket) {
15
+ throw new Error('WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.');
16
+ }
17
+ return new Promise((resolve, reject) => {
18
+ this._socket = new WebSocket(this._url, SUBPROTOCOL);
19
+ this._socket.onerror = event => {
20
+ const error = 'error' in event ? event.error : new Error(`WebSocket error: ${JSON.stringify(event)}`);
21
+ reject(error);
22
+ this.onerror?.(error);
23
+ };
24
+ this._socket.onopen = () => {
25
+ resolve();
26
+ };
27
+ this._socket.onclose = () => {
28
+ this.onclose?.();
29
+ };
30
+ this._socket.onmessage = (event) => {
31
+ let message;
32
+ try {
33
+ message = types_js_1.JSONRPCMessageSchema.parse(JSON.parse(event.data));
34
+ }
35
+ catch (error) {
36
+ this.onerror?.(error);
37
+ return;
38
+ }
39
+ this.onmessage?.(message);
40
+ };
41
+ });
42
+ }
43
+ async close() {
44
+ this._socket?.close();
45
+ }
46
+ send(message) {
47
+ return new Promise((resolve, reject) => {
48
+ if (!this._socket) {
49
+ reject(new Error('Not connected'));
50
+ return;
51
+ }
52
+ this._socket?.send(JSON.stringify(message));
53
+ resolve();
54
+ });
55
+ }
56
+ }
57
+ exports.WebSocketClientTransport = WebSocketClientTransport;
58
+ //# sourceMappingURL=websocket.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/websocket.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/client/websocket.ts"],"names":[],"mappings":";;;AACA,0CAAmE;AAEnE,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B;;GAEG;AACH,MAAa,wBAAwB;IAQjC,YAAY,GAAQ;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,KAAK;QACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACX,mHAAmH,CACtH,CAAC;QACN,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,IAAI,CAAC,OAAO,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAErD,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE;gBAC3B,MAAM,KAAK,GAAG,OAAO,IAAI,KAAK,CAAC,CAAC,CAAE,KAAK,CAAC,KAAe,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACjH,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC,CAAC;YAEF,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;gBACvB,OAAO,EAAE,CAAC;YACd,CAAC,CAAC;YAEF,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE;gBACxB,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACrB,CAAC,CAAC;YAEF,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,KAAmB,EAAE,EAAE;gBAC7C,IAAI,OAAuB,CAAC;gBAC5B,IAAI,CAAC;oBACD,OAAO,GAAG,+BAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBACjE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,IAAI,CAAC,OAAO,EAAE,CAAC,KAAc,CAAC,CAAC;oBAC/B,OAAO;gBACX,CAAC;gBAED,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;YAC9B,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,OAAuB;QACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAChB,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;gBACnC,OAAO;YACX,CAAC;YAED,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5C,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAjED,4DAiEC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/elicitationUrlExample.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export {};
2
+ //# sourceMappingURL=elicitationUrlExample.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/elicitationUrlExample.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"elicitationUrlExample.d.ts","sourceRoot":"","sources":["../../../../src/examples/client/el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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ // Run with: npx tsx src/examples/client/elicitationUrlExample.ts
3
+ //
4
+ // This example demonstrates how to use URL elicitation to securely
5
+ // collect user input in a remote (HTTP) server.
6
+ // URL elicitation allows servers to prompt the end-user to open a URL in their browser
7
+ // to collect sensitive information.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const index_js_1 = require("../../client/index.js");
10
+ const streamableHttp_js_1 = require("../../client/streamableHttp.js");
11
+ const node_readline_1 = require("node:readline");
12
+ const types_js_1 = require("../../types.js");
13
+ const metadataUtils_js_1 = require("../../shared/metadataUtils.js");
14
+ const simpleOAuthClientProvider_js_1 = require("./simpleOAuthClientProvider.js");
15
+ const auth_js_1 = require("../../client/auth.js");
16
+ const node_http_1 = require("node:http");
17
+ // Set up OAuth (required for this example)
18
+ const OAUTH_CALLBACK_PORT = 8090; // Use different port than auth server (3001)
19
+ const OAUTH_CALLBACK_URL = `http://localhost:${OAUTH_CALLBACK_PORT}/callback`;
20
+ let oauthProvider = undefined;
21
+ console.log('Getting OAuth token...');
22
+ const clientMetadata = {
23
+ client_name: 'Elicitation MCP Client',
24
+ redirect_uris: [OAUTH_CALLBACK_URL],
25
+ grant_types: ['authorization_code', 'refresh_token'],
26
+ response_types: ['code'],
27
+ token_endpoint_auth_method: 'client_secret_post',
28
+ scope: 'mcp:tools'
29
+ };
30
+ oauthProvider = new simpleOAuthClientProvider_js_1.InMemoryOAuthClientProvider(OAUTH_CALLBACK_URL, clientMetadata, (redirectUrl) => {
31
+ console.log(`\n🔗 Please open this URL in your browser to authorize:\n ${redirectUrl.toString()}`);
32
+ });
33
+ // Create readline interface for user input
34
+ const readline = (0, node_readline_1.createInterface)({
35
+ input: process.stdin,
36
+ output: process.stdout
37
+ });
38
+ let abortCommand = new AbortController();
39
+ // Global client and transport for interactive commands
40
+ let client = null;
41
+ let transport = null;
42
+ let serverUrl = 'http://localhost:3000/mcp';
43
+ let sessionId = undefined;
44
+ let isProcessingCommand = false;
45
+ let isProcessingElicitations = false;
46
+ const elicitationQueue = [];
47
+ let elicitationQueueSignal = null;
48
+ let elicitationsCompleteSignal = null;
49
+ // Map to track pending URL elicitations waiting for completion notifications
50
+ const pendingURLElicitations = new Map();
51
+ async function main() {
52
+ console.log('MCP Interactive Client');
53
+ console.log('=====================');
54
+ // Connect to server immediately with default settings
55
+ await connect();
56
+ // Start the elicitation loop in the background
57
+ elicitationLoop().catch(error => {
58
+ console.error('Unexpected error in elicitation loop:', error);
59
+ process.exit(1);
60
+ });
61
+ // Short delay allowing the server to send any SSE elicitations on connection
62
+ await new Promise(resolve => setTimeout(resolve, 200));
63
+ // Wait until we are done processing any initial elicitations
64
+ await waitForElicitationsToComplete();
65
+ // Print help and start the command loop
66
+ printHelp();
67
+ await commandLoop();
68
+ }
69
+ async function waitForElicitationsToComplete() {
70
+ // Wait until the queue is empty and nothing is being processed
71
+ while (elicitationQueue.length > 0 || isProcessingElicitations) {
72
+ await new Promise(resolve => setTimeout(resolve, 100));
73
+ }
74
+ }
75
+ function printHelp() {
76
+ console.log('\nAvailable commands:');
77
+ console.log(' connect [url] - Connect to MCP server (default: http://localhost:3000/mcp)');
78
+ console.log(' disconnect - Disconnect from server');
79
+ console.log(' terminate-session - Terminate the current session');
80
+ console.log(' reconnect - Reconnect to the server');
81
+ console.log(' list-tools - List available tools');
82
+ console.log(' call-tool <name> [args] - Call a tool with optional JSON arguments');
83
+ console.log(' payment-confirm - Test URL elicitation via error response with payment-confirm tool');
84
+ console.log(' third-party-auth - Test tool that requires third-party OAuth credentials');
85
+ console.log(' help - Show this help');
86
+ console.log(' quit - Exit the program');
87
+ }
88
+ async function commandLoop() {
89
+ await new Promise(resolve => {
90
+ if (!isProcessingElicitations) {
91
+ resolve();
92
+ }
93
+ else {
94
+ elicitationsCompleteSignal = resolve;
95
+ }
96
+ });
97
+ readline.question('\n> ', { signal: abortCommand.signal }, async (input) => {
98
+ isProcessingCommand = true;
99
+ const args = input.trim().split(/\s+/);
100
+ const command = args[0]?.toLowerCase();
101
+ try {
102
+ switch (command) {
103
+ case 'connect':
104
+ await connect(args[1]);
105
+ break;
106
+ case 'disconnect':
107
+ await disconnect();
108
+ break;
109
+ case 'terminate-session':
110
+ await terminateSession();
111
+ break;
112
+ case 'reconnect':
113
+ await reconnect();
114
+ break;
115
+ case 'list-tools':
116
+ await listTools();
117
+ break;
118
+ case 'call-tool':
119
+ if (args.length < 2) {
120
+ console.log('Usage: call-tool <name> [args]');
121
+ }
122
+ else {
123
+ const toolName = args[1];
124
+ let toolArgs = {};
125
+ if (args.length > 2) {
126
+ try {
127
+ toolArgs = JSON.parse(args.slice(2).join(' '));
128
+ }
129
+ catch {
130
+ console.log('Invalid JSON arguments. Using empty args.');
131
+ }
132
+ }
133
+ await callTool(toolName, toolArgs);
134
+ }
135
+ break;
136
+ case 'payment-confirm':
137
+ await callPaymentConfirmTool();
138
+ break;
139
+ case 'third-party-auth':
140
+ await callThirdPartyAuthTool();
141
+ break;
142
+ case 'help':
143
+ printHelp();
144
+ break;
145
+ case 'quit':
146
+ case 'exit':
147
+ await cleanup();
148
+ return;
149
+ default:
150
+ if (command) {
151
+ console.log(`Unknown command: ${command}`);
152
+ }
153
+ break;
154
+ }
155
+ }
156
+ catch (error) {
157
+ console.error(`Error executing command: ${error}`);
158
+ }
159
+ finally {
160
+ isProcessingCommand = false;
161
+ }
162
+ // Process another command after we've processed the this one
163
+ await commandLoop();
164
+ });
165
+ }
166
+ async function elicitationLoop() {
167
+ while (true) {
168
+ // Wait until we have elicitations to process
169
+ await new Promise(resolve => {
170
+ if (elicitationQueue.length > 0) {
171
+ resolve();
172
+ }
173
+ else {
174
+ elicitationQueueSignal = resolve;
175
+ }
176
+ });
177
+ isProcessingElicitations = true;
178
+ abortCommand.abort(); // Abort the command loop if it's running
179
+ // Process all queued elicitations
180
+ while (elicitationQueue.length > 0) {
181
+ const queued = elicitationQueue.shift();
182
+ console.log(`📤 Processing queued elicitation (${elicitationQueue.length} remaining)`);
183
+ try {
184
+ const result = await handleElicitationRequest(queued.request);
185
+ queued.resolve(result);
186
+ }
187
+ catch (error) {
188
+ queued.reject(error instanceof Error ? error : new Error(String(error)));
189
+ }
190
+ }
191
+ console.log('✅ All queued elicitations processed. Resuming command loop...\n');
192
+ isProcessingElicitations = false;
193
+ // Reset the abort controller for the next command loop
194
+ abortCommand = new AbortController();
195
+ // Resume the command loop
196
+ if (elicitationsCompleteSignal) {
197
+ elicitationsCompleteSignal();
198
+ elicitationsCompleteSignal = null;
199
+ }
200
+ }
201
+ }
202
+ /**
203
+ * Enqueues an elicitation request and returns the result.
204
+ *
205
+ * This function is used so that our CLI (which can only handle one input request at a time)
206
+ * can handle elicitation requests and the command loop.
207
+ *
208
+ * @param request - The elicitation request to be handled
209
+ * @returns The elicitation result
210
+ */
211
+ async function elicitationRequestHandler(request) {
212
+ // If we are processing a command, handle this elicitation immediately
213
+ if (isProcessingCommand) {
214
+ console.log('📋 Processing elicitation immediately (during command execution)');
215
+ return await handleElicitationRequest(request);
216
+ }
217
+ // Otherwise, queue the request to be handled by the elicitation loop
218
+ console.log(`📥 Queueing elicitation request (queue size will be: ${elicitationQueue.length + 1})`);
219
+ return new Promise((resolve, reject) => {
220
+ elicitationQueue.push({
221
+ request,
222
+ resolve,
223
+ reject
224
+ });
225
+ // Signal the elicitation loop that there's work to do
226
+ if (elicitationQueueSignal) {
227
+ elicitationQueueSignal();
228
+ elicitationQueueSignal = null;
229
+ }
230
+ });
231
+ }
232
+ /**
233
+ * Handles an elicitation request.
234
+ *
235
+ * This function is used to handle the elicitation request and return the result.
236
+ *
237
+ * @param request - The elicitation request to be handled
238
+ * @returns The elicitation result
239
+ */
240
+ async function handleElicitationRequest(request) {
241
+ const mode = request.params.mode;
242
+ console.log('\n🔔 Elicitation Request Received:');
243
+ console.log(`Mode: ${mode}`);
244
+ if (mode === 'url') {
245
+ return {
246
+ action: await handleURLElicitation(request.params)
247
+ };
248
+ }
249
+ else {
250
+ // Should not happen because the client declares its capabilities to the server,
251
+ // but being defensive is a good practice:
252
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Unsupported elicitation mode: ${mode}`);
253
+ }
254
+ }
255
+ /**
256
+ * Handles a URL elicitation by opening the URL in the browser.
257
+ *
258
+ * Note: This is a shared code for both request handlers and error handlers.
259
+ * As a result of sharing schema, there is no big forking of logic for the client.
260
+ *
261
+ * @param params - The URL elicitation request parameters
262
+ * @returns The action to take (accept, cancel, or decline)
263
+ */
264
+ async function handleURLElicitation(params) {
265
+ const url = params.url;
266
+ const elicitationId = params.elicitationId;
267
+ const message = params.message;
268
+ console.log(`🆔 Elicitation ID: ${elicitationId}`); // Print for illustration
269
+ // Parse URL to show domain for security
270
+ let domain = 'unknown domain';
271
+ try {
272
+ const parsedUrl = new URL(url);
273
+ domain = parsedUrl.hostname;
274
+ }
275
+ catch {
276
+ console.error('Invalid URL provided by server');
277
+ return 'decline';
278
+ }
279
+ // Example security warning to help prevent phishing attacks
280
+ console.log('\n⚠️ \x1b[33mSECURITY WARNING\x1b[0m ⚠️');
281
+ console.log('\x1b[33mThe server is requesting you to open an external URL.\x1b[0m');
282
+ console.log('\x1b[33mOnly proceed if you trust this server and understand why it needs this.\x1b[0m\n');
283
+ console.log(`🌐 Target domain: \x1b[36m${domain}\x1b[0m`);
284
+ console.log(`🔗 Full URL: \x1b[36m${url}\x1b[0m`);
285
+ console.log(`\nℹ️ Server's reason:\n\n\x1b[36m${message}\x1b[0m\n`);
286
+ // 1. Ask for user consent to open the URL
287
+ const consent = await new Promise(resolve => {
288
+ readline.question('\nDo you want to open this URL in your browser? (y/n): ', input => {
289
+ resolve(input.trim().toLowerCase());
290
+ });
291
+ });
292
+ // 2. If user did not consent, return appropriate result
293
+ if (consent === 'no' || consent === 'n') {
294
+ console.log('❌ URL navigation declined.');
295
+ return 'decline';
296
+ }
297
+ else if (consent !== 'yes' && consent !== 'y') {
298
+ console.log('🚫 Invalid response. Cancelling elicitation.');
299
+ return 'cancel';
300
+ }
301
+ // 3. Wait for completion notification in the background
302
+ const completionPromise = new Promise((resolve, reject) => {
303
+ const timeout = setTimeout(() => {
304
+ pendingURLElicitations.delete(elicitationId);
305
+ console.log(`\x1b[31m❌ Elicitation ${elicitationId} timed out waiting for completion.\x1b[0m`);
306
+ reject(new Error('Elicitation completion timeout'));
307
+ }, 5 * 60 * 1000); // 5 minute timeout
308
+ pendingURLElicitations.set(elicitationId, {
309
+ resolve: () => {
310
+ clearTimeout(timeout);
311
+ resolve();
312
+ },
313
+ reject,
314
+ timeout
315
+ });
316
+ });
317
+ completionPromise.catch(error => {
318
+ console.error('Background completion wait failed:', error);
319
+ });
320
+ // 4. Direct user to open the URL in their browser
321
+ console.log(`\n🔗 Please open this URL in your browser:\n ${url}`);
322
+ console.log('\n⏳ Waiting for you to complete the interaction in your browser...');
323
+ console.log(' The server will send a notification once you complete the action.');
324
+ // 5. Acknowledge the user accepted the elicitation
325
+ return 'accept';
326
+ }
327
+ /**
328
+ * Example OAuth callback handler - in production, use a more robust approach
329
+ * for handling callbacks and storing tokens
330
+ */
331
+ /**
332
+ * Starts a temporary HTTP server to receive the OAuth callback
333
+ */
334
+ async function waitForOAuthCallback() {
335
+ return new Promise((resolve, reject) => {
336
+ const server = (0, node_http_1.createServer)((req, res) => {
337
+ // Ignore favicon requests
338
+ if (req.url === '/favicon.ico') {
339
+ res.writeHead(404);
340
+ res.end();
341
+ return;
342
+ }
343
+ console.log(`📥 Received callback: ${req.url}`);
344
+ const parsedUrl = new URL(req.url || '', 'http://localhost');
345
+ const code = parsedUrl.searchParams.get('code');
346
+ const error = parsedUrl.searchParams.get('error');
347
+ if (code) {
348
+ console.log(`✅ Authorization code received: ${code?.substring(0, 10)}...`);
349
+ res.writeHead(200, { 'Content-Type': 'text/html' });
350
+ res.end(`
351
+ <html>
352
+ <body>
353
+ <h1>Authorization Successful!</h1>
354
+ <p>This simulates successful authorization of the MCP client, which now has an access token for the MCP server.</p>
355
+ <p>This window will close automatically in 10 seconds.</p>
356
+ <script>setTimeout(() => window.close(), 10000);</script>
357
+ </body>
358
+ </html>
359
+ `);
360
+ resolve(code);
361
+ setTimeout(() => server.close(), 15000);
362
+ }
363
+ else if (error) {
364
+ console.log(`❌ Authorization error: ${error}`);
365
+ res.writeHead(400, { 'Content-Type': 'text/html' });
366
+ res.end(`
367
+ <html>
368
+ <body>
369
+ <h1>Authorization Failed</h1>
370
+ <p>Error: ${error}</p>
371
+ </body>
372
+ </html>
373
+ `);
374
+ reject(new Error(`OAuth authorization failed: ${error}`));
375
+ }
376
+ else {
377
+ console.log(`❌ No authorization code or error in callback`);
378
+ res.writeHead(400);
379
+ res.end('Bad request');
380
+ reject(new Error('No authorization code provided'));
381
+ }
382
+ });
383
+ server.listen(OAUTH_CALLBACK_PORT, () => {
384
+ console.log(`OAuth callback server started on http://localhost:${OAUTH_CALLBACK_PORT}`);
385
+ });
386
+ });
387
+ }
388
+ /**
389
+ * Attempts to connect to the MCP server with OAuth authentication.
390
+ * Handles OAuth flow recursively if authorization is required.
391
+ */
392
+ async function attemptConnection(oauthProvider) {
393
+ console.log('🚢 Creating transport with OAuth provider...');
394
+ const baseUrl = new URL(serverUrl);
395
+ transport = new streamableHttp_js_1.StreamableHTTPClientTransport(baseUrl, {
396
+ sessionId: sessionId,
397
+ authProvider: oauthProvider
398
+ });
399
+ console.log('🚢 Transport created');
400
+ try {
401
+ console.log('🔌 Attempting connection (this will trigger OAuth redirect if needed)...');
402
+ await client.connect(transport);
403
+ sessionId = transport.sessionId;
404
+ console.log('Transport created with session ID:', sessionId);
405
+ console.log('✅ Connected successfully');
406
+ }
407
+ catch (error) {
408
+ if (error instanceof auth_js_1.UnauthorizedError) {
409
+ console.log('🔐 OAuth required - waiting for authorization...');
410
+ const callbackPromise = waitForOAuthCallback();
411
+ const authCode = await callbackPromise;
412
+ await transport.finishAuth(authCode);
413
+ console.log('🔐 Authorization code received:', authCode);
414
+ console.log('🔌 Reconnecting with authenticated transport...');
415
+ // Recursively retry connection after OAuth completion
416
+ await attemptConnection(oauthProvider);
417
+ }
418
+ else {
419
+ console.error('❌ Connection failed with non-auth error:', error);
420
+ throw error;
421
+ }
422
+ }
423
+ }
424
+ async function connect(url) {
425
+ if (client) {
426
+ console.log('Already connected. Disconnect first.');
427
+ return;
428
+ }
429
+ if (url) {
430
+ serverUrl = url;
431
+ }
432
+ console.log(`🔗 Attempting to connect to ${serverUrl}...`);
433
+ // Create a new client with elicitation capability
434
+ console.log('👤 Creating MCP client...');
435
+ client = new index_js_1.Client({
436
+ name: 'example-client',
437
+ version: '1.0.0'
438
+ }, {
439
+ capabilities: {
440
+ elicitation: {
441
+ // Only URL elicitation is supported in this demo
442
+ // (see server/elicitationExample.ts for a demo of form mode elicitation)
443
+ url: {}
444
+ }
445
+ }
446
+ });
447
+ console.log('👤 Client created');
448
+ // Set up elicitation request handler with proper validation
449
+ client.setRequestHandler(types_js_1.ElicitRequestSchema, elicitationRequestHandler);
450
+ // Set up notification handler for elicitation completion
451
+ client.setNotificationHandler(types_js_1.ElicitationCompleteNotificationSchema, notification => {
452
+ const { elicitationId } = notification.params;
453
+ const pending = pendingURLElicitations.get(elicitationId);
454
+ if (pending) {
455
+ clearTimeout(pending.timeout);
456
+ pendingURLElicitations.delete(elicitationId);
457
+ console.log(`\x1b[32m✅ Elicitation ${elicitationId} completed!\x1b[0m`);
458
+ pending.resolve();
459
+ }
460
+ else {
461
+ // Shouldn't happen - discard it!
462
+ console.warn(`Received completion notification for unknown elicitation: ${elicitationId}`);
463
+ }
464
+ });
465
+ try {
466
+ console.log('🔐 Starting OAuth flow...');
467
+ await attemptConnection(oauthProvider);
468
+ console.log('Connected to MCP server');
469
+ // Set up error handler after connection is established so we don't double log errors
470
+ client.onerror = error => {
471
+ console.error('\x1b[31mClient error:', error, '\x1b[0m');
472
+ };
473
+ }
474
+ catch (error) {
475
+ console.error('Failed to connect:', error);
476
+ client = null;
477
+ transport = null;
478
+ return;
479
+ }
480
+ }
481
+ async function disconnect() {
482
+ if (!client || !transport) {
483
+ console.log('Not connected.');
484
+ return;
485
+ }
486
+ try {
487
+ await transport.close();
488
+ console.log('Disconnected from MCP server');
489
+ client = null;
490
+ transport = null;
491
+ }
492
+ catch (error) {
493
+ console.error('Error disconnecting:', error);
494
+ }
495
+ }
496
+ async function terminateSession() {
497
+ if (!client || !transport) {
498
+ console.log('Not connected.');
499
+ return;
500
+ }
501
+ try {
502
+ console.log('Terminating session with ID:', transport.sessionId);
503
+ await transport.terminateSession();
504
+ console.log('Session terminated successfully');
505
+ // Check if sessionId was cleared after termination
506
+ if (!transport.sessionId) {
507
+ console.log('Session ID has been cleared');
508
+ sessionId = undefined;
509
+ // Also close the transport and clear client objects
510
+ await transport.close();
511
+ console.log('Transport closed after session termination');
512
+ client = null;
513
+ transport = null;
514
+ }
515
+ else {
516
+ console.log('Server responded with 405 Method Not Allowed (session termination not supported)');
517
+ console.log('Session ID is still active:', transport.sessionId);
518
+ }
519
+ }
520
+ catch (error) {
521
+ console.error('Error terminating session:', error);
522
+ }
523
+ }
524
+ async function reconnect() {
525
+ if (client) {
526
+ await disconnect();
527
+ }
528
+ await connect();
529
+ }
530
+ async function listTools() {
531
+ if (!client) {
532
+ console.log('Not connected to server.');
533
+ return;
534
+ }
535
+ try {
536
+ const toolsRequest = {
537
+ method: 'tools/list',
538
+ params: {}
539
+ };
540
+ const toolsResult = await client.request(toolsRequest, types_js_1.ListToolsResultSchema);
541
+ console.log('Available tools:');
542
+ if (toolsResult.tools.length === 0) {
543
+ console.log(' No tools available');
544
+ }
545
+ else {
546
+ for (const tool of toolsResult.tools) {
547
+ console.log(` - id: ${tool.name}, name: ${(0, metadataUtils_js_1.getDisplayName)(tool)}, description: ${tool.description}`);
548
+ }
549
+ }
550
+ }
551
+ catch (error) {
552
+ console.log(`Tools not supported by this server (${error})`);
553
+ }
554
+ }
555
+ async function callTool(name, args) {
556
+ if (!client) {
557
+ console.log('Not connected to server.');
558
+ return;
559
+ }
560
+ try {
561
+ const request = {
562
+ method: 'tools/call',
563
+ params: {
564
+ name,
565
+ arguments: args
566
+ }
567
+ };
568
+ console.log(`Calling tool '${name}' with args:`, args);
569
+ const result = await client.request(request, types_js_1.CallToolResultSchema);
570
+ console.log('Tool result:');
571
+ const resourceLinks = [];
572
+ result.content.forEach(item => {
573
+ if (item.type === 'text') {
574
+ console.log(` ${item.text}`);
575
+ }
576
+ else if (item.type === 'resource_link') {
577
+ const resourceLink = item;
578
+ resourceLinks.push(resourceLink);
579
+ console.log(` 📁 Resource Link: ${resourceLink.name}`);
580
+ console.log(` URI: ${resourceLink.uri}`);
581
+ if (resourceLink.mimeType) {
582
+ console.log(` Type: ${resourceLink.mimeType}`);
583
+ }
584
+ if (resourceLink.description) {
585
+ console.log(` Description: ${resourceLink.description}`);
586
+ }
587
+ }
588
+ else if (item.type === 'resource') {
589
+ console.log(` [Embedded Resource: ${item.resource.uri}]`);
590
+ }
591
+ else if (item.type === 'image') {
592
+ console.log(` [Image: ${item.mimeType}]`);
593
+ }
594
+ else if (item.type === 'audio') {
595
+ console.log(` [Audio: ${item.mimeType}]`);
596
+ }
597
+ else {
598
+ console.log(` [Unknown content type]:`, item);
599
+ }
600
+ });
601
+ // Offer to read resource links
602
+ if (resourceLinks.length > 0) {
603
+ console.log(`\nFound ${resourceLinks.length} resource link(s). Use 'read-resource <uri>' to read their content.`);
604
+ }
605
+ }
606
+ catch (error) {
607
+ if (error instanceof types_js_1.UrlElicitationRequiredError) {
608
+ console.log('\n🔔 Elicitation Required Error Received:');
609
+ console.log(`Message: ${error.message}`);
610
+ for (const e of error.elicitations) {
611
+ await handleURLElicitation(e); // For the error handler, we discard the action result because we don't respond to an error response
612
+ }
613
+ return;
614
+ }
615
+ console.log(`Error calling tool ${name}: ${error}`);
616
+ }
617
+ }
618
+ async function cleanup() {
619
+ if (client && transport) {
620
+ try {
621
+ // First try to terminate the session gracefully
622
+ if (transport.sessionId) {
623
+ try {
624
+ console.log('Terminating session before exit...');
625
+ await transport.terminateSession();
626
+ console.log('Session terminated successfully');
627
+ }
628
+ catch (error) {
629
+ console.error('Error terminating session:', error);
630
+ }
631
+ }
632
+ // Then close the transport
633
+ await transport.close();
634
+ }
635
+ catch (error) {
636
+ console.error('Error closing transport:', error);
637
+ }
638
+ }
639
+ process.stdin.setRawMode(false);
640
+ readline.close();
641
+ console.log('\nGoodbye!');
642
+ process.exit(0);
643
+ }
644
+ async function callPaymentConfirmTool() {
645
+ console.log('Calling payment-confirm tool...');
646
+ await callTool('payment-confirm', { cartId: 'cart_123' });
647
+ }
648
+ async function callThirdPartyAuthTool() {
649
+ console.log('Calling third-party-auth tool...');
650
+ await callTool('third-party-auth', { param1: 'test' });
651
+ }
652
+ // Set up raw mode for keyboard input to capture Escape key
653
+ process.stdin.setRawMode(true);
654
+ process.stdin.on('data', async (data) => {
655
+ // Check for Escape key (27)
656
+ if (data.length === 1 && data[0] === 27) {
657
+ console.log('\nESC key pressed. Disconnecting from server...');
658
+ // Abort current operation and disconnect from server
659
+ if (client && transport) {
660
+ await disconnect();
661
+ console.log('Disconnected. Press Enter to continue.');
662
+ }
663
+ else {
664
+ console.log('Not connected to server.');
665
+ }
666
+ // Re-display the prompt
667
+ process.stdout.write('> ');
668
+ }
669
+ });
670
+ // Handle Ctrl+C
671
+ process.on('SIGINT', async () => {
672
+ console.log('\nReceived SIGINT. Cleaning up...');
673
+ await cleanup();
674
+ });
675
+ // Start the interactive client
676
+ main().catch((error) => {
677
+ console.error('Error running MCP client:', error);
678
+ process.exit(1);
679
+ });
680
+ //# sourceMappingURL=elicitationUrlExample.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/elicitationUrlExample.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"elicitationUrlExample.js","sourceRoot":"","sources":["../../../../src/examples/client/elicitationUrlExample.ts"],"names":[],"mappings":";AAAA,iEAAiE;AACjE,EAAE;AACF,mEAAmE;AACnE,gDAAgD;AAChD,uFAAuF;AACvF,oCAAoC;;AAEpC,oDAA+C;AAC/C,sEAA+E;AAC/E,iDAAgD;AAChD,6CAcwB;AACxB,oEAA+D;AAE/D,iFAA6E;AAC7E,kDAAyD;AACzD,yCAAyC;AAEzC,2CAA2C;AAC3C,MAAM,mBAAmB,GAAG,IAAI,CAAC,CAAC,6CAA6C;AAC/E,MAAM,kBAAkB,GAAG,oBAAoB,mBAAmB,WAAW,CAAC;AAC9E,IAAI,aAAa,GAA4C,SAAS,CAAC;AAEvE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AACtC,MAAM,cAAc,GAAwB;IACxC,WAAW,EAAE,wBAAwB;IACrC,aAAa,EAAE,CAAC,kBAAkB,CAAC;IACnC,WAAW,EAAE,CAAC,oBAAoB,EAAE,eAAe,CAAC;IACpD,cAAc,EAAE,CAAC,MAAM,CAAC;IACxB,0BAA0B,EAAE,oBAAoB;IAChD,KAAK,EAAE,WAAW;CACrB,CAAC;AACF,aAAa,GAAG,IAAI,0DAA2B,CAAC,kBAAkB,EAAE,cAAc,EAAE,CAAC,WAAgB,EAAE,EAAE;IACrG,OAAO,CAAC,GAAG,CAAC,8DAA8D,WA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AC5B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACjD,MAAM,OAAO,EAAE,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,+BAA+B;AAC/B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export {};
2
+ //# sourceMappingURL=multipleClientsParallel.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"multipleClientsParallel.d.ts","sourceRoot":"","sources":["../../../../src/examples/client/multipleClientsParallel.ts"],"names":[],"mappings":""}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.js ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_js_1 = require("../../client/index.js");
4
+ const streamableHttp_js_1 = require("../../client/streamableHttp.js");
5
+ const types_js_1 = require("../../types.js");
6
+ /**
7
+ * Multiple Clients MCP Example
8
+ *
9
+ * This client demonstrates how to:
10
+ * 1. Create multiple MCP clients in parallel
11
+ * 2. Each client calls a single tool
12
+ * 3. Track notifications from each client independently
13
+ */
14
+ // Command line args processing
15
+ const args = process.argv.slice(2);
16
+ const serverUrl = args[0] || 'http://localhost:3000/mcp';
17
+ async function createAndRunClient(config) {
18
+ console.log(`[${config.id}] Creating client: ${config.name}`);
19
+ const client = new index_js_1.Client({
20
+ name: config.name,
21
+ version: '1.0.0'
22
+ });
23
+ const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(serverUrl));
24
+ // Set up client-specific error handler
25
+ client.onerror = error => {
26
+ console.error(`[${config.id}] Client error:`, error);
27
+ };
28
+ // Set up client-specific notification handler
29
+ client.setNotificationHandler(types_js_1.LoggingMessageNotificationSchema, notification => {
30
+ console.log(`[${config.id}] Notification: ${notification.params.data}`);
31
+ });
32
+ try {
33
+ // Connect to the server
34
+ await client.connect(transport);
35
+ console.log(`[${config.id}] Connected to MCP server`);
36
+ // Call the specified tool
37
+ console.log(`[${config.id}] Calling tool: ${config.toolName}`);
38
+ const toolRequest = {
39
+ method: 'tools/call',
40
+ params: {
41
+ name: config.toolName,
42
+ arguments: {
43
+ ...config.toolArguments,
44
+ // Add client ID to arguments for identification in notifications
45
+ caller: config.id
46
+ }
47
+ }
48
+ };
49
+ const result = await client.request(toolRequest, types_js_1.CallToolResultSchema);
50
+ console.log(`[${config.id}] Tool call completed`);
51
+ // Keep the connection open for a bit to receive notifications
52
+ await new Promise(resolve => setTimeout(resolve, 5000));
53
+ // Disconnect
54
+ await transport.close();
55
+ console.log(`[${config.id}] Disconnected from MCP server`);
56
+ return { id: config.id, result };
57
+ }
58
+ catch (error) {
59
+ console.error(`[${config.id}] Error:`, error);
60
+ throw error;
61
+ }
62
+ }
63
+ async function main() {
64
+ console.log('MCP Multiple Clients Example');
65
+ console.log('============================');
66
+ console.log(`Server URL: ${serverUrl}`);
67
+ console.log('');
68
+ try {
69
+ // Define client configurations
70
+ const clientConfigs = [
71
+ {
72
+ id: 'client1',
73
+ name: 'basic-client-1',
74
+ toolName: 'start-notification-stream',
75
+ toolArguments: {
76
+ interval: 3, // 1 second between notifications
77
+ count: 5 // Send 5 notifications
78
+ }
79
+ },
80
+ {
81
+ id: 'client2',
82
+ name: 'basic-client-2',
83
+ toolName: 'start-notification-stream',
84
+ toolArguments: {
85
+ interval: 2, // 2 seconds between notifications
86
+ count: 3 // Send 3 notifications
87
+ }
88
+ },
89
+ {
90
+ id: 'client3',
91
+ name: 'basic-client-3',
92
+ toolName: 'start-notification-stream',
93
+ toolArguments: {
94
+ interval: 1, // 0.5 second between notifications
95
+ count: 8 // Send 8 notifications
96
+ }
97
+ }
98
+ ];
99
+ // Start all clients in parallel
100
+ console.log(`Starting ${clientConfigs.length} clients in parallel...`);
101
+ console.log('');
102
+ const clientPromises = clientConfigs.map(config => createAndRunClient(config));
103
+ const results = await Promise.all(clientPromises);
104
+ // Display results from all clients
105
+ console.log('\n=== Final Results ===');
106
+ results.forEach(({ id, result }) => {
107
+ console.log(`\n[${id}] Tool result:`);
108
+ if (Array.isArray(result.content)) {
109
+ result.content.forEach((item) => {
110
+ if (item.type === 'text' && item.text) {
111
+ console.log(` ${item.text}`);
112
+ }
113
+ else {
114
+ console.log(` ${item.type} content:`, item);
115
+ }
116
+ });
117
+ }
118
+ else {
119
+ console.log(` Unexpected result format:`, result);
120
+ }
121
+ });
122
+ console.log('\n=== All clients completed successfully ===');
123
+ }
124
+ catch (error) {
125
+ console.error('Error running multiple clients:', error);
126
+ process.exit(1);
127
+ }
128
+ }
129
+ // Start the example
130
+ main().catch((error) => {
131
+ console.error('Error running MCP multiple clients example:', error);
132
+ process.exit(1);
133
+ });
134
+ //# sourceMappingURL=multipleClientsParallel.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/multipleClientsParallel.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,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,CAAC;gBAChC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAqC,EAAE,EAAE;oBAC7D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;wBACpC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;oBAClC,CAAC;yBAAM,CAAC;wBACJ,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,IAAI,WAAW,EAAE,IAAI,CAAC,CAAC;oBACjD,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;YACvD,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC;AAED,oBAAoB;AACpB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;IACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export {};
2
+ //# sourceMappingURL=parallelToolCallsClient.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"parallelToolCallsClient.d.ts","sourceRoot":"","sources":["../../../../src/examples/client/parallelToolCallsClient.ts"],"names":[],"mappings":""}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.js ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_js_1 = require("../../client/index.js");
4
+ const streamableHttp_js_1 = require("../../client/streamableHttp.js");
5
+ const types_js_1 = require("../../types.js");
6
+ /**
7
+ * Parallel Tool Calls MCP Client
8
+ *
9
+ * This client demonstrates how to:
10
+ * 1. Start multiple tool calls in parallel
11
+ * 2. Track notifications from each tool call using a caller parameter
12
+ */
13
+ // Command line args processing
14
+ const args = process.argv.slice(2);
15
+ const serverUrl = args[0] || 'http://localhost:3000/mcp';
16
+ async function main() {
17
+ console.log('MCP Parallel Tool Calls Client');
18
+ console.log('==============================');
19
+ console.log(`Connecting to server at: ${serverUrl}`);
20
+ let client;
21
+ let transport;
22
+ try {
23
+ // Create client with streamable HTTP transport
24
+ client = new index_js_1.Client({
25
+ name: 'parallel-tool-calls-client',
26
+ version: '1.0.0'
27
+ });
28
+ client.onerror = error => {
29
+ console.error('Client error:', error);
30
+ };
31
+ // Connect to the server
32
+ transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(serverUrl));
33
+ await client.connect(transport);
34
+ console.log('Successfully connected to MCP server');
35
+ // Set up notification handler with caller identification
36
+ client.setNotificationHandler(types_js_1.LoggingMessageNotificationSchema, notification => {
37
+ console.log(`Notification: ${notification.params.data}`);
38
+ });
39
+ console.log('List tools');
40
+ const toolsRequest = await listTools(client);
41
+ console.log('Tools: ', toolsRequest);
42
+ // 2. Start multiple notification tools in parallel
43
+ console.log('\n=== Starting Multiple Notification Streams in Parallel ===');
44
+ const toolResults = await startParallelNotificationTools(client);
45
+ // Log the results from each tool call
46
+ for (const [caller, result] of Object.entries(toolResults)) {
47
+ console.log(`\n=== Tool result for ${caller} ===`);
48
+ result.content.forEach((item) => {
49
+ if (item.type === 'text') {
50
+ console.log(` ${item.text}`);
51
+ }
52
+ else {
53
+ console.log(` ${item.type} content:`, item);
54
+ }
55
+ });
56
+ }
57
+ // 3. Wait for all notifications (10 seconds)
58
+ console.log('\n=== Waiting for all notifications ===');
59
+ await new Promise(resolve => setTimeout(resolve, 10000));
60
+ // 4. Disconnect
61
+ console.log('\n=== Disconnecting ===');
62
+ await transport.close();
63
+ console.log('Disconnected from MCP server');
64
+ }
65
+ catch (error) {
66
+ console.error('Error running client:', error);
67
+ process.exit(1);
68
+ }
69
+ }
70
+ /**
71
+ * List available tools on the server
72
+ */
73
+ async function listTools(client) {
74
+ try {
75
+ const toolsRequest = {
76
+ method: 'tools/list',
77
+ params: {}
78
+ };
79
+ const toolsResult = await client.request(toolsRequest, types_js_1.ListToolsResultSchema);
80
+ console.log('Available tools:');
81
+ if (toolsResult.tools.length === 0) {
82
+ console.log(' No tools available');
83
+ }
84
+ else {
85
+ for (const tool of toolsResult.tools) {
86
+ console.log(` - ${tool.name}: ${tool.description}`);
87
+ }
88
+ }
89
+ }
90
+ catch (error) {
91
+ console.log(`Tools not supported by this server: ${error}`);
92
+ }
93
+ }
94
+ /**
95
+ * Start multiple notification tools in parallel with different configurations
96
+ * Each tool call includes a caller parameter to identify its notifications
97
+ */
98
+ async function startParallelNotificationTools(client) {
99
+ try {
100
+ // Define multiple tool calls with different configurations
101
+ const toolCalls = [
102
+ {
103
+ caller: 'fast-notifier',
104
+ request: {
105
+ method: 'tools/call',
106
+ params: {
107
+ name: 'start-notification-stream',
108
+ arguments: {
109
+ interval: 2, // 0.5 second between notifications
110
+ count: 10, // Send 10 notifications
111
+ caller: 'fast-notifier' // Identify this tool call
112
+ }
113
+ }
114
+ }
115
+ },
116
+ {
117
+ caller: 'slow-notifier',
118
+ request: {
119
+ method: 'tools/call',
120
+ params: {
121
+ name: 'start-notification-stream',
122
+ arguments: {
123
+ interval: 5, // 2 seconds between notifications
124
+ count: 5, // Send 5 notifications
125
+ caller: 'slow-notifier' // Identify this tool call
126
+ }
127
+ }
128
+ }
129
+ },
130
+ {
131
+ caller: 'burst-notifier',
132
+ request: {
133
+ method: 'tools/call',
134
+ params: {
135
+ name: 'start-notification-stream',
136
+ arguments: {
137
+ interval: 1, // 0.1 second between notifications
138
+ count: 3, // Send just 3 notifications
139
+ caller: 'burst-notifier' // Identify this tool call
140
+ }
141
+ }
142
+ }
143
+ }
144
+ ];
145
+ console.log(`Starting ${toolCalls.length} notification tools in parallel...`);
146
+ // Start all tool calls in parallel
147
+ const toolPromises = toolCalls.map(({ caller, request }) => {
148
+ console.log(`Starting tool call for ${caller}...`);
149
+ return client
150
+ .request(request, types_js_1.CallToolResultSchema)
151
+ .then(result => ({ caller, result }))
152
+ .catch(error => {
153
+ console.error(`Error in tool call for ${caller}:`, error);
154
+ throw error;
155
+ });
156
+ });
157
+ // Wait for all tool calls to complete
158
+ const results = await Promise.all(toolPromises);
159
+ // Organize results by caller
160
+ const resultsByTool = {};
161
+ results.forEach(({ caller, result }) => {
162
+ resultsByTool[caller] = result;
163
+ });
164
+ return resultsByTool;
165
+ }
166
+ catch (error) {
167
+ console.error(`Error starting parallel notification tools:`, error);
168
+ throw error;
169
+ }
170
+ }
171
+ // Start the client
172
+ main().catch((error) => {
173
+ console.error('Error running MCP client:', error);
174
+ process.exit(1);
175
+ });
176
+ //# sourceMappingURL=parallelToolCallsClient.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/parallelToolCallsClient.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"parallelToolCallsClient.js","sourceRoot":"","sources":["../../../../src/examples/client/parallelToolCallsClient.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,sEAA+E;AAC/E,6CAMwB;AAExB;;;;;;GAMG;AAEH,+BAA+B;AAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,2BAA2B,CAAC;AAEzD,KAAK,UAAU,IAAI;IACf,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC;IAErD,IAAI,MAAc,CAAC;IACnB,IAAI,SAAwC,CAAC;IAE7C,IAAI,CAAC;QACD,+CAA+C;QAC/C,MAAM,GAAG,IAAI,iBAAM,CAAC;YAChB,IAAI,EAAE,4BAA4B;YAClC,OAAO,EAAE,OAAO;SACnB,CAAC,CAAC;QAEH,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE;YACrB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF,wBAAwB;QACxB,SAAS,GAAG,IAAI,iDAA6B,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QAClE,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAEpD,yDAAyD;QACzD,MAAM,CAAC,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AAG,EAAE,KAAK,CAAC,CAAC;gBAC1D,MAAM,KAAK,CAAC;YAChB,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QAEH,sCAAsC;QACtC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAEhD,6BAA6B;QAC7B,MAAM,aAAa,GAAmC,EAAE,CAAC;QACzD,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;YACnC,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;QACpE,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC;AAED,mBAAmB;AACnB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Example demonstrating client_credentials grant for machine-to-machine authentication.
4
+ *
5
+ * Supports two authentication methods based on environment variables:
6
+ *
7
+ * 1. client_secret_basic (default):
8
+ * MCP_CLIENT_ID - OAuth client ID (required)
9
+ * MCP_CLIENT_SECRET - OAuth client secret (required)
10
+ *
11
+ * 2. private_key_jwt (when MCP_CLIENT_PRIVATE_KEY_PEM is set):
12
+ * MCP_CLIENT_ID - OAuth client ID (required)
13
+ * MCP_CLIENT_PRIVATE_KEY_PEM - PEM-encoded private key for JWT signing (required)
14
+ * MCP_CLIENT_ALGORITHM - Signing algorithm (default: RS256)
15
+ *
16
+ * Common:
17
+ * MCP_SERVER_URL - Server URL (default: http://localhost:3000/mcp)
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=simpleClientCredentials.d.ts.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"simpleClientCredentials.d.ts","sourceRoot":"","sources":["../../../../src/examples/client/simpleClientCredentials.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;GAgBG"}
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Example demonstrating client_credentials grant for machine-to-machine authentication.
5
+ *
6
+ * Supports two authentication methods based on environment variables:
7
+ *
8
+ * 1. client_secret_basic (default):
9
+ * MCP_CLIENT_ID - OAuth client ID (required)
10
+ * MCP_CLIENT_SECRET - OAuth client secret (required)
11
+ *
12
+ * 2. private_key_jwt (when MCP_CLIENT_PRIVATE_KEY_PEM is set):
13
+ * MCP_CLIENT_ID - OAuth client ID (required)
14
+ * MCP_CLIENT_PRIVATE_KEY_PEM - PEM-encoded private key for JWT signing (required)
15
+ * MCP_CLIENT_ALGORITHM - Signing algorithm (default: RS256)
16
+ *
17
+ * Common:
18
+ * MCP_SERVER_URL - Server URL (default: http://localhost:3000/mcp)
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const index_js_1 = require("../../client/index.js");
22
+ const streamableHttp_js_1 = require("../../client/streamableHttp.js");
23
+ const auth_extensions_js_1 = require("../../client/auth-extensions.js");
24
+ const DEFAULT_SERVER_URL = process.env.MCP_SERVER_URL || 'http://localhost:3000/mcp';
25
+ function createProvider() {
26
+ const clientId = process.env.MCP_CLIENT_ID;
27
+ if (!clientId) {
28
+ console.error('MCP_CLIENT_ID environment variable is required');
29
+ process.exit(1);
30
+ }
31
+ // If private key is provided, use private_key_jwt authentication
32
+ const privateKeyPem = process.env.MCP_CLIENT_PRIVATE_KEY_PEM;
33
+ if (privateKeyPem) {
34
+ const algorithm = process.env.MCP_CLIENT_ALGORITHM || 'RS256';
35
+ console.log('Using private_key_jwt authentication');
36
+ return new auth_extensions_js_1.PrivateKeyJwtProvider({
37
+ clientId,
38
+ privateKey: privateKeyPem,
39
+ algorithm
40
+ });
41
+ }
42
+ // Otherwise, use client_secret_basic authentication
43
+ const clientSecret = process.env.MCP_CLIENT_SECRET;
44
+ if (!clientSecret) {
45
+ console.error('MCP_CLIENT_SECRET or MCP_CLIENT_PRIVATE_KEY_PEM environment variable is required');
46
+ process.exit(1);
47
+ }
48
+ console.log('Using client_secret_basic authentication');
49
+ return new auth_extensions_js_1.ClientCredentialsProvider({
50
+ clientId,
51
+ clientSecret
52
+ });
53
+ }
54
+ async function main() {
55
+ const provider = createProvider();
56
+ const client = new index_js_1.Client({ name: 'client-credentials-example', version: '1.0.0' }, { capabilities: {} });
57
+ const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(DEFAULT_SERVER_URL), {
58
+ authProvider: provider
59
+ });
60
+ await client.connect(transport);
61
+ console.log('Connected successfully.');
62
+ const tools = await client.listTools();
63
+ console.log('Available tools:', tools.tools.map(t => t.name).join(', ') || '(none)');
64
+ await transport.close();
65
+ }
66
+ main().catch(err => {
67
+ console.error(err);
68
+ process.exit(1);
69
+ });
70
+ //# sourceMappingURL=simpleClientCredentials.js.map
loan-advisor-chatgpt-app/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"simpleClientCredentials.js","sourceRoot":"","sources":["../../../../src/examples/client/simpleClientCredentials.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;GAgBG;;AAEH,oDAA+C;AAC/C,sEAA+E;AAC/E,wEAAmG;AAGnG,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,2BAA2B,CAAC;AAErF,SAAS,cAAc;IACnB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,iEAAiE;IACjE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IAC7D,IAAI,aAAa,EAAE,CAAC;QAChB,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QACpD,OAAO,IAAI,0CAAqB,CAAC;YAC7B,QAAQ;YACR,UAAU,EAAE,aAAa;YACzB,SAAS;SACZ,CAAC,CAAC;IACP,CAAC;IAED,oDAAoD;IACpD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACnD,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,kFAAkF,CAAC,CAAC;QAClG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IACxD,OAAO,IAAI,8CAAyB,CAAC;QACjC,QAAQ;QACR,Y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