@mcp-z/client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +159 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/auth/capability-discovery.d.cts +25 -0
- package/dist/cjs/auth/capability-discovery.d.ts +25 -0
- package/dist/cjs/auth/capability-discovery.js +280 -0
- package/dist/cjs/auth/capability-discovery.js.map +1 -0
- package/dist/cjs/auth/index.d.cts +9 -0
- package/dist/cjs/auth/index.d.ts +9 -0
- package/dist/cjs/auth/index.js +28 -0
- package/dist/cjs/auth/index.js.map +1 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.cts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.js +537 -0
- package/dist/cjs/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/cjs/auth/oauth-callback-listener.d.cts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.js +333 -0
- package/dist/cjs/auth/oauth-callback-listener.js.map +1 -0
- package/dist/cjs/auth/pkce.d.cts +17 -0
- package/dist/cjs/auth/pkce.d.ts +17 -0
- package/dist/cjs/auth/pkce.js +192 -0
- package/dist/cjs/auth/pkce.js.map +1 -0
- package/dist/cjs/auth/rfc9728-discovery.d.cts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.js +436 -0
- package/dist/cjs/auth/rfc9728-discovery.js.map +1 -0
- package/dist/cjs/auth/types.d.cts +137 -0
- package/dist/cjs/auth/types.d.ts +137 -0
- package/dist/cjs/auth/types.js +9 -0
- package/dist/cjs/auth/types.js.map +1 -0
- package/dist/cjs/client-helpers.d.cts +55 -0
- package/dist/cjs/client-helpers.d.ts +55 -0
- package/dist/cjs/client-helpers.js +128 -0
- package/dist/cjs/client-helpers.js.map +1 -0
- package/dist/cjs/config/server-loader.d.cts +27 -0
- package/dist/cjs/config/server-loader.d.ts +27 -0
- package/dist/cjs/config/server-loader.js +111 -0
- package/dist/cjs/config/server-loader.js.map +1 -0
- package/dist/cjs/config/validate-config.d.cts +15 -0
- package/dist/cjs/config/validate-config.d.ts +15 -0
- package/dist/cjs/config/validate-config.js +128 -0
- package/dist/cjs/config/validate-config.js.map +1 -0
- package/dist/cjs/connection/connect-client.d.cts +59 -0
- package/dist/cjs/connection/connect-client.d.ts +59 -0
- package/dist/cjs/connection/connect-client.js +536 -0
- package/dist/cjs/connection/connect-client.js.map +1 -0
- package/dist/cjs/connection/existing-process-transport.d.cts +40 -0
- package/dist/cjs/connection/existing-process-transport.d.ts +40 -0
- package/dist/cjs/connection/existing-process-transport.js +274 -0
- package/dist/cjs/connection/existing-process-transport.js.map +1 -0
- package/dist/cjs/connection/types.d.cts +61 -0
- package/dist/cjs/connection/types.d.ts +61 -0
- package/dist/cjs/connection/types.js +53 -0
- package/dist/cjs/connection/types.js.map +1 -0
- package/dist/cjs/connection/wait-for-http-ready.d.cts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.js +232 -0
- package/dist/cjs/connection/wait-for-http-ready.js.map +1 -0
- package/dist/cjs/dcr/dcr-authenticator.d.cts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.js +655 -0
- package/dist/cjs/dcr/dcr-authenticator.js.map +1 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.cts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js +245 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/cjs/dcr/index.d.cts +8 -0
- package/dist/cjs/dcr/index.d.ts +8 -0
- package/dist/cjs/dcr/index.js +24 -0
- package/dist/cjs/dcr/index.js.map +1 -0
- package/dist/cjs/index.d.cts +21 -0
- package/dist/cjs/index.d.ts +21 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/monkey-patches.d.cts +6 -0
- package/dist/cjs/monkey-patches.d.ts +6 -0
- package/dist/cjs/monkey-patches.js +236 -0
- package/dist/cjs/monkey-patches.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/response-wrappers.d.cts +41 -0
- package/dist/cjs/response-wrappers.d.ts +41 -0
- package/dist/cjs/response-wrappers.js +443 -0
- package/dist/cjs/response-wrappers.js.map +1 -0
- package/dist/cjs/search/index.d.cts +6 -0
- package/dist/cjs/search/index.d.ts +6 -0
- package/dist/cjs/search/index.js +25 -0
- package/dist/cjs/search/index.js.map +1 -0
- package/dist/cjs/search/search.d.cts +22 -0
- package/dist/cjs/search/search.d.ts +22 -0
- package/dist/cjs/search/search.js +630 -0
- package/dist/cjs/search/search.js.map +1 -0
- package/dist/cjs/search/types.d.cts +122 -0
- package/dist/cjs/search/types.d.ts +122 -0
- package/dist/cjs/search/types.js +10 -0
- package/dist/cjs/search/types.js.map +1 -0
- package/dist/cjs/spawn/spawn-server.d.cts +83 -0
- package/dist/cjs/spawn/spawn-server.d.ts +83 -0
- package/dist/cjs/spawn/spawn-server.js +410 -0
- package/dist/cjs/spawn/spawn-server.js.map +1 -0
- package/dist/cjs/spawn/spawn-servers.d.cts +151 -0
- package/dist/cjs/spawn/spawn-servers.d.ts +151 -0
- package/dist/cjs/spawn/spawn-servers.js +911 -0
- package/dist/cjs/spawn/spawn-servers.js.map +1 -0
- package/dist/cjs/types.d.cts +11 -0
- package/dist/cjs/types.d.ts +11 -0
- package/dist/cjs/types.js +10 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/logger.d.cts +24 -0
- package/dist/cjs/utils/logger.d.ts +24 -0
- package/dist/cjs/utils/logger.js +80 -0
- package/dist/cjs/utils/logger.js.map +1 -0
- package/dist/cjs/utils/path-utils.d.cts +45 -0
- package/dist/cjs/utils/path-utils.d.ts +45 -0
- package/dist/cjs/utils/path-utils.js +158 -0
- package/dist/cjs/utils/path-utils.js.map +1 -0
- package/dist/cjs/utils/sanitizer.d.cts +30 -0
- package/dist/cjs/utils/sanitizer.d.ts +30 -0
- package/dist/cjs/utils/sanitizer.js +124 -0
- package/dist/cjs/utils/sanitizer.js.map +1 -0
- package/dist/esm/auth/capability-discovery.d.ts +25 -0
- package/dist/esm/auth/capability-discovery.js +110 -0
- package/dist/esm/auth/capability-discovery.js.map +1 -0
- package/dist/esm/auth/index.d.ts +9 -0
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/esm/auth/interactive-oauth-flow.js +217 -0
- package/dist/esm/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/esm/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/esm/auth/oauth-callback-listener.js +166 -0
- package/dist/esm/auth/oauth-callback-listener.js.map +1 -0
- package/dist/esm/auth/pkce.d.ts +17 -0
- package/dist/esm/auth/pkce.js +41 -0
- package/dist/esm/auth/pkce.js.map +1 -0
- package/dist/esm/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/esm/auth/rfc9728-discovery.js +157 -0
- package/dist/esm/auth/rfc9728-discovery.js.map +1 -0
- package/dist/esm/auth/types.d.ts +137 -0
- package/dist/esm/auth/types.js +7 -0
- package/dist/esm/auth/types.js.map +1 -0
- package/dist/esm/client-helpers.d.ts +55 -0
- package/dist/esm/client-helpers.js +81 -0
- package/dist/esm/client-helpers.js.map +1 -0
- package/dist/esm/config/server-loader.d.ts +27 -0
- package/dist/esm/config/server-loader.js +49 -0
- package/dist/esm/config/server-loader.js.map +1 -0
- package/dist/esm/config/validate-config.d.ts +15 -0
- package/dist/esm/config/validate-config.js +76 -0
- package/dist/esm/config/validate-config.js.map +1 -0
- package/dist/esm/connection/connect-client.d.ts +59 -0
- package/dist/esm/connection/connect-client.js +272 -0
- package/dist/esm/connection/connect-client.js.map +1 -0
- package/dist/esm/connection/existing-process-transport.d.ts +40 -0
- package/dist/esm/connection/existing-process-transport.js +103 -0
- package/dist/esm/connection/existing-process-transport.js.map +1 -0
- package/dist/esm/connection/types.d.ts +61 -0
- package/dist/esm/connection/types.js +34 -0
- package/dist/esm/connection/types.js.map +1 -0
- package/dist/esm/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/esm/connection/wait-for-http-ready.js +43 -0
- package/dist/esm/connection/wait-for-http-ready.js.map +1 -0
- package/dist/esm/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/esm/dcr/dcr-authenticator.js +235 -0
- package/dist/esm/dcr/dcr-authenticator.js.map +1 -0
- package/dist/esm/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/esm/dcr/dynamic-client-registrar.js +66 -0
- package/dist/esm/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/esm/dcr/index.d.ts +8 -0
- package/dist/esm/dcr/index.js +5 -0
- package/dist/esm/dcr/index.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/monkey-patches.d.ts +6 -0
- package/dist/esm/monkey-patches.js +32 -0
- package/dist/esm/monkey-patches.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/response-wrappers.d.ts +41 -0
- package/dist/esm/response-wrappers.js +201 -0
- package/dist/esm/response-wrappers.js.map +1 -0
- package/dist/esm/search/index.d.ts +6 -0
- package/dist/esm/search/index.js +3 -0
- package/dist/esm/search/index.js.map +1 -0
- package/dist/esm/search/search.d.ts +22 -0
- package/dist/esm/search/search.js +236 -0
- package/dist/esm/search/search.js.map +1 -0
- package/dist/esm/search/types.d.ts +122 -0
- package/dist/esm/search/types.js +8 -0
- package/dist/esm/search/types.js.map +1 -0
- package/dist/esm/spawn/spawn-server.d.ts +83 -0
- package/dist/esm/spawn/spawn-server.js +145 -0
- package/dist/esm/spawn/spawn-server.js.map +1 -0
- package/dist/esm/spawn/spawn-servers.d.ts +151 -0
- package/dist/esm/spawn/spawn-servers.js +406 -0
- package/dist/esm/spawn/spawn-servers.js.map +1 -0
- package/dist/esm/types.d.ts +11 -0
- package/dist/esm/types.js +9 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/logger.d.ts +24 -0
- package/dist/esm/utils/logger.js +59 -0
- package/dist/esm/utils/logger.js.map +1 -0
- package/dist/esm/utils/path-utils.d.ts +45 -0
- package/dist/esm/utils/path-utils.js +89 -0
- package/dist/esm/utils/path-utils.js.map +1 -0
- package/dist/esm/utils/sanitizer.d.ts +30 -0
- package/dist/esm/utils/sanitizer.js +43 -0
- package/dist/esm/utils/sanitizer.js.map +1 -0
- package/package.json +92 -0
- package/schemas/servers.d.ts +90 -0
- package/schemas/servers.schema.json +104 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# MCP Examples for AI Agents
|
|
2
|
+
|
|
3
|
+
Quick-start examples for building scripts with MCP servers using `@mcp-z/client`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mcp-z/client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Peek
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import { createServerRegistry } from '@mcp-z/client';
|
|
15
|
+
|
|
16
|
+
const registry = createServerRegistry({ todoist: { url: 'https://ai.todoist.net/mcp' } });
|
|
17
|
+
const client = await registry.connect('todoist');
|
|
18
|
+
await client.callTool('add-tasks', { tasks: [{ content: 'My task', priority: 4 }] });
|
|
19
|
+
await registry.close();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Full Example: Todoist Task Management
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
/**
|
|
26
|
+
* This example shows how to use @mcp-z/client to manage tasks via Todoist.
|
|
27
|
+
* Copy this and modify it for your needs!
|
|
28
|
+
*
|
|
29
|
+
* PREREQUISITES:
|
|
30
|
+
* npm install @mcp-z/client # the client library for typescript / javascript
|
|
31
|
+
* npm install @mcp-z/cli # the cli command is "mcpz". Run "mcpz --help" for a full list of commands
|
|
32
|
+
*
|
|
33
|
+
* DISCOVERY (find tools before writing code):
|
|
34
|
+
* npx @mcp-z/cli search "add task" # Find the tool you need
|
|
35
|
+
* npx @mcp-z/cli inspect --servers todoist # See all available tools
|
|
36
|
+
* npx @mcp-z/cli call-tool todoist add-tasks '{}' # Test it works
|
|
37
|
+
*
|
|
38
|
+
* TIP: Or load your own .mcp.json file instead of inline config:
|
|
39
|
+
* const config = JSON.parse(fs.readFileSync('.mcp.json', 'utf-8'));
|
|
40
|
+
* const registry = createServerRegistry(config.mcpServers);
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
import { createServerRegistry } from '@mcp-z/client';
|
|
44
|
+
|
|
45
|
+
// Configure your MCP servers (inline, or load from .mcp.json file)
|
|
46
|
+
const servers = {
|
|
47
|
+
todoist: {
|
|
48
|
+
url: 'https://ai.todoist.net/mcp'
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
async function main() {
|
|
53
|
+
const registry = createServerRegistry(servers);
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
console.log('🚀 Connecting to Todoist...');
|
|
57
|
+
const client = await registry.connect('todoist');
|
|
58
|
+
|
|
59
|
+
console.log('✅ Connected! Adding task...');
|
|
60
|
+
|
|
61
|
+
// Add a task to Todoist
|
|
62
|
+
// See available tools: npx @mcp-z/cli inspect --servers todoist
|
|
63
|
+
await client.callTool('add-tasks', {
|
|
64
|
+
tasks: [
|
|
65
|
+
{
|
|
66
|
+
content: 'Learn MCP with @mcp-z/client',
|
|
67
|
+
projectId: undefined, // Optional: add to specific project
|
|
68
|
+
priority: 4 // 1-4, where 4 is highest
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
console.log('✅ Task added successfully!');
|
|
74
|
+
|
|
75
|
+
// List tasks (discovery first: npx @mcp-z/cli inspect --servers todoist)
|
|
76
|
+
console.log('\n📋 Fetching tasks...');
|
|
77
|
+
const findResponse = await client.callTool('find-tasks', {
|
|
78
|
+
searchText: 'Learn MCP'
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
console.log('✅ Tasks found:', findResponse.json());
|
|
82
|
+
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error('❌ Error:', error.message);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
} finally {
|
|
87
|
+
console.log('🔒 Closing connection...');
|
|
88
|
+
await registry.close();
|
|
89
|
+
console.log('✅ Done!');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
main();
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## The Pattern
|
|
97
|
+
|
|
98
|
+
Once you understand this example, you understand them all:
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
import { createServerRegistry } from '@mcp-z/client';
|
|
102
|
+
|
|
103
|
+
const registry = createServerRegistry(servers); // Configure servers
|
|
104
|
+
try {
|
|
105
|
+
const client = await registry.connect('server-name'); // Connect
|
|
106
|
+
await client.callTool('tool-name', { /* args */ }); // Use tools
|
|
107
|
+
} finally {
|
|
108
|
+
await registry.close(); // Always cleanup
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Configure servers inline or from `.mcp.json`:**
|
|
113
|
+
```javascript
|
|
114
|
+
// Inline config
|
|
115
|
+
const servers = { todoist: { url: '...' } };
|
|
116
|
+
|
|
117
|
+
// Or load from file
|
|
118
|
+
const config = JSON.parse(fs.readFileSync('.mcp.json', 'utf-8'));
|
|
119
|
+
const servers = config.mcpServers;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Discovery Workflow
|
|
123
|
+
|
|
124
|
+
**Before writing code, discover what's available:**
|
|
125
|
+
|
|
126
|
+
1. **Search for tools:**
|
|
127
|
+
```bash
|
|
128
|
+
npx @mcp-z/cli search "add task"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
2. **Inspect a server:**
|
|
132
|
+
```bash
|
|
133
|
+
npx @mcp-z/cli inspect --servers todoist
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
3. **Test a tool:**
|
|
137
|
+
```bash
|
|
138
|
+
npx @mcp-z/cli call-tool todoist add-tasks '{"tasks":[{"content":"Test"}]}'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
4. **Write your script** using `@mcp-z/client`
|
|
142
|
+
|
|
143
|
+
## Available Public Servers
|
|
144
|
+
|
|
145
|
+
These servers don't need special setup - just use their URLs:
|
|
146
|
+
|
|
147
|
+
- **Todoist**: `https://ai.todoist.net/mcp`
|
|
148
|
+
- **Notion**: `https://mcp.notion.com/mcp`
|
|
149
|
+
|
|
150
|
+
Private servers (require authentication):
|
|
151
|
+
- Google Sheets, Drive, Gmail, Outlook, PDF (contact us for access)
|
|
152
|
+
|
|
153
|
+
## Need Help?
|
|
154
|
+
|
|
155
|
+
1. **Discover tools**: `npx @mcp-z/cli search <query>`
|
|
156
|
+
2. **See all tools**: `npx @mcp-z/cli inspect --servers <server>`
|
|
157
|
+
3. **Test first**: `npx @mcp-z/cli call-tool <server> <tool> '{}'`
|
|
158
|
+
|
|
159
|
+
Once you know a tool works via CLI, use it in your script with `@mcp-z/client`!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kevin Malakoff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @mcp-z/client
|
|
2
|
+
|
|
3
|
+
Docs: https://mcp-z.github.io/client
|
|
4
|
+
Programmatic MCP client for spawning, connecting to, and calling MCP servers.
|
|
5
|
+
|
|
6
|
+
## Common uses
|
|
7
|
+
|
|
8
|
+
- Run MCP tools from scripts
|
|
9
|
+
- Connect to multiple servers in one process
|
|
10
|
+
- Integration tests for MCP servers
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install --save-dev @mcp-z/client
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Requires Node.js >= 22.
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { createServerRegistry } from '@mcp-z/client';
|
|
24
|
+
|
|
25
|
+
const registry = createServerRegistry({
|
|
26
|
+
todoist: { url: 'https://ai.todoist.net/mcp', type: 'http' }
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const client = await registry.connect('todoist');
|
|
30
|
+
await client.callTool('add-tasks', {
|
|
31
|
+
tasks: [{ content: 'Learn MCP', priority: 4 }]
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await registry.close();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
MCP supports stdio and HTTP.
|
|
40
|
+
|
|
41
|
+
**Stdio**
|
|
42
|
+
```ts
|
|
43
|
+
{
|
|
44
|
+
echo: {
|
|
45
|
+
command: 'node',
|
|
46
|
+
args: ['server.js'],
|
|
47
|
+
env: { LOG_LEVEL: 'info' }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**HTTP**
|
|
53
|
+
```ts
|
|
54
|
+
{
|
|
55
|
+
todoist: {
|
|
56
|
+
type: 'http',
|
|
57
|
+
url: 'https://ai.todoist.net/mcp',
|
|
58
|
+
headers: { Authorization: 'Bearer token' }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## API basics
|
|
64
|
+
|
|
65
|
+
- `createServerRegistry(config, options?)`
|
|
66
|
+
- `registry.connect(name)`
|
|
67
|
+
- `client.callTool(name, args)`
|
|
68
|
+
- `client.listTools()` / `client.listResources()` / `client.listPrompts()`
|
|
69
|
+
- `registry.close()`
|
|
70
|
+
|
|
71
|
+
## OAuth (DCR)
|
|
72
|
+
|
|
73
|
+
If an HTTP server supports DCR, pass a token store:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import Keyv from 'keyv';
|
|
77
|
+
import { createServerRegistry } from '@mcp-z/client';
|
|
78
|
+
|
|
79
|
+
const registry = createServerRegistry({
|
|
80
|
+
todoist: { type: 'http', url: 'https://ai.todoist.net/mcp' }
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const client = await registry.connect('todoist', {
|
|
84
|
+
dcrAuthenticator: { tokenStore: new Keyv() }
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Requirements
|
|
89
|
+
|
|
90
|
+
- Node.js >= 22
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Server Capability Discovery
|
|
3
|
+
* Probes RFC 9728 (Protected Resource) and RFC 8414 (Authorization Server) metadata
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthCapabilities } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Probe OAuth server capabilities using RFC 9728 → RFC 8414 discovery chain
|
|
8
|
+
* Returns capabilities including DCR support detection
|
|
9
|
+
*
|
|
10
|
+
* Discovery Strategy:
|
|
11
|
+
* 1. Try RFC 9728 Protected Resource Metadata (supports cross-domain OAuth)
|
|
12
|
+
* 2. If found, use first authorization_server to discover RFC 8414 Authorization Server Metadata
|
|
13
|
+
* 3. Fall back to direct RFC 8414 discovery at resource origin
|
|
14
|
+
*
|
|
15
|
+
* @param baseUrl - Base URL of the protected resource (e.g., https://ai.todoist.net/mcp)
|
|
16
|
+
* @returns AuthCapabilities object with discovered endpoints and features
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Todoist case: MCP at ai.todoist.net/mcp, OAuth at todoist.com
|
|
20
|
+
* const caps = await probeAuthCapabilities('https://ai.todoist.net/mcp');
|
|
21
|
+
* if (caps.supportsDcr) {
|
|
22
|
+
* console.log('Registration endpoint:', caps.registrationEndpoint);
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
export declare function probeAuthCapabilities(baseUrl: string): Promise<AuthCapabilities>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Server Capability Discovery
|
|
3
|
+
* Probes RFC 9728 (Protected Resource) and RFC 8414 (Authorization Server) metadata
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthCapabilities } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Probe OAuth server capabilities using RFC 9728 → RFC 8414 discovery chain
|
|
8
|
+
* Returns capabilities including DCR support detection
|
|
9
|
+
*
|
|
10
|
+
* Discovery Strategy:
|
|
11
|
+
* 1. Try RFC 9728 Protected Resource Metadata (supports cross-domain OAuth)
|
|
12
|
+
* 2. If found, use first authorization_server to discover RFC 8414 Authorization Server Metadata
|
|
13
|
+
* 3. Fall back to direct RFC 8414 discovery at resource origin
|
|
14
|
+
*
|
|
15
|
+
* @param baseUrl - Base URL of the protected resource (e.g., https://ai.todoist.net/mcp)
|
|
16
|
+
* @returns AuthCapabilities object with discovered endpoints and features
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Todoist case: MCP at ai.todoist.net/mcp, OAuth at todoist.com
|
|
20
|
+
* const caps = await probeAuthCapabilities('https://ai.todoist.net/mcp');
|
|
21
|
+
* if (caps.supportsDcr) {
|
|
22
|
+
* console.log('Registration endpoint:', caps.registrationEndpoint);
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
export declare function probeAuthCapabilities(baseUrl: string): Promise<AuthCapabilities>;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Server Capability Discovery
|
|
3
|
+
* Probes RFC 9728 (Protected Resource) and RFC 8414 (Authorization Server) metadata
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "probeAuthCapabilities", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return probeAuthCapabilities;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _rfc9728discoveryts = require("./rfc9728-discovery.js");
|
|
15
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16
|
+
try {
|
|
17
|
+
var info = gen[key](arg);
|
|
18
|
+
var value = info.value;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
reject(error);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (info.done) {
|
|
24
|
+
resolve(value);
|
|
25
|
+
} else {
|
|
26
|
+
Promise.resolve(value).then(_next, _throw);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function _async_to_generator(fn) {
|
|
30
|
+
return function() {
|
|
31
|
+
var self = this, args = arguments;
|
|
32
|
+
return new Promise(function(resolve, reject) {
|
|
33
|
+
var gen = fn.apply(self, args);
|
|
34
|
+
function _next(value) {
|
|
35
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
36
|
+
}
|
|
37
|
+
function _throw(err) {
|
|
38
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
39
|
+
}
|
|
40
|
+
_next(undefined);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function _ts_generator(thisArg, body) {
|
|
45
|
+
var f, y, t, _ = {
|
|
46
|
+
label: 0,
|
|
47
|
+
sent: function() {
|
|
48
|
+
if (t[0] & 1) throw t[1];
|
|
49
|
+
return t[1];
|
|
50
|
+
},
|
|
51
|
+
trys: [],
|
|
52
|
+
ops: []
|
|
53
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
54
|
+
return d(g, "next", {
|
|
55
|
+
value: verb(0)
|
|
56
|
+
}), d(g, "throw", {
|
|
57
|
+
value: verb(1)
|
|
58
|
+
}), d(g, "return", {
|
|
59
|
+
value: verb(2)
|
|
60
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
61
|
+
value: function() {
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
}), g;
|
|
65
|
+
function verb(n) {
|
|
66
|
+
return function(v) {
|
|
67
|
+
return step([
|
|
68
|
+
n,
|
|
69
|
+
v
|
|
70
|
+
]);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function step(op) {
|
|
74
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
75
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
76
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
77
|
+
if (y = 0, t) op = [
|
|
78
|
+
op[0] & 2,
|
|
79
|
+
t.value
|
|
80
|
+
];
|
|
81
|
+
switch(op[0]){
|
|
82
|
+
case 0:
|
|
83
|
+
case 1:
|
|
84
|
+
t = op;
|
|
85
|
+
break;
|
|
86
|
+
case 4:
|
|
87
|
+
_.label++;
|
|
88
|
+
return {
|
|
89
|
+
value: op[1],
|
|
90
|
+
done: false
|
|
91
|
+
};
|
|
92
|
+
case 5:
|
|
93
|
+
_.label++;
|
|
94
|
+
y = op[1];
|
|
95
|
+
op = [
|
|
96
|
+
0
|
|
97
|
+
];
|
|
98
|
+
continue;
|
|
99
|
+
case 7:
|
|
100
|
+
op = _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
default:
|
|
104
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
105
|
+
_ = 0;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
109
|
+
_.label = op[1];
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
113
|
+
_.label = t[1];
|
|
114
|
+
t = op;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (t && _.label < t[2]) {
|
|
118
|
+
_.label = t[2];
|
|
119
|
+
_.ops.push(op);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
if (t[2]) _.ops.pop();
|
|
123
|
+
_.trys.pop();
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
op = body.call(thisArg, _);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
op = [
|
|
129
|
+
6,
|
|
130
|
+
e
|
|
131
|
+
];
|
|
132
|
+
y = 0;
|
|
133
|
+
} finally{
|
|
134
|
+
f = t = 0;
|
|
135
|
+
}
|
|
136
|
+
if (op[0] & 5) throw op[1];
|
|
137
|
+
return {
|
|
138
|
+
value: op[0] ? op[1] : void 0,
|
|
139
|
+
done: true
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Extract origin (protocol + host) from a URL
|
|
145
|
+
* @param url - Full URL that may include a path
|
|
146
|
+
* @returns Origin (e.g., "https://example.com") or original string if invalid URL
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* getOrigin('https://example.com/mcp') // → 'https://example.com'
|
|
150
|
+
* getOrigin('http://localhost:9999/api/v1/mcp') // → 'http://localhost:9999'
|
|
151
|
+
*/ function getOrigin(url) {
|
|
152
|
+
try {
|
|
153
|
+
return new URL(url).origin;
|
|
154
|
+
} catch (unused) {
|
|
155
|
+
// Invalid URL - return as-is for graceful degradation
|
|
156
|
+
return url;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function probeAuthCapabilities(baseUrl) {
|
|
160
|
+
return _async_to_generator(function() {
|
|
161
|
+
var resourceMetadata, authServerUrl, authServerMetadata, supportsDcr, capabilities, scopes, origin, authServerMetadata1, supportsDcr1, capabilities1, _error;
|
|
162
|
+
return _ts_generator(this, function(_state) {
|
|
163
|
+
switch(_state.label){
|
|
164
|
+
case 0:
|
|
165
|
+
_state.trys.push([
|
|
166
|
+
0,
|
|
167
|
+
5,
|
|
168
|
+
,
|
|
169
|
+
6
|
|
170
|
+
]);
|
|
171
|
+
return [
|
|
172
|
+
4,
|
|
173
|
+
(0, _rfc9728discoveryts.discoverProtectedResourceMetadata)(baseUrl)
|
|
174
|
+
];
|
|
175
|
+
case 1:
|
|
176
|
+
resourceMetadata = _state.sent();
|
|
177
|
+
if (!(resourceMetadata && resourceMetadata.authorization_servers.length > 0)) return [
|
|
178
|
+
3,
|
|
179
|
+
3
|
|
180
|
+
];
|
|
181
|
+
// Found protected resource metadata with authorization servers
|
|
182
|
+
// Discover the authorization server's metadata (RFC 8414)
|
|
183
|
+
authServerUrl = resourceMetadata.authorization_servers[0];
|
|
184
|
+
if (!authServerUrl) {
|
|
185
|
+
// Array has length > 0 but first element is undefined/null - skip this path
|
|
186
|
+
return [
|
|
187
|
+
2,
|
|
188
|
+
{
|
|
189
|
+
supportsDcr: false
|
|
190
|
+
}
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
return [
|
|
194
|
+
4,
|
|
195
|
+
(0, _rfc9728discoveryts.discoverAuthorizationServerMetadata)(authServerUrl)
|
|
196
|
+
];
|
|
197
|
+
case 2:
|
|
198
|
+
authServerMetadata = _state.sent();
|
|
199
|
+
if (authServerMetadata) {
|
|
200
|
+
// Successfully discovered full OAuth metadata via RFC 9728 → RFC 8414 chain
|
|
201
|
+
supportsDcr = !!authServerMetadata.registration_endpoint;
|
|
202
|
+
capabilities = {
|
|
203
|
+
supportsDcr: supportsDcr
|
|
204
|
+
};
|
|
205
|
+
if (authServerMetadata.registration_endpoint) {
|
|
206
|
+
capabilities.registrationEndpoint = authServerMetadata.registration_endpoint;
|
|
207
|
+
}
|
|
208
|
+
if (authServerMetadata.authorization_endpoint) {
|
|
209
|
+
capabilities.authorizationEndpoint = authServerMetadata.authorization_endpoint;
|
|
210
|
+
}
|
|
211
|
+
if (authServerMetadata.token_endpoint) capabilities.tokenEndpoint = authServerMetadata.token_endpoint;
|
|
212
|
+
if (authServerMetadata.introspection_endpoint) {
|
|
213
|
+
capabilities.introspectionEndpoint = authServerMetadata.introspection_endpoint;
|
|
214
|
+
}
|
|
215
|
+
// Prefer resource scopes over auth server scopes
|
|
216
|
+
scopes = resourceMetadata.scopes_supported || authServerMetadata.scopes_supported;
|
|
217
|
+
if (scopes) capabilities.scopes = scopes;
|
|
218
|
+
return [
|
|
219
|
+
2,
|
|
220
|
+
capabilities
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
_state.label = 3;
|
|
224
|
+
case 3:
|
|
225
|
+
// Strategy 2: Fall back to direct RFC 8414 discovery at resource origin
|
|
226
|
+
// This handles same-domain OAuth (traditional setup)
|
|
227
|
+
origin = getOrigin(baseUrl);
|
|
228
|
+
return [
|
|
229
|
+
4,
|
|
230
|
+
(0, _rfc9728discoveryts.discoverAuthorizationServerMetadata)(origin)
|
|
231
|
+
];
|
|
232
|
+
case 4:
|
|
233
|
+
authServerMetadata1 = _state.sent();
|
|
234
|
+
if (authServerMetadata1) {
|
|
235
|
+
supportsDcr1 = !!authServerMetadata1.registration_endpoint;
|
|
236
|
+
capabilities1 = {
|
|
237
|
+
supportsDcr: supportsDcr1
|
|
238
|
+
};
|
|
239
|
+
if (authServerMetadata1.registration_endpoint) {
|
|
240
|
+
capabilities1.registrationEndpoint = authServerMetadata1.registration_endpoint;
|
|
241
|
+
}
|
|
242
|
+
if (authServerMetadata1.authorization_endpoint) {
|
|
243
|
+
capabilities1.authorizationEndpoint = authServerMetadata1.authorization_endpoint;
|
|
244
|
+
}
|
|
245
|
+
if (authServerMetadata1.token_endpoint) capabilities1.tokenEndpoint = authServerMetadata1.token_endpoint;
|
|
246
|
+
if (authServerMetadata1.introspection_endpoint) {
|
|
247
|
+
capabilities1.introspectionEndpoint = authServerMetadata1.introspection_endpoint;
|
|
248
|
+
}
|
|
249
|
+
if (authServerMetadata1.scopes_supported) capabilities1.scopes = authServerMetadata1.scopes_supported;
|
|
250
|
+
return [
|
|
251
|
+
2,
|
|
252
|
+
capabilities1
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
// No OAuth metadata found
|
|
256
|
+
return [
|
|
257
|
+
2,
|
|
258
|
+
{
|
|
259
|
+
supportsDcr: false
|
|
260
|
+
}
|
|
261
|
+
];
|
|
262
|
+
case 5:
|
|
263
|
+
_error = _state.sent();
|
|
264
|
+
// Network error, invalid JSON, or other fetch failure
|
|
265
|
+
// Gracefully degrade - assume no DCR support
|
|
266
|
+
return [
|
|
267
|
+
2,
|
|
268
|
+
{
|
|
269
|
+
supportsDcr: false
|
|
270
|
+
}
|
|
271
|
+
];
|
|
272
|
+
case 6:
|
|
273
|
+
return [
|
|
274
|
+
2
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
})();
|
|
279
|
+
}
|
|
280
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/libs/client/src/auth/capability-discovery.ts"],"sourcesContent":["/**\n * OAuth Server Capability Discovery\n * Probes RFC 9728 (Protected Resource) and RFC 8414 (Authorization Server) metadata\n */\n\nimport { discoverAuthorizationServerMetadata, discoverProtectedResourceMetadata } from './rfc9728-discovery.ts';\nimport type { AuthCapabilities } from './types.ts';\n\n/**\n * Extract origin (protocol + host) from a URL\n * @param url - Full URL that may include a path\n * @returns Origin (e.g., \"https://example.com\") or original string if invalid URL\n *\n * @example\n * getOrigin('https://example.com/mcp') // → 'https://example.com'\n * getOrigin('http://localhost:9999/api/v1/mcp') // → 'http://localhost:9999'\n */\nfunction getOrigin(url: string): string {\n try {\n return new URL(url).origin;\n } catch {\n // Invalid URL - return as-is for graceful degradation\n return url;\n }\n}\n\n/**\n * Probe OAuth server capabilities using RFC 9728 → RFC 8414 discovery chain\n * Returns capabilities including DCR support detection\n *\n * Discovery Strategy:\n * 1. Try RFC 9728 Protected Resource Metadata (supports cross-domain OAuth)\n * 2. If found, use first authorization_server to discover RFC 8414 Authorization Server Metadata\n * 3. Fall back to direct RFC 8414 discovery at resource origin\n *\n * @param baseUrl - Base URL of the protected resource (e.g., https://ai.todoist.net/mcp)\n * @returns AuthCapabilities object with discovered endpoints and features\n *\n * @example\n * // Todoist case: MCP at ai.todoist.net/mcp, OAuth at todoist.com\n * const caps = await probeAuthCapabilities('https://ai.todoist.net/mcp');\n * if (caps.supportsDcr) {\n * console.log('Registration endpoint:', caps.registrationEndpoint);\n * }\n */\nexport async function probeAuthCapabilities(baseUrl: string): Promise<AuthCapabilities> {\n try {\n // Strategy 1: Try RFC 9728 Protected Resource Metadata discovery\n // This handles cross-domain OAuth (e.g., Todoist: ai.todoist.net/mcp → todoist.com)\n const resourceMetadata = await discoverProtectedResourceMetadata(baseUrl);\n\n if (resourceMetadata && resourceMetadata.authorization_servers.length > 0) {\n // Found protected resource metadata with authorization servers\n // Discover the authorization server's metadata (RFC 8414)\n const authServerUrl = resourceMetadata.authorization_servers[0];\n if (!authServerUrl) {\n // Array has length > 0 but first element is undefined/null - skip this path\n return { supportsDcr: false };\n }\n const authServerMetadata = await discoverAuthorizationServerMetadata(authServerUrl);\n\n if (authServerMetadata) {\n // Successfully discovered full OAuth metadata via RFC 9728 → RFC 8414 chain\n const supportsDcr = !!authServerMetadata.registration_endpoint;\n const capabilities: AuthCapabilities = { supportsDcr };\n\n if (authServerMetadata.registration_endpoint) {\n capabilities.registrationEndpoint = authServerMetadata.registration_endpoint;\n }\n if (authServerMetadata.authorization_endpoint) {\n capabilities.authorizationEndpoint = authServerMetadata.authorization_endpoint;\n }\n if (authServerMetadata.token_endpoint) capabilities.tokenEndpoint = authServerMetadata.token_endpoint;\n if (authServerMetadata.introspection_endpoint) {\n capabilities.introspectionEndpoint = authServerMetadata.introspection_endpoint;\n }\n\n // Prefer resource scopes over auth server scopes\n const scopes = resourceMetadata.scopes_supported || authServerMetadata.scopes_supported;\n if (scopes) capabilities.scopes = scopes;\n\n return capabilities;\n }\n }\n\n // Strategy 2: Fall back to direct RFC 8414 discovery at resource origin\n // This handles same-domain OAuth (traditional setup)\n const origin = getOrigin(baseUrl);\n const authServerMetadata = await discoverAuthorizationServerMetadata(origin);\n\n if (authServerMetadata) {\n const supportsDcr = !!authServerMetadata.registration_endpoint;\n const capabilities: AuthCapabilities = { supportsDcr };\n\n if (authServerMetadata.registration_endpoint) {\n capabilities.registrationEndpoint = authServerMetadata.registration_endpoint;\n }\n if (authServerMetadata.authorization_endpoint) {\n capabilities.authorizationEndpoint = authServerMetadata.authorization_endpoint;\n }\n if (authServerMetadata.token_endpoint) capabilities.tokenEndpoint = authServerMetadata.token_endpoint;\n if (authServerMetadata.introspection_endpoint) {\n capabilities.introspectionEndpoint = authServerMetadata.introspection_endpoint;\n }\n if (authServerMetadata.scopes_supported) capabilities.scopes = authServerMetadata.scopes_supported;\n\n return capabilities;\n }\n\n // No OAuth metadata found\n return { supportsDcr: false };\n } catch (_error) {\n // Network error, invalid JSON, or other fetch failure\n // Gracefully degrade - assume no DCR support\n return { supportsDcr: false };\n }\n}\n"],"names":["probeAuthCapabilities","getOrigin","url","URL","origin","baseUrl","resourceMetadata","authServerUrl","authServerMetadata","supportsDcr","capabilities","scopes","_error","discoverProtectedResourceMetadata","authorization_servers","length","discoverAuthorizationServerMetadata","registration_endpoint","registrationEndpoint","authorization_endpoint","authorizationEndpoint","token_endpoint","tokenEndpoint","introspection_endpoint","introspectionEndpoint","scopes_supported"],"mappings":"AAAA;;;CAGC;;;;+BA0CqBA;;;eAAAA;;;kCAxCiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvF;;;;;;;;CAQC,GACD,SAASC,UAAUC,GAAW;IAC5B,IAAI;QACF,OAAO,IAAIC,IAAID,KAAKE,MAAM;IAC5B,EAAE,eAAM;QACN,sDAAsD;QACtD,OAAOF;IACT;AACF;AAqBO,SAAeF,sBAAsBK,OAAe;;YAIjDC,kBAKEC,eAKAC,oBAIEC,aACAC,cAcAC,QASJP,QACAI,qBAGEC,cACAC,eAmBDE;;;;;;;;;;oBA9DkB;;wBAAMC,IAAAA,qDAAiC,EAACR;;;oBAA3DC,mBAAmB;yBAErBA,CAAAA,oBAAoBA,iBAAiBQ,qBAAqB,CAACC,MAAM,GAAG,CAAA,GAApET;;;;oBACF,+DAA+D;oBAC/D,0DAA0D;oBACpDC,gBAAgBD,iBAAiBQ,qBAAqB,CAAC,EAAE;oBAC/D,IAAI,CAACP,eAAe;wBAClB,4EAA4E;wBAC5E;;4BAAO;gCAAEE,aAAa;4BAAM;;oBAC9B;oBAC2B;;wBAAMO,IAAAA,uDAAmC,EAACT;;;oBAA/DC,qBAAqB;oBAE3B,IAAIA,oBAAoB;wBACtB,4EAA4E;wBACtEC,cAAc,CAAC,CAACD,mBAAmBS,qBAAqB;wBACxDP,eAAiC;4BAAED,aAAAA;wBAAY;wBAErD,IAAID,mBAAmBS,qBAAqB,EAAE;4BAC5CP,aAAaQ,oBAAoB,GAAGV,mBAAmBS,qBAAqB;wBAC9E;wBACA,IAAIT,mBAAmBW,sBAAsB,EAAE;4BAC7CT,aAAaU,qBAAqB,GAAGZ,mBAAmBW,sBAAsB;wBAChF;wBACA,IAAIX,mBAAmBa,cAAc,EAAEX,aAAaY,aAAa,GAAGd,mBAAmBa,cAAc;wBACrG,IAAIb,mBAAmBe,sBAAsB,EAAE;4BAC7Cb,aAAac,qBAAqB,GAAGhB,mBAAmBe,sBAAsB;wBAChF;wBAEA,iDAAiD;wBAC3CZ,SAASL,iBAAiBmB,gBAAgB,IAAIjB,mBAAmBiB,gBAAgB;wBACvF,IAAId,QAAQD,aAAaC,MAAM,GAAGA;wBAElC;;4BAAOD;;oBACT;;;oBAGF,wEAAwE;oBACxE,qDAAqD;oBAC/CN,SAASH,UAAUI;oBACE;;wBAAMW,IAAAA,uDAAmC,EAACZ;;;oBAA/DI,sBAAqB;oBAE3B,IAAIA,qBAAoB;wBAChBC,eAAc,CAAC,CAACD,oBAAmBS,qBAAqB;wBACxDP,gBAAiC;4BAAED,aAAAA;wBAAY;wBAErD,IAAID,oBAAmBS,qBAAqB,EAAE;4BAC5CP,cAAaQ,oBAAoB,GAAGV,oBAAmBS,qBAAqB;wBAC9E;wBACA,IAAIT,oBAAmBW,sBAAsB,EAAE;4BAC7CT,cAAaU,qBAAqB,GAAGZ,oBAAmBW,sBAAsB;wBAChF;wBACA,IAAIX,oBAAmBa,cAAc,EAAEX,cAAaY,aAAa,GAAGd,oBAAmBa,cAAc;wBACrG,IAAIb,oBAAmBe,sBAAsB,EAAE;4BAC7Cb,cAAac,qBAAqB,GAAGhB,oBAAmBe,sBAAsB;wBAChF;wBACA,IAAIf,oBAAmBiB,gBAAgB,EAAEf,cAAaC,MAAM,GAAGH,oBAAmBiB,gBAAgB;wBAElG;;4BAAOf;;oBACT;oBAEA,0BAA0B;oBAC1B;;wBAAO;4BAAED,aAAa;wBAAM;;;oBACrBG;oBACP,sDAAsD;oBACtD,6CAA6C;oBAC7C;;wBAAO;4BAAEH,aAAa;wBAAM;;;;;;;;IAEhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Module
|
|
3
|
+
* Exports public API for OAuth authentication only (DCR moved to ../dcr/)
|
|
4
|
+
*/
|
|
5
|
+
export { probeAuthCapabilities } from './capability-discovery.js';
|
|
6
|
+
export { InteractiveOAuthFlow } from './interactive-oauth-flow.js';
|
|
7
|
+
export type { OAuthCallbackListenerOptions } from './oauth-callback-listener.js';
|
|
8
|
+
export { OAuthCallbackListener } from './oauth-callback-listener.js';
|
|
9
|
+
export type { AuthCapabilities, CallbackResult, OAuthFlowOptions, TokenSet } from './types.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Module
|
|
3
|
+
* Exports public API for OAuth authentication only (DCR moved to ../dcr/)
|
|
4
|
+
*/
|
|
5
|
+
export { probeAuthCapabilities } from './capability-discovery.js';
|
|
6
|
+
export { InteractiveOAuthFlow } from './interactive-oauth-flow.js';
|
|
7
|
+
export type { OAuthCallbackListenerOptions } from './oauth-callback-listener.js';
|
|
8
|
+
export { OAuthCallbackListener } from './oauth-callback-listener.js';
|
|
9
|
+
export type { AuthCapabilities, CallbackResult, OAuthFlowOptions, TokenSet } from './types.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Module
|
|
3
|
+
* Exports public API for OAuth authentication only (DCR moved to ../dcr/)
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
function _export(target, all) {
|
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_export(exports, {
|
|
15
|
+
get InteractiveOAuthFlow () {
|
|
16
|
+
return _interactiveoauthflowts.InteractiveOAuthFlow;
|
|
17
|
+
},
|
|
18
|
+
get OAuthCallbackListener () {
|
|
19
|
+
return _oauthcallbacklistenerts.OAuthCallbackListener;
|
|
20
|
+
},
|
|
21
|
+
get probeAuthCapabilities () {
|
|
22
|
+
return _capabilitydiscoveryts.probeAuthCapabilities;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var _capabilitydiscoveryts = require("./capability-discovery.js");
|
|
26
|
+
var _interactiveoauthflowts = require("./interactive-oauth-flow.js");
|
|
27
|
+
var _oauthcallbacklistenerts = require("./oauth-callback-listener.js");
|
|
28
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/libs/client/src/auth/index.ts"],"sourcesContent":["/**\n * Authentication Module\n * Exports public API for OAuth authentication only (DCR moved to ../dcr/)\n */\n\nexport { probeAuthCapabilities } from './capability-discovery.ts';\nexport { InteractiveOAuthFlow } from './interactive-oauth-flow.ts';\nexport type { OAuthCallbackListenerOptions } from './oauth-callback-listener.ts';\nexport { OAuthCallbackListener } from './oauth-callback-listener.ts';\nexport type { AuthCapabilities, CallbackResult, OAuthFlowOptions, TokenSet } from './types.ts';\n"],"names":["InteractiveOAuthFlow","OAuthCallbackListener","probeAuthCapabilities"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;QAGQA;eAAAA,4CAAoB;;QAEpBC;eAAAA,8CAAqB;;QAHrBC;eAAAA,4CAAqB;;;qCAAQ;sCACD;uCAEC"}
|