@kya-os/mcp-i 1.7.0 → 1.7.3
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.
|
@@ -3,6 +3,7 @@ import { ZodTypeAny } from "zod";
|
|
|
3
3
|
import { ToolFile } from "./server";
|
|
4
4
|
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { DetachedProof } from "@kya-os/contracts/proof";
|
|
6
|
+
import { type ClientMessagesConfig } from "@kya-os/mcp-i-core";
|
|
6
7
|
export type ZodRawShape = {
|
|
7
8
|
[k: string]: ZodTypeAny;
|
|
8
9
|
};
|
|
@@ -22,4 +23,4 @@ export declare function addToolsToServer(server: McpServer, toolModules: Map<str
|
|
|
22
23
|
environment?: string;
|
|
23
24
|
devIdentityPath?: string;
|
|
24
25
|
privacyMode?: boolean;
|
|
25
|
-
}): Promise<McpServer>;
|
|
26
|
+
}, clientMessagesConfig?: ClientMessagesConfig): Promise<McpServer>;
|
|
@@ -120,7 +120,7 @@ if (typeof global !== "undefined") {
|
|
|
120
120
|
global.__MCPI_HANDLERS_REGISTERED__ || false;
|
|
121
121
|
}
|
|
122
122
|
/** Loads tools and injects them into the server */
|
|
123
|
-
async function addToolsToServer(server, toolModules, identityConfig) {
|
|
123
|
+
async function addToolsToServer(server, toolModules, identityConfig, clientMessagesConfig) {
|
|
124
124
|
// Guard against double registration using global scope
|
|
125
125
|
// Set this IMMEDIATELY to prevent race conditions
|
|
126
126
|
if (typeof global !== "undefined") {
|
|
@@ -491,7 +491,24 @@ async function addToolsToServer(server, toolModules, identityConfig) {
|
|
|
491
491
|
if (identityConfig?.debug) {
|
|
492
492
|
console.error(`[MCPI] Tool "${name}" blocked - authorization required`);
|
|
493
493
|
}
|
|
494
|
+
// Format human-readable message using DelegationErrorFormatter
|
|
495
|
+
// Supports client-specific messages via clientMessagesConfig
|
|
496
|
+
// The formatter may modify the URL (e.g., adding extraParams from config)
|
|
497
|
+
const formatter = new mcp_i_core_1.DelegationErrorFormatter(clientMessagesConfig);
|
|
498
|
+
const { message: displayMessage, consentUrl } = formatter.format({
|
|
499
|
+
toolName: name,
|
|
500
|
+
consentUrl: verifyResult.authError?.authorizationUrl,
|
|
501
|
+
scopes: verifyResult.authError?.scopes,
|
|
502
|
+
// TODO: Client-specific message formatting not yet available for Node.js runtime.
|
|
503
|
+
// The `findKnownClient()` function that maps client names to IDs (claude, chatgpt, etc.)
|
|
504
|
+
// is currently in @kya-os/mcp-i-cloudflare. To enable client-specific messages here,
|
|
505
|
+
// consider moving findKnownClient to @kya-os/mcp-i-core for cross-platform use.
|
|
506
|
+
// See: packages/mcp-i-cloudflare/src/utils/known-clients.ts
|
|
507
|
+
clientId: undefined,
|
|
508
|
+
});
|
|
494
509
|
// Return MCP error format with authorization hints
|
|
510
|
+
// Includes both human-readable displayMessage and structured data
|
|
511
|
+
// Use formatter's consentUrl (may include extraParams) for consistency with displayMessage
|
|
495
512
|
return {
|
|
496
513
|
content: [
|
|
497
514
|
{
|
|
@@ -499,7 +516,8 @@ async function addToolsToServer(server, toolModules, identityConfig) {
|
|
|
499
516
|
text: JSON.stringify({
|
|
500
517
|
error: "needs_authorization",
|
|
501
518
|
message: `Tool "${name}" requires user authorization`,
|
|
502
|
-
|
|
519
|
+
displayMessage, // Human-readable message for clients to display
|
|
520
|
+
authorizationUrl: consentUrl, // Use formatter's URL for consistency
|
|
503
521
|
resumeToken: verifyResult.authError?.resumeToken,
|
|
504
522
|
scopes: verifyResult.authError?.scopes,
|
|
505
523
|
display: verifyResult.authError?.display,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp-i",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "The TypeScript MCP framework with identity features built-in",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"model-context-protocol"
|
|
64
64
|
],
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@kya-os/contracts": "^1.7.
|
|
67
|
-
"@kya-os/mcp-i-core": "^1.4.
|
|
66
|
+
"@kya-os/contracts": "^1.7.6",
|
|
67
|
+
"@kya-os/mcp-i-core": "^1.4.3",
|
|
68
68
|
"@modelcontextprotocol/sdk": "^1.11.4",
|
|
69
69
|
"@swc/core": "^1.11.24",
|
|
70
70
|
"@types/express": "^5.0.1",
|