@kya-os/mcp-i-cloudflare 1.6.1 → 1.6.2-canary.clientinfo.20251125192351

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/adapter.d.ts +2 -1
  2. package/dist/adapter.d.ts.map +1 -1
  3. package/dist/adapter.js +14 -2
  4. package/dist/adapter.js.map +1 -1
  5. package/dist/agent.d.ts +6 -0
  6. package/dist/agent.d.ts.map +1 -1
  7. package/dist/agent.js +32 -0
  8. package/dist/agent.js.map +1 -1
  9. package/dist/app.d.ts.map +1 -1
  10. package/dist/app.js +76 -9
  11. package/dist/app.js.map +1 -1
  12. package/dist/utils/client-info.d.ts +69 -0
  13. package/dist/utils/client-info.d.ts.map +1 -0
  14. package/dist/utils/client-info.js +178 -0
  15. package/dist/utils/client-info.js.map +1 -0
  16. package/dist/utils/error-formatter.d.ts +103 -0
  17. package/dist/utils/error-formatter.d.ts.map +1 -0
  18. package/dist/utils/error-formatter.js +245 -0
  19. package/dist/utils/error-formatter.js.map +1 -0
  20. package/dist/utils/initialize-context.d.ts +91 -0
  21. package/dist/utils/initialize-context.d.ts.map +1 -0
  22. package/dist/utils/initialize-context.js +169 -0
  23. package/dist/utils/initialize-context.js.map +1 -0
  24. package/dist/utils/oauth-identity.d.ts +58 -0
  25. package/dist/utils/oauth-identity.d.ts.map +1 -0
  26. package/dist/utils/oauth-identity.js +215 -0
  27. package/dist/utils/oauth-identity.js.map +1 -0
  28. package/package.json +1 -1
  29. package/dist/services/oauth-service.d.ts +0 -66
  30. package/dist/services/oauth-service.d.ts.map +0 -1
  31. package/dist/services/oauth-service.js +0 -223
  32. package/dist/services/oauth-service.js.map +0 -1
  33. package/dist/services/tool-context-builder.d.ts +0 -55
  34. package/dist/services/tool-context-builder.d.ts.map +0 -1
  35. package/dist/services/tool-context-builder.js +0 -124
  36. package/dist/services/tool-context-builder.js.map +0 -1
  37. package/dist/types/tool-context.d.ts +0 -35
  38. package/dist/types/tool-context.d.ts.map +0 -1
  39. package/dist/types/tool-context.js +0 -13
  40. package/dist/types/tool-context.js.map +0 -1
@@ -1,124 +0,0 @@
1
- /**
2
- * Tool Context Builder
3
- *
4
- * Builds ToolExecutionContext for tool handlers by resolving IDP tokens
5
- * based on tool protection configuration and user identity.
6
- *
7
- * @package @kya-os/mcp-i-cloudflare
8
- */
9
- /**
10
- * Builder for tool execution context
11
- *
12
- * Resolves IDP tokens and builds context for tool handlers.
13
- * Phase 1: Uses configured provider as temporary fallback.
14
- * Phase 2+: Requires explicit oauthProvider on tool protection.
15
- */
16
- export class ToolContextBuilder {
17
- config;
18
- constructor(config) {
19
- this.config = {
20
- tokenResolver: config.tokenResolver,
21
- configService: config.configService,
22
- projectId: config.projectId,
23
- logger: config.logger || (() => { }),
24
- };
25
- }
26
- /**
27
- * Build tool execution context
28
- *
29
- * @param toolName - Name of the tool being executed
30
- * @param userDid - User DID (optional, required for OAuth)
31
- * @param sessionId - Session ID (optional)
32
- * @param delegationToken - Delegation token (optional)
33
- * @param toolProtection - Tool protection configuration (optional)
34
- * @returns Tool execution context or undefined if not needed
35
- */
36
- async buildContext(toolName, userDid, sessionId, delegationToken, toolProtection) {
37
- // Only build context if tool requires OAuth
38
- if (!toolProtection?.requiredScopes?.length || !userDid) {
39
- return undefined;
40
- }
41
- // Phase 1: Resolve provider from configured providers
42
- // Phase 1 uses configured provider as temporary fallback
43
- // Phase 2+ requires explicit oauthProvider on tool protection
44
- const provider = await this.resolveProvider(toolProtection);
45
- if (!provider) {
46
- this.config.logger("[ToolContextBuilder] Provider not resolved", {
47
- toolName,
48
- userDid: userDid.substring(0, 20) + "...",
49
- });
50
- return undefined;
51
- }
52
- // Resolve IDP token
53
- const idpToken = await this.config.tokenResolver.resolveTokenFromDid(userDid, provider, toolProtection.requiredScopes);
54
- if (!idpToken) {
55
- // Token not available - will trigger OAuth flow
56
- this.config.logger("[ToolContextBuilder] Token not available", {
57
- toolName,
58
- userDid: userDid.substring(0, 20) + "...",
59
- provider,
60
- scopes: toolProtection.requiredScopes,
61
- });
62
- return undefined;
63
- }
64
- // Build context with token
65
- const context = {
66
- idpToken,
67
- provider,
68
- scopes: toolProtection.requiredScopes,
69
- userDid,
70
- sessionId,
71
- delegationToken,
72
- };
73
- this.config.logger("[ToolContextBuilder] Context built successfully", {
74
- toolName,
75
- userDid: userDid.substring(0, 20) + "...",
76
- provider,
77
- hasToken: !!idpToken,
78
- });
79
- return context;
80
- }
81
- /**
82
- * Resolve OAuth provider for a tool
83
- *
84
- * Phase 1: Uses configured provider from OAuth config as temporary fallback
85
- * Phase 2+: Requires explicit oauthProvider on tool protection
86
- *
87
- * @param toolProtection - Tool protection configuration
88
- * @returns Provider name or null if not found
89
- */
90
- async resolveProvider(toolProtection) {
91
- // Phase 2+: Check for explicit oauthProvider (not yet implemented)
92
- // if (toolProtection.oauthProvider) {
93
- // return toolProtection.oauthProvider;
94
- // }
95
- // Phase 1: Use configured provider from OAuth config as temporary fallback
96
- // Get first configured provider (Phase 1 assumes single provider per project)
97
- try {
98
- const oauthConfig = await this.config.configService.getOAuthConfig(this.config.projectId);
99
- const providers = Object.keys(oauthConfig.providers);
100
- if (providers.length === 0) {
101
- this.config.logger("[ToolContextBuilder] No providers configured", {
102
- projectId: this.config.projectId,
103
- });
104
- return null;
105
- }
106
- // Phase 1: Use first configured provider as fallback
107
- // Phase 2+: This fallback will be removed, tools must specify oauthProvider
108
- const provider = providers[0];
109
- this.config.logger("[ToolContextBuilder] Provider resolved (Phase 1 fallback)", {
110
- provider,
111
- availableProviders: providers,
112
- });
113
- return provider;
114
- }
115
- catch (error) {
116
- this.config.logger("[ToolContextBuilder] Failed to fetch OAuth config", {
117
- error: error instanceof Error ? error.message : String(error),
118
- projectId: this.config.projectId,
119
- });
120
- return null;
121
- }
122
- }
123
- }
124
- //# sourceMappingURL=tool-context-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-context-builder.js","sourceRoot":"","sources":["../../src/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AAC,CAAC,CAAC,CAAC;YAE9B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,2DAA2D,EAAE;gBAC9E,QAAQ;gBACR,kBAAkB,EAAE,SAAS;aAC9B,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mDAAmD,EAAE;gBACtE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC7D,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;aACjC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Tool Execution Context
3
- *
4
- * Execution context passed to tool handlers, enabling tools to access
5
- * IDP tokens for external API calls (GitHub, Google, etc.).
6
- *
7
- * All fields are optional for backward compatibility - tools that don't
8
- * require OAuth will receive undefined context.
9
- *
10
- * @package @kya-os/mcp-i-cloudflare
11
- */
12
- /**
13
- * Execution context passed to tool handlers
14
- *
15
- * Enables tools to access IDP tokens for external API calls.
16
- * Context is only provided when:
17
- * - Tool requires OAuth (has requiredScopes)
18
- * - User DID is available
19
- * - IDP token is successfully resolved
20
- */
21
- export interface ToolExecutionContext {
22
- /** IDP access token for external API calls (e.g., GitHub, Google) */
23
- idpToken?: string;
24
- /** OAuth provider name (e.g., "github", "google") */
25
- provider?: string;
26
- /** Scopes granted for this token */
27
- scopes?: string[];
28
- /** User DID associated with this token */
29
- userDid?: string;
30
- /** Session ID */
31
- sessionId?: string;
32
- /** Delegation token (MCP-I internal authorization) */
33
- delegationToken?: string;
34
- }
35
- //# sourceMappingURL=tool-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-context.d.ts","sourceRoot":"","sources":["../../src/types/tool-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Tool Execution Context
3
- *
4
- * Execution context passed to tool handlers, enabling tools to access
5
- * IDP tokens for external API calls (GitHub, Google, etc.).
6
- *
7
- * All fields are optional for backward compatibility - tools that don't
8
- * require OAuth will receive undefined context.
9
- *
10
- * @package @kya-os/mcp-i-cloudflare
11
- */
12
- export {};
13
- //# sourceMappingURL=tool-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-context.js","sourceRoot":"","sources":["../../src/types/tool-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}