@kadoa/mcp 0.5.33 → 0.6.0-rc.1
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/README.md +10 -0
- package/dist/index.js +1062 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -376,6 +376,16 @@ KADOA_PUBLIC_API_URI=http://localhost:12380 bun run dev
|
|
|
376
376
|
|
|
377
377
|
The server starts in HTTP mode. You authenticate via OAuth the same way as with the remote server.
|
|
378
378
|
|
|
379
|
+
### HTTP server environment variables
|
|
380
|
+
|
|
381
|
+
Opaque OAuth bearer tokens are routed to the existing OAuth verifier. RS256 Kadoa access tokens (Public API tokens, including delegated Kadoa Assistant tokens) additionally require:
|
|
382
|
+
|
|
383
|
+
| Variable | Description | If unset |
|
|
384
|
+
|---|---|---|
|
|
385
|
+
| `MCP_AUTH_ISSUER` | Issuer of Public API RS256 access tokens, `https://api.kadoa.com/v5/auth` | RS256 bearers rejected |
|
|
386
|
+
| `MCP_AUTH_JWKS_URL` | JWKS of that issuer, `https://api.kadoa.com/v5/auth/.well-known/jwks.json` | RS256 bearers rejected |
|
|
387
|
+
| `MCP_AUTH_AUDIENCE` | This pod's exact resource URL, e.g. `https://beta.mcp.kadoa.com/mcp` — must match the pod actually serving the request; a value copied from another pod's config cross-accepts that pod's tokens | RS256 bearers rejected |
|
|
388
|
+
|
|
379
389
|
## Contributing
|
|
380
390
|
|
|
381
391
|
A typical feature touches three repos — **`kadoa-backend` → `kadoa-sdks` → `kadoa-mcp`**. The same surgery on three layers; same operation, different audience above it.
|
package/dist/index.js
CHANGED
|
@@ -19875,6 +19875,803 @@ var init_mcp = __esm(() => {
|
|
|
19875
19875
|
};
|
|
19876
19876
|
});
|
|
19877
19877
|
|
|
19878
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
19879
|
+
var RELATED_TASK_META_KEY2 = "io.modelcontextprotocol/related-task", JSONRPC_VERSION2 = "2.0", AssertObjectSchema2, ProgressTokenSchema2, CursorSchema2, TaskCreationParamsSchema2, TaskMetadataSchema2, RelatedTaskMetadataSchema2, RequestMetaSchema2, BaseRequestParamsSchema2, TaskAugmentedRequestParamsSchema2, RequestSchema2, NotificationsParamsSchema2, NotificationSchema2, ResultSchema2, RequestIdSchema2, JSONRPCRequestSchema2, JSONRPCNotificationSchema2, JSONRPCResultResponseSchema2, ErrorCode2, JSONRPCErrorResponseSchema2, JSONRPCMessageSchema2, JSONRPCResponseSchema2, EmptyResultSchema2, CancelledNotificationParamsSchema2, CancelledNotificationSchema2, IconSchema2, IconsSchema2, BaseMetadataSchema2, ImplementationSchema2, FormElicitationCapabilitySchema2, ElicitationCapabilitySchema2, ClientTasksCapabilitySchema2, ServerTasksCapabilitySchema2, ClientCapabilitiesSchema2, InitializeRequestParamsSchema2, InitializeRequestSchema2, ServerCapabilitiesSchema2, InitializeResultSchema2, InitializedNotificationSchema2, PingRequestSchema2, ProgressSchema2, ProgressNotificationParamsSchema2, ProgressNotificationSchema2, PaginatedRequestParamsSchema2, PaginatedRequestSchema2, PaginatedResultSchema2, TaskStatusSchema2, TaskSchema2, CreateTaskResultSchema2, TaskStatusNotificationParamsSchema2, TaskStatusNotificationSchema2, GetTaskRequestSchema2, GetTaskResultSchema2, GetTaskPayloadRequestSchema2, GetTaskPayloadResultSchema2, ListTasksRequestSchema2, ListTasksResultSchema2, CancelTaskRequestSchema2, CancelTaskResultSchema2, ResourceContentsSchema2, TextResourceContentsSchema2, Base64Schema2, BlobResourceContentsSchema2, RoleSchema2, AnnotationsSchema2, ResourceSchema2, ResourceTemplateSchema2, ListResourcesRequestSchema2, ListResourcesResultSchema2, ListResourceTemplatesRequestSchema2, ListResourceTemplatesResultSchema2, ResourceRequestParamsSchema2, ReadResourceRequestParamsSchema2, ReadResourceRequestSchema2, ReadResourceResultSchema2, ResourceListChangedNotificationSchema2, SubscribeRequestParamsSchema2, SubscribeRequestSchema2, UnsubscribeRequestParamsSchema2, UnsubscribeRequestSchema2, ResourceUpdatedNotificationParamsSchema2, ResourceUpdatedNotificationSchema2, PromptArgumentSchema2, PromptSchema2, ListPromptsRequestSchema2, ListPromptsResultSchema2, GetPromptRequestParamsSchema2, GetPromptRequestSchema2, TextContentSchema2, ImageContentSchema2, AudioContentSchema2, ToolUseContentSchema2, EmbeddedResourceSchema2, ResourceLinkSchema2, ContentBlockSchema2, PromptMessageSchema2, GetPromptResultSchema2, PromptListChangedNotificationSchema2, ToolAnnotationsSchema2, ToolExecutionSchema2, ToolSchema2, ListToolsRequestSchema2, ListToolsResultSchema2, CallToolResultSchema2, CompatibilityCallToolResultSchema2, CallToolRequestParamsSchema2, CallToolRequestSchema2, ToolListChangedNotificationSchema2, ListChangedOptionsBaseSchema2, LoggingLevelSchema2, SetLevelRequestParamsSchema2, SetLevelRequestSchema2, LoggingMessageNotificationParamsSchema2, LoggingMessageNotificationSchema2, ModelHintSchema2, ModelPreferencesSchema2, ToolChoiceSchema2, ToolResultContentSchema2, SamplingContentSchema2, SamplingMessageContentBlockSchema2, SamplingMessageSchema2, CreateMessageRequestParamsSchema2, CreateMessageRequestSchema2, CreateMessageResultSchema2, CreateMessageResultWithToolsSchema2, BooleanSchemaSchema2, StringSchemaSchema2, NumberSchemaSchema2, UntitledSingleSelectEnumSchemaSchema2, TitledSingleSelectEnumSchemaSchema2, LegacyTitledEnumSchemaSchema2, SingleSelectEnumSchemaSchema2, UntitledMultiSelectEnumSchemaSchema2, TitledMultiSelectEnumSchemaSchema2, MultiSelectEnumSchemaSchema2, EnumSchemaSchema2, PrimitiveSchemaDefinitionSchema2, ElicitRequestFormParamsSchema2, ElicitRequestURLParamsSchema2, ElicitRequestParamsSchema2, ElicitRequestSchema2, ElicitationCompleteNotificationParamsSchema2, ElicitationCompleteNotificationSchema2, ElicitResultSchema2, ResourceTemplateReferenceSchema2, PromptReferenceSchema2, CompleteRequestParamsSchema2, CompleteRequestSchema2, CompleteResultSchema2, RootSchema2, ListRootsRequestSchema2, ListRootsResultSchema2, RootsListChangedNotificationSchema2, ClientRequestSchema2, ClientNotificationSchema2, ClientResultSchema2, ServerRequestSchema2, ServerNotificationSchema2, ServerResultSchema2;
|
|
19880
|
+
var init_types3 = __esm(() => {
|
|
19881
|
+
init_v4();
|
|
19882
|
+
AssertObjectSchema2 = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
19883
|
+
ProgressTokenSchema2 = union([string2(), number2().int()]);
|
|
19884
|
+
CursorSchema2 = string2();
|
|
19885
|
+
TaskCreationParamsSchema2 = looseObject({
|
|
19886
|
+
ttl: union([number2(), _null3()]).optional(),
|
|
19887
|
+
pollInterval: number2().optional()
|
|
19888
|
+
});
|
|
19889
|
+
TaskMetadataSchema2 = object2({
|
|
19890
|
+
ttl: number2().optional()
|
|
19891
|
+
});
|
|
19892
|
+
RelatedTaskMetadataSchema2 = object2({
|
|
19893
|
+
taskId: string2()
|
|
19894
|
+
});
|
|
19895
|
+
RequestMetaSchema2 = looseObject({
|
|
19896
|
+
progressToken: ProgressTokenSchema2.optional(),
|
|
19897
|
+
[RELATED_TASK_META_KEY2]: RelatedTaskMetadataSchema2.optional()
|
|
19898
|
+
});
|
|
19899
|
+
BaseRequestParamsSchema2 = object2({
|
|
19900
|
+
_meta: RequestMetaSchema2.optional()
|
|
19901
|
+
});
|
|
19902
|
+
TaskAugmentedRequestParamsSchema2 = BaseRequestParamsSchema2.extend({
|
|
19903
|
+
task: TaskMetadataSchema2.optional()
|
|
19904
|
+
});
|
|
19905
|
+
RequestSchema2 = object2({
|
|
19906
|
+
method: string2(),
|
|
19907
|
+
params: BaseRequestParamsSchema2.loose().optional()
|
|
19908
|
+
});
|
|
19909
|
+
NotificationsParamsSchema2 = object2({
|
|
19910
|
+
_meta: RequestMetaSchema2.optional()
|
|
19911
|
+
});
|
|
19912
|
+
NotificationSchema2 = object2({
|
|
19913
|
+
method: string2(),
|
|
19914
|
+
params: NotificationsParamsSchema2.loose().optional()
|
|
19915
|
+
});
|
|
19916
|
+
ResultSchema2 = looseObject({
|
|
19917
|
+
_meta: RequestMetaSchema2.optional()
|
|
19918
|
+
});
|
|
19919
|
+
RequestIdSchema2 = union([string2(), number2().int()]);
|
|
19920
|
+
JSONRPCRequestSchema2 = object2({
|
|
19921
|
+
jsonrpc: literal(JSONRPC_VERSION2),
|
|
19922
|
+
id: RequestIdSchema2,
|
|
19923
|
+
...RequestSchema2.shape
|
|
19924
|
+
}).strict();
|
|
19925
|
+
JSONRPCNotificationSchema2 = object2({
|
|
19926
|
+
jsonrpc: literal(JSONRPC_VERSION2),
|
|
19927
|
+
...NotificationSchema2.shape
|
|
19928
|
+
}).strict();
|
|
19929
|
+
JSONRPCResultResponseSchema2 = object2({
|
|
19930
|
+
jsonrpc: literal(JSONRPC_VERSION2),
|
|
19931
|
+
id: RequestIdSchema2,
|
|
19932
|
+
result: ResultSchema2
|
|
19933
|
+
}).strict();
|
|
19934
|
+
(function(ErrorCode) {
|
|
19935
|
+
ErrorCode[ErrorCode["ConnectionClosed"] = -32000] = "ConnectionClosed";
|
|
19936
|
+
ErrorCode[ErrorCode["RequestTimeout"] = -32001] = "RequestTimeout";
|
|
19937
|
+
ErrorCode[ErrorCode["ParseError"] = -32700] = "ParseError";
|
|
19938
|
+
ErrorCode[ErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
19939
|
+
ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
19940
|
+
ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
19941
|
+
ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
|
|
19942
|
+
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
19943
|
+
})(ErrorCode2 || (ErrorCode2 = {}));
|
|
19944
|
+
JSONRPCErrorResponseSchema2 = object2({
|
|
19945
|
+
jsonrpc: literal(JSONRPC_VERSION2),
|
|
19946
|
+
id: RequestIdSchema2.optional(),
|
|
19947
|
+
error: object2({
|
|
19948
|
+
code: number2().int(),
|
|
19949
|
+
message: string2(),
|
|
19950
|
+
data: unknown().optional()
|
|
19951
|
+
})
|
|
19952
|
+
}).strict();
|
|
19953
|
+
JSONRPCMessageSchema2 = union([
|
|
19954
|
+
JSONRPCRequestSchema2,
|
|
19955
|
+
JSONRPCNotificationSchema2,
|
|
19956
|
+
JSONRPCResultResponseSchema2,
|
|
19957
|
+
JSONRPCErrorResponseSchema2
|
|
19958
|
+
]);
|
|
19959
|
+
JSONRPCResponseSchema2 = union([JSONRPCResultResponseSchema2, JSONRPCErrorResponseSchema2]);
|
|
19960
|
+
EmptyResultSchema2 = ResultSchema2.strict();
|
|
19961
|
+
CancelledNotificationParamsSchema2 = NotificationsParamsSchema2.extend({
|
|
19962
|
+
requestId: RequestIdSchema2.optional(),
|
|
19963
|
+
reason: string2().optional()
|
|
19964
|
+
});
|
|
19965
|
+
CancelledNotificationSchema2 = NotificationSchema2.extend({
|
|
19966
|
+
method: literal("notifications/cancelled"),
|
|
19967
|
+
params: CancelledNotificationParamsSchema2
|
|
19968
|
+
});
|
|
19969
|
+
IconSchema2 = object2({
|
|
19970
|
+
src: string2(),
|
|
19971
|
+
mimeType: string2().optional(),
|
|
19972
|
+
sizes: array(string2()).optional(),
|
|
19973
|
+
theme: _enum(["light", "dark"]).optional()
|
|
19974
|
+
});
|
|
19975
|
+
IconsSchema2 = object2({
|
|
19976
|
+
icons: array(IconSchema2).optional()
|
|
19977
|
+
});
|
|
19978
|
+
BaseMetadataSchema2 = object2({
|
|
19979
|
+
name: string2(),
|
|
19980
|
+
title: string2().optional()
|
|
19981
|
+
});
|
|
19982
|
+
ImplementationSchema2 = BaseMetadataSchema2.extend({
|
|
19983
|
+
...BaseMetadataSchema2.shape,
|
|
19984
|
+
...IconsSchema2.shape,
|
|
19985
|
+
version: string2(),
|
|
19986
|
+
websiteUrl: string2().optional(),
|
|
19987
|
+
description: string2().optional()
|
|
19988
|
+
});
|
|
19989
|
+
FormElicitationCapabilitySchema2 = intersection(object2({
|
|
19990
|
+
applyDefaults: boolean2().optional()
|
|
19991
|
+
}), record(string2(), unknown()));
|
|
19992
|
+
ElicitationCapabilitySchema2 = preprocess((value) => {
|
|
19993
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
19994
|
+
if (Object.keys(value).length === 0) {
|
|
19995
|
+
return { form: {} };
|
|
19996
|
+
}
|
|
19997
|
+
}
|
|
19998
|
+
return value;
|
|
19999
|
+
}, intersection(object2({
|
|
20000
|
+
form: FormElicitationCapabilitySchema2.optional(),
|
|
20001
|
+
url: AssertObjectSchema2.optional()
|
|
20002
|
+
}), record(string2(), unknown()).optional()));
|
|
20003
|
+
ClientTasksCapabilitySchema2 = looseObject({
|
|
20004
|
+
list: AssertObjectSchema2.optional(),
|
|
20005
|
+
cancel: AssertObjectSchema2.optional(),
|
|
20006
|
+
requests: looseObject({
|
|
20007
|
+
sampling: looseObject({
|
|
20008
|
+
createMessage: AssertObjectSchema2.optional()
|
|
20009
|
+
}).optional(),
|
|
20010
|
+
elicitation: looseObject({
|
|
20011
|
+
create: AssertObjectSchema2.optional()
|
|
20012
|
+
}).optional()
|
|
20013
|
+
}).optional()
|
|
20014
|
+
});
|
|
20015
|
+
ServerTasksCapabilitySchema2 = looseObject({
|
|
20016
|
+
list: AssertObjectSchema2.optional(),
|
|
20017
|
+
cancel: AssertObjectSchema2.optional(),
|
|
20018
|
+
requests: looseObject({
|
|
20019
|
+
tools: looseObject({
|
|
20020
|
+
call: AssertObjectSchema2.optional()
|
|
20021
|
+
}).optional()
|
|
20022
|
+
}).optional()
|
|
20023
|
+
});
|
|
20024
|
+
ClientCapabilitiesSchema2 = object2({
|
|
20025
|
+
experimental: record(string2(), AssertObjectSchema2).optional(),
|
|
20026
|
+
sampling: object2({
|
|
20027
|
+
context: AssertObjectSchema2.optional(),
|
|
20028
|
+
tools: AssertObjectSchema2.optional()
|
|
20029
|
+
}).optional(),
|
|
20030
|
+
elicitation: ElicitationCapabilitySchema2.optional(),
|
|
20031
|
+
roots: object2({
|
|
20032
|
+
listChanged: boolean2().optional()
|
|
20033
|
+
}).optional(),
|
|
20034
|
+
tasks: ClientTasksCapabilitySchema2.optional()
|
|
20035
|
+
});
|
|
20036
|
+
InitializeRequestParamsSchema2 = BaseRequestParamsSchema2.extend({
|
|
20037
|
+
protocolVersion: string2(),
|
|
20038
|
+
capabilities: ClientCapabilitiesSchema2,
|
|
20039
|
+
clientInfo: ImplementationSchema2
|
|
20040
|
+
});
|
|
20041
|
+
InitializeRequestSchema2 = RequestSchema2.extend({
|
|
20042
|
+
method: literal("initialize"),
|
|
20043
|
+
params: InitializeRequestParamsSchema2
|
|
20044
|
+
});
|
|
20045
|
+
ServerCapabilitiesSchema2 = object2({
|
|
20046
|
+
experimental: record(string2(), AssertObjectSchema2).optional(),
|
|
20047
|
+
logging: AssertObjectSchema2.optional(),
|
|
20048
|
+
completions: AssertObjectSchema2.optional(),
|
|
20049
|
+
prompts: object2({
|
|
20050
|
+
listChanged: boolean2().optional()
|
|
20051
|
+
}).optional(),
|
|
20052
|
+
resources: object2({
|
|
20053
|
+
subscribe: boolean2().optional(),
|
|
20054
|
+
listChanged: boolean2().optional()
|
|
20055
|
+
}).optional(),
|
|
20056
|
+
tools: object2({
|
|
20057
|
+
listChanged: boolean2().optional()
|
|
20058
|
+
}).optional(),
|
|
20059
|
+
tasks: ServerTasksCapabilitySchema2.optional()
|
|
20060
|
+
});
|
|
20061
|
+
InitializeResultSchema2 = ResultSchema2.extend({
|
|
20062
|
+
protocolVersion: string2(),
|
|
20063
|
+
capabilities: ServerCapabilitiesSchema2,
|
|
20064
|
+
serverInfo: ImplementationSchema2,
|
|
20065
|
+
instructions: string2().optional()
|
|
20066
|
+
});
|
|
20067
|
+
InitializedNotificationSchema2 = NotificationSchema2.extend({
|
|
20068
|
+
method: literal("notifications/initialized"),
|
|
20069
|
+
params: NotificationsParamsSchema2.optional()
|
|
20070
|
+
});
|
|
20071
|
+
PingRequestSchema2 = RequestSchema2.extend({
|
|
20072
|
+
method: literal("ping"),
|
|
20073
|
+
params: BaseRequestParamsSchema2.optional()
|
|
20074
|
+
});
|
|
20075
|
+
ProgressSchema2 = object2({
|
|
20076
|
+
progress: number2(),
|
|
20077
|
+
total: optional(number2()),
|
|
20078
|
+
message: optional(string2())
|
|
20079
|
+
});
|
|
20080
|
+
ProgressNotificationParamsSchema2 = object2({
|
|
20081
|
+
...NotificationsParamsSchema2.shape,
|
|
20082
|
+
...ProgressSchema2.shape,
|
|
20083
|
+
progressToken: ProgressTokenSchema2
|
|
20084
|
+
});
|
|
20085
|
+
ProgressNotificationSchema2 = NotificationSchema2.extend({
|
|
20086
|
+
method: literal("notifications/progress"),
|
|
20087
|
+
params: ProgressNotificationParamsSchema2
|
|
20088
|
+
});
|
|
20089
|
+
PaginatedRequestParamsSchema2 = BaseRequestParamsSchema2.extend({
|
|
20090
|
+
cursor: CursorSchema2.optional()
|
|
20091
|
+
});
|
|
20092
|
+
PaginatedRequestSchema2 = RequestSchema2.extend({
|
|
20093
|
+
params: PaginatedRequestParamsSchema2.optional()
|
|
20094
|
+
});
|
|
20095
|
+
PaginatedResultSchema2 = ResultSchema2.extend({
|
|
20096
|
+
nextCursor: CursorSchema2.optional()
|
|
20097
|
+
});
|
|
20098
|
+
TaskStatusSchema2 = _enum(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
20099
|
+
TaskSchema2 = object2({
|
|
20100
|
+
taskId: string2(),
|
|
20101
|
+
status: TaskStatusSchema2,
|
|
20102
|
+
ttl: union([number2(), _null3()]),
|
|
20103
|
+
createdAt: string2(),
|
|
20104
|
+
lastUpdatedAt: string2(),
|
|
20105
|
+
pollInterval: optional(number2()),
|
|
20106
|
+
statusMessage: optional(string2())
|
|
20107
|
+
});
|
|
20108
|
+
CreateTaskResultSchema2 = ResultSchema2.extend({
|
|
20109
|
+
task: TaskSchema2
|
|
20110
|
+
});
|
|
20111
|
+
TaskStatusNotificationParamsSchema2 = NotificationsParamsSchema2.merge(TaskSchema2);
|
|
20112
|
+
TaskStatusNotificationSchema2 = NotificationSchema2.extend({
|
|
20113
|
+
method: literal("notifications/tasks/status"),
|
|
20114
|
+
params: TaskStatusNotificationParamsSchema2
|
|
20115
|
+
});
|
|
20116
|
+
GetTaskRequestSchema2 = RequestSchema2.extend({
|
|
20117
|
+
method: literal("tasks/get"),
|
|
20118
|
+
params: BaseRequestParamsSchema2.extend({
|
|
20119
|
+
taskId: string2()
|
|
20120
|
+
})
|
|
20121
|
+
});
|
|
20122
|
+
GetTaskResultSchema2 = ResultSchema2.merge(TaskSchema2);
|
|
20123
|
+
GetTaskPayloadRequestSchema2 = RequestSchema2.extend({
|
|
20124
|
+
method: literal("tasks/result"),
|
|
20125
|
+
params: BaseRequestParamsSchema2.extend({
|
|
20126
|
+
taskId: string2()
|
|
20127
|
+
})
|
|
20128
|
+
});
|
|
20129
|
+
GetTaskPayloadResultSchema2 = ResultSchema2.loose();
|
|
20130
|
+
ListTasksRequestSchema2 = PaginatedRequestSchema2.extend({
|
|
20131
|
+
method: literal("tasks/list")
|
|
20132
|
+
});
|
|
20133
|
+
ListTasksResultSchema2 = PaginatedResultSchema2.extend({
|
|
20134
|
+
tasks: array(TaskSchema2)
|
|
20135
|
+
});
|
|
20136
|
+
CancelTaskRequestSchema2 = RequestSchema2.extend({
|
|
20137
|
+
method: literal("tasks/cancel"),
|
|
20138
|
+
params: BaseRequestParamsSchema2.extend({
|
|
20139
|
+
taskId: string2()
|
|
20140
|
+
})
|
|
20141
|
+
});
|
|
20142
|
+
CancelTaskResultSchema2 = ResultSchema2.merge(TaskSchema2);
|
|
20143
|
+
ResourceContentsSchema2 = object2({
|
|
20144
|
+
uri: string2(),
|
|
20145
|
+
mimeType: optional(string2()),
|
|
20146
|
+
_meta: record(string2(), unknown()).optional()
|
|
20147
|
+
});
|
|
20148
|
+
TextResourceContentsSchema2 = ResourceContentsSchema2.extend({
|
|
20149
|
+
text: string2()
|
|
20150
|
+
});
|
|
20151
|
+
Base64Schema2 = string2().refine((val) => {
|
|
20152
|
+
try {
|
|
20153
|
+
atob(val);
|
|
20154
|
+
return true;
|
|
20155
|
+
} catch {
|
|
20156
|
+
return false;
|
|
20157
|
+
}
|
|
20158
|
+
}, { message: "Invalid Base64 string" });
|
|
20159
|
+
BlobResourceContentsSchema2 = ResourceContentsSchema2.extend({
|
|
20160
|
+
blob: Base64Schema2
|
|
20161
|
+
});
|
|
20162
|
+
RoleSchema2 = _enum(["user", "assistant"]);
|
|
20163
|
+
AnnotationsSchema2 = object2({
|
|
20164
|
+
audience: array(RoleSchema2).optional(),
|
|
20165
|
+
priority: number2().min(0).max(1).optional(),
|
|
20166
|
+
lastModified: datetime2({ offset: true }).optional()
|
|
20167
|
+
});
|
|
20168
|
+
ResourceSchema2 = object2({
|
|
20169
|
+
...BaseMetadataSchema2.shape,
|
|
20170
|
+
...IconsSchema2.shape,
|
|
20171
|
+
uri: string2(),
|
|
20172
|
+
description: optional(string2()),
|
|
20173
|
+
mimeType: optional(string2()),
|
|
20174
|
+
annotations: AnnotationsSchema2.optional(),
|
|
20175
|
+
_meta: optional(looseObject({}))
|
|
20176
|
+
});
|
|
20177
|
+
ResourceTemplateSchema2 = object2({
|
|
20178
|
+
...BaseMetadataSchema2.shape,
|
|
20179
|
+
...IconsSchema2.shape,
|
|
20180
|
+
uriTemplate: string2(),
|
|
20181
|
+
description: optional(string2()),
|
|
20182
|
+
mimeType: optional(string2()),
|
|
20183
|
+
annotations: AnnotationsSchema2.optional(),
|
|
20184
|
+
_meta: optional(looseObject({}))
|
|
20185
|
+
});
|
|
20186
|
+
ListResourcesRequestSchema2 = PaginatedRequestSchema2.extend({
|
|
20187
|
+
method: literal("resources/list")
|
|
20188
|
+
});
|
|
20189
|
+
ListResourcesResultSchema2 = PaginatedResultSchema2.extend({
|
|
20190
|
+
resources: array(ResourceSchema2)
|
|
20191
|
+
});
|
|
20192
|
+
ListResourceTemplatesRequestSchema2 = PaginatedRequestSchema2.extend({
|
|
20193
|
+
method: literal("resources/templates/list")
|
|
20194
|
+
});
|
|
20195
|
+
ListResourceTemplatesResultSchema2 = PaginatedResultSchema2.extend({
|
|
20196
|
+
resourceTemplates: array(ResourceTemplateSchema2)
|
|
20197
|
+
});
|
|
20198
|
+
ResourceRequestParamsSchema2 = BaseRequestParamsSchema2.extend({
|
|
20199
|
+
uri: string2()
|
|
20200
|
+
});
|
|
20201
|
+
ReadResourceRequestParamsSchema2 = ResourceRequestParamsSchema2;
|
|
20202
|
+
ReadResourceRequestSchema2 = RequestSchema2.extend({
|
|
20203
|
+
method: literal("resources/read"),
|
|
20204
|
+
params: ReadResourceRequestParamsSchema2
|
|
20205
|
+
});
|
|
20206
|
+
ReadResourceResultSchema2 = ResultSchema2.extend({
|
|
20207
|
+
contents: array(union([TextResourceContentsSchema2, BlobResourceContentsSchema2]))
|
|
20208
|
+
});
|
|
20209
|
+
ResourceListChangedNotificationSchema2 = NotificationSchema2.extend({
|
|
20210
|
+
method: literal("notifications/resources/list_changed"),
|
|
20211
|
+
params: NotificationsParamsSchema2.optional()
|
|
20212
|
+
});
|
|
20213
|
+
SubscribeRequestParamsSchema2 = ResourceRequestParamsSchema2;
|
|
20214
|
+
SubscribeRequestSchema2 = RequestSchema2.extend({
|
|
20215
|
+
method: literal("resources/subscribe"),
|
|
20216
|
+
params: SubscribeRequestParamsSchema2
|
|
20217
|
+
});
|
|
20218
|
+
UnsubscribeRequestParamsSchema2 = ResourceRequestParamsSchema2;
|
|
20219
|
+
UnsubscribeRequestSchema2 = RequestSchema2.extend({
|
|
20220
|
+
method: literal("resources/unsubscribe"),
|
|
20221
|
+
params: UnsubscribeRequestParamsSchema2
|
|
20222
|
+
});
|
|
20223
|
+
ResourceUpdatedNotificationParamsSchema2 = NotificationsParamsSchema2.extend({
|
|
20224
|
+
uri: string2()
|
|
20225
|
+
});
|
|
20226
|
+
ResourceUpdatedNotificationSchema2 = NotificationSchema2.extend({
|
|
20227
|
+
method: literal("notifications/resources/updated"),
|
|
20228
|
+
params: ResourceUpdatedNotificationParamsSchema2
|
|
20229
|
+
});
|
|
20230
|
+
PromptArgumentSchema2 = object2({
|
|
20231
|
+
name: string2(),
|
|
20232
|
+
description: optional(string2()),
|
|
20233
|
+
required: optional(boolean2())
|
|
20234
|
+
});
|
|
20235
|
+
PromptSchema2 = object2({
|
|
20236
|
+
...BaseMetadataSchema2.shape,
|
|
20237
|
+
...IconsSchema2.shape,
|
|
20238
|
+
description: optional(string2()),
|
|
20239
|
+
arguments: optional(array(PromptArgumentSchema2)),
|
|
20240
|
+
_meta: optional(looseObject({}))
|
|
20241
|
+
});
|
|
20242
|
+
ListPromptsRequestSchema2 = PaginatedRequestSchema2.extend({
|
|
20243
|
+
method: literal("prompts/list")
|
|
20244
|
+
});
|
|
20245
|
+
ListPromptsResultSchema2 = PaginatedResultSchema2.extend({
|
|
20246
|
+
prompts: array(PromptSchema2)
|
|
20247
|
+
});
|
|
20248
|
+
GetPromptRequestParamsSchema2 = BaseRequestParamsSchema2.extend({
|
|
20249
|
+
name: string2(),
|
|
20250
|
+
arguments: record(string2(), string2()).optional()
|
|
20251
|
+
});
|
|
20252
|
+
GetPromptRequestSchema2 = RequestSchema2.extend({
|
|
20253
|
+
method: literal("prompts/get"),
|
|
20254
|
+
params: GetPromptRequestParamsSchema2
|
|
20255
|
+
});
|
|
20256
|
+
TextContentSchema2 = object2({
|
|
20257
|
+
type: literal("text"),
|
|
20258
|
+
text: string2(),
|
|
20259
|
+
annotations: AnnotationsSchema2.optional(),
|
|
20260
|
+
_meta: record(string2(), unknown()).optional()
|
|
20261
|
+
});
|
|
20262
|
+
ImageContentSchema2 = object2({
|
|
20263
|
+
type: literal("image"),
|
|
20264
|
+
data: Base64Schema2,
|
|
20265
|
+
mimeType: string2(),
|
|
20266
|
+
annotations: AnnotationsSchema2.optional(),
|
|
20267
|
+
_meta: record(string2(), unknown()).optional()
|
|
20268
|
+
});
|
|
20269
|
+
AudioContentSchema2 = object2({
|
|
20270
|
+
type: literal("audio"),
|
|
20271
|
+
data: Base64Schema2,
|
|
20272
|
+
mimeType: string2(),
|
|
20273
|
+
annotations: AnnotationsSchema2.optional(),
|
|
20274
|
+
_meta: record(string2(), unknown()).optional()
|
|
20275
|
+
});
|
|
20276
|
+
ToolUseContentSchema2 = object2({
|
|
20277
|
+
type: literal("tool_use"),
|
|
20278
|
+
name: string2(),
|
|
20279
|
+
id: string2(),
|
|
20280
|
+
input: record(string2(), unknown()),
|
|
20281
|
+
_meta: record(string2(), unknown()).optional()
|
|
20282
|
+
});
|
|
20283
|
+
EmbeddedResourceSchema2 = object2({
|
|
20284
|
+
type: literal("resource"),
|
|
20285
|
+
resource: union([TextResourceContentsSchema2, BlobResourceContentsSchema2]),
|
|
20286
|
+
annotations: AnnotationsSchema2.optional(),
|
|
20287
|
+
_meta: record(string2(), unknown()).optional()
|
|
20288
|
+
});
|
|
20289
|
+
ResourceLinkSchema2 = ResourceSchema2.extend({
|
|
20290
|
+
type: literal("resource_link")
|
|
20291
|
+
});
|
|
20292
|
+
ContentBlockSchema2 = union([
|
|
20293
|
+
TextContentSchema2,
|
|
20294
|
+
ImageContentSchema2,
|
|
20295
|
+
AudioContentSchema2,
|
|
20296
|
+
ResourceLinkSchema2,
|
|
20297
|
+
EmbeddedResourceSchema2
|
|
20298
|
+
]);
|
|
20299
|
+
PromptMessageSchema2 = object2({
|
|
20300
|
+
role: RoleSchema2,
|
|
20301
|
+
content: ContentBlockSchema2
|
|
20302
|
+
});
|
|
20303
|
+
GetPromptResultSchema2 = ResultSchema2.extend({
|
|
20304
|
+
description: string2().optional(),
|
|
20305
|
+
messages: array(PromptMessageSchema2)
|
|
20306
|
+
});
|
|
20307
|
+
PromptListChangedNotificationSchema2 = NotificationSchema2.extend({
|
|
20308
|
+
method: literal("notifications/prompts/list_changed"),
|
|
20309
|
+
params: NotificationsParamsSchema2.optional()
|
|
20310
|
+
});
|
|
20311
|
+
ToolAnnotationsSchema2 = object2({
|
|
20312
|
+
title: string2().optional(),
|
|
20313
|
+
readOnlyHint: boolean2().optional(),
|
|
20314
|
+
destructiveHint: boolean2().optional(),
|
|
20315
|
+
idempotentHint: boolean2().optional(),
|
|
20316
|
+
openWorldHint: boolean2().optional()
|
|
20317
|
+
});
|
|
20318
|
+
ToolExecutionSchema2 = object2({
|
|
20319
|
+
taskSupport: _enum(["required", "optional", "forbidden"]).optional()
|
|
20320
|
+
});
|
|
20321
|
+
ToolSchema2 = object2({
|
|
20322
|
+
...BaseMetadataSchema2.shape,
|
|
20323
|
+
...IconsSchema2.shape,
|
|
20324
|
+
description: string2().optional(),
|
|
20325
|
+
inputSchema: object2({
|
|
20326
|
+
type: literal("object"),
|
|
20327
|
+
properties: record(string2(), AssertObjectSchema2).optional(),
|
|
20328
|
+
required: array(string2()).optional()
|
|
20329
|
+
}).catchall(unknown()),
|
|
20330
|
+
outputSchema: object2({
|
|
20331
|
+
type: literal("object"),
|
|
20332
|
+
properties: record(string2(), AssertObjectSchema2).optional(),
|
|
20333
|
+
required: array(string2()).optional()
|
|
20334
|
+
}).catchall(unknown()).optional(),
|
|
20335
|
+
annotations: ToolAnnotationsSchema2.optional(),
|
|
20336
|
+
execution: ToolExecutionSchema2.optional(),
|
|
20337
|
+
_meta: record(string2(), unknown()).optional()
|
|
20338
|
+
});
|
|
20339
|
+
ListToolsRequestSchema2 = PaginatedRequestSchema2.extend({
|
|
20340
|
+
method: literal("tools/list")
|
|
20341
|
+
});
|
|
20342
|
+
ListToolsResultSchema2 = PaginatedResultSchema2.extend({
|
|
20343
|
+
tools: array(ToolSchema2)
|
|
20344
|
+
});
|
|
20345
|
+
CallToolResultSchema2 = ResultSchema2.extend({
|
|
20346
|
+
content: array(ContentBlockSchema2).default([]),
|
|
20347
|
+
structuredContent: record(string2(), unknown()).optional(),
|
|
20348
|
+
isError: boolean2().optional()
|
|
20349
|
+
});
|
|
20350
|
+
CompatibilityCallToolResultSchema2 = CallToolResultSchema2.or(ResultSchema2.extend({
|
|
20351
|
+
toolResult: unknown()
|
|
20352
|
+
}));
|
|
20353
|
+
CallToolRequestParamsSchema2 = TaskAugmentedRequestParamsSchema2.extend({
|
|
20354
|
+
name: string2(),
|
|
20355
|
+
arguments: record(string2(), unknown()).optional()
|
|
20356
|
+
});
|
|
20357
|
+
CallToolRequestSchema2 = RequestSchema2.extend({
|
|
20358
|
+
method: literal("tools/call"),
|
|
20359
|
+
params: CallToolRequestParamsSchema2
|
|
20360
|
+
});
|
|
20361
|
+
ToolListChangedNotificationSchema2 = NotificationSchema2.extend({
|
|
20362
|
+
method: literal("notifications/tools/list_changed"),
|
|
20363
|
+
params: NotificationsParamsSchema2.optional()
|
|
20364
|
+
});
|
|
20365
|
+
ListChangedOptionsBaseSchema2 = object2({
|
|
20366
|
+
autoRefresh: boolean2().default(true),
|
|
20367
|
+
debounceMs: number2().int().nonnegative().default(300)
|
|
20368
|
+
});
|
|
20369
|
+
LoggingLevelSchema2 = _enum(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
20370
|
+
SetLevelRequestParamsSchema2 = BaseRequestParamsSchema2.extend({
|
|
20371
|
+
level: LoggingLevelSchema2
|
|
20372
|
+
});
|
|
20373
|
+
SetLevelRequestSchema2 = RequestSchema2.extend({
|
|
20374
|
+
method: literal("logging/setLevel"),
|
|
20375
|
+
params: SetLevelRequestParamsSchema2
|
|
20376
|
+
});
|
|
20377
|
+
LoggingMessageNotificationParamsSchema2 = NotificationsParamsSchema2.extend({
|
|
20378
|
+
level: LoggingLevelSchema2,
|
|
20379
|
+
logger: string2().optional(),
|
|
20380
|
+
data: unknown()
|
|
20381
|
+
});
|
|
20382
|
+
LoggingMessageNotificationSchema2 = NotificationSchema2.extend({
|
|
20383
|
+
method: literal("notifications/message"),
|
|
20384
|
+
params: LoggingMessageNotificationParamsSchema2
|
|
20385
|
+
});
|
|
20386
|
+
ModelHintSchema2 = object2({
|
|
20387
|
+
name: string2().optional()
|
|
20388
|
+
});
|
|
20389
|
+
ModelPreferencesSchema2 = object2({
|
|
20390
|
+
hints: array(ModelHintSchema2).optional(),
|
|
20391
|
+
costPriority: number2().min(0).max(1).optional(),
|
|
20392
|
+
speedPriority: number2().min(0).max(1).optional(),
|
|
20393
|
+
intelligencePriority: number2().min(0).max(1).optional()
|
|
20394
|
+
});
|
|
20395
|
+
ToolChoiceSchema2 = object2({
|
|
20396
|
+
mode: _enum(["auto", "required", "none"]).optional()
|
|
20397
|
+
});
|
|
20398
|
+
ToolResultContentSchema2 = object2({
|
|
20399
|
+
type: literal("tool_result"),
|
|
20400
|
+
toolUseId: string2().describe("The unique identifier for the corresponding tool call."),
|
|
20401
|
+
content: array(ContentBlockSchema2).default([]),
|
|
20402
|
+
structuredContent: object2({}).loose().optional(),
|
|
20403
|
+
isError: boolean2().optional(),
|
|
20404
|
+
_meta: record(string2(), unknown()).optional()
|
|
20405
|
+
});
|
|
20406
|
+
SamplingContentSchema2 = discriminatedUnion("type", [TextContentSchema2, ImageContentSchema2, AudioContentSchema2]);
|
|
20407
|
+
SamplingMessageContentBlockSchema2 = discriminatedUnion("type", [
|
|
20408
|
+
TextContentSchema2,
|
|
20409
|
+
ImageContentSchema2,
|
|
20410
|
+
AudioContentSchema2,
|
|
20411
|
+
ToolUseContentSchema2,
|
|
20412
|
+
ToolResultContentSchema2
|
|
20413
|
+
]);
|
|
20414
|
+
SamplingMessageSchema2 = object2({
|
|
20415
|
+
role: RoleSchema2,
|
|
20416
|
+
content: union([SamplingMessageContentBlockSchema2, array(SamplingMessageContentBlockSchema2)]),
|
|
20417
|
+
_meta: record(string2(), unknown()).optional()
|
|
20418
|
+
});
|
|
20419
|
+
CreateMessageRequestParamsSchema2 = TaskAugmentedRequestParamsSchema2.extend({
|
|
20420
|
+
messages: array(SamplingMessageSchema2),
|
|
20421
|
+
modelPreferences: ModelPreferencesSchema2.optional(),
|
|
20422
|
+
systemPrompt: string2().optional(),
|
|
20423
|
+
includeContext: _enum(["none", "thisServer", "allServers"]).optional(),
|
|
20424
|
+
temperature: number2().optional(),
|
|
20425
|
+
maxTokens: number2().int(),
|
|
20426
|
+
stopSequences: array(string2()).optional(),
|
|
20427
|
+
metadata: AssertObjectSchema2.optional(),
|
|
20428
|
+
tools: array(ToolSchema2).optional(),
|
|
20429
|
+
toolChoice: ToolChoiceSchema2.optional()
|
|
20430
|
+
});
|
|
20431
|
+
CreateMessageRequestSchema2 = RequestSchema2.extend({
|
|
20432
|
+
method: literal("sampling/createMessage"),
|
|
20433
|
+
params: CreateMessageRequestParamsSchema2
|
|
20434
|
+
});
|
|
20435
|
+
CreateMessageResultSchema2 = ResultSchema2.extend({
|
|
20436
|
+
model: string2(),
|
|
20437
|
+
stopReason: optional(_enum(["endTurn", "stopSequence", "maxTokens"]).or(string2())),
|
|
20438
|
+
role: RoleSchema2,
|
|
20439
|
+
content: SamplingContentSchema2
|
|
20440
|
+
});
|
|
20441
|
+
CreateMessageResultWithToolsSchema2 = ResultSchema2.extend({
|
|
20442
|
+
model: string2(),
|
|
20443
|
+
stopReason: optional(_enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string2())),
|
|
20444
|
+
role: RoleSchema2,
|
|
20445
|
+
content: union([SamplingMessageContentBlockSchema2, array(SamplingMessageContentBlockSchema2)])
|
|
20446
|
+
});
|
|
20447
|
+
BooleanSchemaSchema2 = object2({
|
|
20448
|
+
type: literal("boolean"),
|
|
20449
|
+
title: string2().optional(),
|
|
20450
|
+
description: string2().optional(),
|
|
20451
|
+
default: boolean2().optional()
|
|
20452
|
+
});
|
|
20453
|
+
StringSchemaSchema2 = object2({
|
|
20454
|
+
type: literal("string"),
|
|
20455
|
+
title: string2().optional(),
|
|
20456
|
+
description: string2().optional(),
|
|
20457
|
+
minLength: number2().optional(),
|
|
20458
|
+
maxLength: number2().optional(),
|
|
20459
|
+
format: _enum(["email", "uri", "date", "date-time"]).optional(),
|
|
20460
|
+
default: string2().optional()
|
|
20461
|
+
});
|
|
20462
|
+
NumberSchemaSchema2 = object2({
|
|
20463
|
+
type: _enum(["number", "integer"]),
|
|
20464
|
+
title: string2().optional(),
|
|
20465
|
+
description: string2().optional(),
|
|
20466
|
+
minimum: number2().optional(),
|
|
20467
|
+
maximum: number2().optional(),
|
|
20468
|
+
default: number2().optional()
|
|
20469
|
+
});
|
|
20470
|
+
UntitledSingleSelectEnumSchemaSchema2 = object2({
|
|
20471
|
+
type: literal("string"),
|
|
20472
|
+
title: string2().optional(),
|
|
20473
|
+
description: string2().optional(),
|
|
20474
|
+
enum: array(string2()),
|
|
20475
|
+
default: string2().optional()
|
|
20476
|
+
});
|
|
20477
|
+
TitledSingleSelectEnumSchemaSchema2 = object2({
|
|
20478
|
+
type: literal("string"),
|
|
20479
|
+
title: string2().optional(),
|
|
20480
|
+
description: string2().optional(),
|
|
20481
|
+
oneOf: array(object2({
|
|
20482
|
+
const: string2(),
|
|
20483
|
+
title: string2()
|
|
20484
|
+
})),
|
|
20485
|
+
default: string2().optional()
|
|
20486
|
+
});
|
|
20487
|
+
LegacyTitledEnumSchemaSchema2 = object2({
|
|
20488
|
+
type: literal("string"),
|
|
20489
|
+
title: string2().optional(),
|
|
20490
|
+
description: string2().optional(),
|
|
20491
|
+
enum: array(string2()),
|
|
20492
|
+
enumNames: array(string2()).optional(),
|
|
20493
|
+
default: string2().optional()
|
|
20494
|
+
});
|
|
20495
|
+
SingleSelectEnumSchemaSchema2 = union([UntitledSingleSelectEnumSchemaSchema2, TitledSingleSelectEnumSchemaSchema2]);
|
|
20496
|
+
UntitledMultiSelectEnumSchemaSchema2 = object2({
|
|
20497
|
+
type: literal("array"),
|
|
20498
|
+
title: string2().optional(),
|
|
20499
|
+
description: string2().optional(),
|
|
20500
|
+
minItems: number2().optional(),
|
|
20501
|
+
maxItems: number2().optional(),
|
|
20502
|
+
items: object2({
|
|
20503
|
+
type: literal("string"),
|
|
20504
|
+
enum: array(string2())
|
|
20505
|
+
}),
|
|
20506
|
+
default: array(string2()).optional()
|
|
20507
|
+
});
|
|
20508
|
+
TitledMultiSelectEnumSchemaSchema2 = object2({
|
|
20509
|
+
type: literal("array"),
|
|
20510
|
+
title: string2().optional(),
|
|
20511
|
+
description: string2().optional(),
|
|
20512
|
+
minItems: number2().optional(),
|
|
20513
|
+
maxItems: number2().optional(),
|
|
20514
|
+
items: object2({
|
|
20515
|
+
anyOf: array(object2({
|
|
20516
|
+
const: string2(),
|
|
20517
|
+
title: string2()
|
|
20518
|
+
}))
|
|
20519
|
+
}),
|
|
20520
|
+
default: array(string2()).optional()
|
|
20521
|
+
});
|
|
20522
|
+
MultiSelectEnumSchemaSchema2 = union([UntitledMultiSelectEnumSchemaSchema2, TitledMultiSelectEnumSchemaSchema2]);
|
|
20523
|
+
EnumSchemaSchema2 = union([LegacyTitledEnumSchemaSchema2, SingleSelectEnumSchemaSchema2, MultiSelectEnumSchemaSchema2]);
|
|
20524
|
+
PrimitiveSchemaDefinitionSchema2 = union([EnumSchemaSchema2, BooleanSchemaSchema2, StringSchemaSchema2, NumberSchemaSchema2]);
|
|
20525
|
+
ElicitRequestFormParamsSchema2 = TaskAugmentedRequestParamsSchema2.extend({
|
|
20526
|
+
mode: literal("form").optional(),
|
|
20527
|
+
message: string2(),
|
|
20528
|
+
requestedSchema: object2({
|
|
20529
|
+
type: literal("object"),
|
|
20530
|
+
properties: record(string2(), PrimitiveSchemaDefinitionSchema2),
|
|
20531
|
+
required: array(string2()).optional()
|
|
20532
|
+
})
|
|
20533
|
+
});
|
|
20534
|
+
ElicitRequestURLParamsSchema2 = TaskAugmentedRequestParamsSchema2.extend({
|
|
20535
|
+
mode: literal("url"),
|
|
20536
|
+
message: string2(),
|
|
20537
|
+
elicitationId: string2(),
|
|
20538
|
+
url: string2().url()
|
|
20539
|
+
});
|
|
20540
|
+
ElicitRequestParamsSchema2 = union([ElicitRequestFormParamsSchema2, ElicitRequestURLParamsSchema2]);
|
|
20541
|
+
ElicitRequestSchema2 = RequestSchema2.extend({
|
|
20542
|
+
method: literal("elicitation/create"),
|
|
20543
|
+
params: ElicitRequestParamsSchema2
|
|
20544
|
+
});
|
|
20545
|
+
ElicitationCompleteNotificationParamsSchema2 = NotificationsParamsSchema2.extend({
|
|
20546
|
+
elicitationId: string2()
|
|
20547
|
+
});
|
|
20548
|
+
ElicitationCompleteNotificationSchema2 = NotificationSchema2.extend({
|
|
20549
|
+
method: literal("notifications/elicitation/complete"),
|
|
20550
|
+
params: ElicitationCompleteNotificationParamsSchema2
|
|
20551
|
+
});
|
|
20552
|
+
ElicitResultSchema2 = ResultSchema2.extend({
|
|
20553
|
+
action: _enum(["accept", "decline", "cancel"]),
|
|
20554
|
+
content: preprocess((val) => val === null ? undefined : val, record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional())
|
|
20555
|
+
});
|
|
20556
|
+
ResourceTemplateReferenceSchema2 = object2({
|
|
20557
|
+
type: literal("ref/resource"),
|
|
20558
|
+
uri: string2()
|
|
20559
|
+
});
|
|
20560
|
+
PromptReferenceSchema2 = object2({
|
|
20561
|
+
type: literal("ref/prompt"),
|
|
20562
|
+
name: string2()
|
|
20563
|
+
});
|
|
20564
|
+
CompleteRequestParamsSchema2 = BaseRequestParamsSchema2.extend({
|
|
20565
|
+
ref: union([PromptReferenceSchema2, ResourceTemplateReferenceSchema2]),
|
|
20566
|
+
argument: object2({
|
|
20567
|
+
name: string2(),
|
|
20568
|
+
value: string2()
|
|
20569
|
+
}),
|
|
20570
|
+
context: object2({
|
|
20571
|
+
arguments: record(string2(), string2()).optional()
|
|
20572
|
+
}).optional()
|
|
20573
|
+
});
|
|
20574
|
+
CompleteRequestSchema2 = RequestSchema2.extend({
|
|
20575
|
+
method: literal("completion/complete"),
|
|
20576
|
+
params: CompleteRequestParamsSchema2
|
|
20577
|
+
});
|
|
20578
|
+
CompleteResultSchema2 = ResultSchema2.extend({
|
|
20579
|
+
completion: looseObject({
|
|
20580
|
+
values: array(string2()).max(100),
|
|
20581
|
+
total: optional(number2().int()),
|
|
20582
|
+
hasMore: optional(boolean2())
|
|
20583
|
+
})
|
|
20584
|
+
});
|
|
20585
|
+
RootSchema2 = object2({
|
|
20586
|
+
uri: string2().startsWith("file://"),
|
|
20587
|
+
name: string2().optional(),
|
|
20588
|
+
_meta: record(string2(), unknown()).optional()
|
|
20589
|
+
});
|
|
20590
|
+
ListRootsRequestSchema2 = RequestSchema2.extend({
|
|
20591
|
+
method: literal("roots/list"),
|
|
20592
|
+
params: BaseRequestParamsSchema2.optional()
|
|
20593
|
+
});
|
|
20594
|
+
ListRootsResultSchema2 = ResultSchema2.extend({
|
|
20595
|
+
roots: array(RootSchema2)
|
|
20596
|
+
});
|
|
20597
|
+
RootsListChangedNotificationSchema2 = NotificationSchema2.extend({
|
|
20598
|
+
method: literal("notifications/roots/list_changed"),
|
|
20599
|
+
params: NotificationsParamsSchema2.optional()
|
|
20600
|
+
});
|
|
20601
|
+
ClientRequestSchema2 = union([
|
|
20602
|
+
PingRequestSchema2,
|
|
20603
|
+
InitializeRequestSchema2,
|
|
20604
|
+
CompleteRequestSchema2,
|
|
20605
|
+
SetLevelRequestSchema2,
|
|
20606
|
+
GetPromptRequestSchema2,
|
|
20607
|
+
ListPromptsRequestSchema2,
|
|
20608
|
+
ListResourcesRequestSchema2,
|
|
20609
|
+
ListResourceTemplatesRequestSchema2,
|
|
20610
|
+
ReadResourceRequestSchema2,
|
|
20611
|
+
SubscribeRequestSchema2,
|
|
20612
|
+
UnsubscribeRequestSchema2,
|
|
20613
|
+
CallToolRequestSchema2,
|
|
20614
|
+
ListToolsRequestSchema2,
|
|
20615
|
+
GetTaskRequestSchema2,
|
|
20616
|
+
GetTaskPayloadRequestSchema2,
|
|
20617
|
+
ListTasksRequestSchema2,
|
|
20618
|
+
CancelTaskRequestSchema2
|
|
20619
|
+
]);
|
|
20620
|
+
ClientNotificationSchema2 = union([
|
|
20621
|
+
CancelledNotificationSchema2,
|
|
20622
|
+
ProgressNotificationSchema2,
|
|
20623
|
+
InitializedNotificationSchema2,
|
|
20624
|
+
RootsListChangedNotificationSchema2,
|
|
20625
|
+
TaskStatusNotificationSchema2
|
|
20626
|
+
]);
|
|
20627
|
+
ClientResultSchema2 = union([
|
|
20628
|
+
EmptyResultSchema2,
|
|
20629
|
+
CreateMessageResultSchema2,
|
|
20630
|
+
CreateMessageResultWithToolsSchema2,
|
|
20631
|
+
ElicitResultSchema2,
|
|
20632
|
+
ListRootsResultSchema2,
|
|
20633
|
+
GetTaskResultSchema2,
|
|
20634
|
+
ListTasksResultSchema2,
|
|
20635
|
+
CreateTaskResultSchema2
|
|
20636
|
+
]);
|
|
20637
|
+
ServerRequestSchema2 = union([
|
|
20638
|
+
PingRequestSchema2,
|
|
20639
|
+
CreateMessageRequestSchema2,
|
|
20640
|
+
ElicitRequestSchema2,
|
|
20641
|
+
ListRootsRequestSchema2,
|
|
20642
|
+
GetTaskRequestSchema2,
|
|
20643
|
+
GetTaskPayloadRequestSchema2,
|
|
20644
|
+
ListTasksRequestSchema2,
|
|
20645
|
+
CancelTaskRequestSchema2
|
|
20646
|
+
]);
|
|
20647
|
+
ServerNotificationSchema2 = union([
|
|
20648
|
+
CancelledNotificationSchema2,
|
|
20649
|
+
ProgressNotificationSchema2,
|
|
20650
|
+
LoggingMessageNotificationSchema2,
|
|
20651
|
+
ResourceUpdatedNotificationSchema2,
|
|
20652
|
+
ResourceListChangedNotificationSchema2,
|
|
20653
|
+
ToolListChangedNotificationSchema2,
|
|
20654
|
+
PromptListChangedNotificationSchema2,
|
|
20655
|
+
TaskStatusNotificationSchema2,
|
|
20656
|
+
ElicitationCompleteNotificationSchema2
|
|
20657
|
+
]);
|
|
20658
|
+
ServerResultSchema2 = union([
|
|
20659
|
+
EmptyResultSchema2,
|
|
20660
|
+
InitializeResultSchema2,
|
|
20661
|
+
CompleteResultSchema2,
|
|
20662
|
+
GetPromptResultSchema2,
|
|
20663
|
+
ListPromptsResultSchema2,
|
|
20664
|
+
ListResourcesResultSchema2,
|
|
20665
|
+
ListResourceTemplatesResultSchema2,
|
|
20666
|
+
ReadResourceResultSchema2,
|
|
20667
|
+
CallToolResultSchema2,
|
|
20668
|
+
ListToolsResultSchema2,
|
|
20669
|
+
GetTaskResultSchema2,
|
|
20670
|
+
ListTasksResultSchema2,
|
|
20671
|
+
CreateTaskResultSchema2
|
|
20672
|
+
]);
|
|
20673
|
+
});
|
|
20674
|
+
|
|
19878
20675
|
// node_modules/axios/lib/helpers/bind.js
|
|
19879
20676
|
function bind(fn, thisArg) {
|
|
19880
20677
|
return function wrap() {
|
|
@@ -43741,7 +44538,7 @@ function isScrapeRequest(url) {
|
|
|
43741
44538
|
function createKadoaClient(auth) {
|
|
43742
44539
|
const { principal } = auth;
|
|
43743
44540
|
const client = new KadoaClient({
|
|
43744
|
-
bearerToken: principal.type === "user" ? principal.supabaseJwt : principal.kadoaAccessToken
|
|
44541
|
+
bearerToken: principal.type === "user" ? principal.supabaseJwt : principal.type === "kadoa" ? principal.accessToken : principal.kadoaAccessToken
|
|
43745
44542
|
});
|
|
43746
44543
|
client.axiosInstance.interceptors.request.use((config) => {
|
|
43747
44544
|
config.headers["x-kadoa-source"] = "mcp";
|
|
@@ -44274,6 +45071,16 @@ function registerTools(server, ctx, capabilities) {
|
|
|
44274
45071
|
teamId: ctx.principal.teamId
|
|
44275
45072
|
});
|
|
44276
45073
|
}
|
|
45074
|
+
if (ctx.principal.type === "kadoa") {
|
|
45075
|
+
const user = await ctx.client.user.getCurrentUser();
|
|
45076
|
+
return jsonResult({
|
|
45077
|
+
email: user.email,
|
|
45078
|
+
authMethod: ctx.principal.actor ? `Kadoa Assistant (delegated via ${ctx.principal.actor.sub})` : "Kadoa access token",
|
|
45079
|
+
teamId: ctx.principal.teamId,
|
|
45080
|
+
...ctx.principal.teamRole ? { memberRole: ctx.principal.teamRole } : {},
|
|
45081
|
+
scopes: ctx.principal.scopes
|
|
45082
|
+
});
|
|
45083
|
+
}
|
|
44277
45084
|
const jwt = await getValidJwt(ctx);
|
|
44278
45085
|
const user = await ctx.client.user.getCurrentUser();
|
|
44279
45086
|
const teams = await ctx.client.listTeams(jwt ? { bearerToken: jwt } : undefined);
|
|
@@ -45577,6 +46384,13 @@ function registerTools(server, ctx, capabilities) {
|
|
|
45577
46384
|
activeTeamId: ctx.principal.teamId
|
|
45578
46385
|
});
|
|
45579
46386
|
}
|
|
46387
|
+
if (ctx.principal.type === "kadoa") {
|
|
46388
|
+
return jsonResult({
|
|
46389
|
+
teams: [{ id: ctx.principal.teamId, active: true }],
|
|
46390
|
+
activeTeamId: ctx.principal.teamId,
|
|
46391
|
+
note: "Team is fixed for this credential; reconnect to switch."
|
|
46392
|
+
});
|
|
46393
|
+
}
|
|
45580
46394
|
const jwt = await getValidJwt(ctx);
|
|
45581
46395
|
const teams = await ctx.client.listTeams(jwt ? { bearerToken: jwt } : undefined);
|
|
45582
46396
|
const activeTeamId = ctx.teamId ?? teams[0]?.id;
|
|
@@ -45601,6 +46415,9 @@ function registerTools(server, ctx, capabilities) {
|
|
|
45601
46415
|
if (ctx.principal.type === "serviceAccount") {
|
|
45602
46416
|
return errorResult("This shared organization connector is fixed to one team and cannot switch teams.");
|
|
45603
46417
|
}
|
|
46418
|
+
if (ctx.principal.type === "kadoa") {
|
|
46419
|
+
return errorResult("team_switch is not available for this credential. Reconnect and choose the team at sign-in.");
|
|
46420
|
+
}
|
|
45604
46421
|
const jwt = await getValidJwt(ctx);
|
|
45605
46422
|
const teams = await ctx.client.listTeams({ bearerToken: jwt });
|
|
45606
46423
|
const identifier = args.teamIdentifier;
|
|
@@ -46194,7 +47011,7 @@ var package_default;
|
|
|
46194
47011
|
var init_package = __esm(() => {
|
|
46195
47012
|
package_default = {
|
|
46196
47013
|
name: "@kadoa/mcp",
|
|
46197
|
-
version: "0.
|
|
47014
|
+
version: "0.6.0-rc.1",
|
|
46198
47015
|
description: "Kadoa MCP Server — manage workflows from Claude Desktop, Cursor, and other MCP clients",
|
|
46199
47016
|
type: "module",
|
|
46200
47017
|
main: "dist/index.js",
|
|
@@ -50308,8 +51125,12 @@ function randomToken(bytes = 32) {
|
|
|
50308
51125
|
return randomBytes(bytes).toString("hex");
|
|
50309
51126
|
}
|
|
50310
51127
|
function readPrincipal(entry) {
|
|
50311
|
-
if (entry.principal)
|
|
51128
|
+
if (entry.principal) {
|
|
51129
|
+
if (entry.principal.type === "kadoa") {
|
|
51130
|
+
throw new InvalidTokenError("Stored token has no valid principal");
|
|
51131
|
+
}
|
|
50312
51132
|
return entry.principal;
|
|
51133
|
+
}
|
|
50313
51134
|
if (entry.supabaseJwt && entry.supabaseRefreshToken) {
|
|
50314
51135
|
return {
|
|
50315
51136
|
type: "user",
|
|
@@ -50321,6 +51142,9 @@ function readPrincipal(entry) {
|
|
|
50321
51142
|
throw new InvalidTokenError("Stored token has no valid principal");
|
|
50322
51143
|
}
|
|
50323
51144
|
function persistPrincipal(principal) {
|
|
51145
|
+
if (principal.type === "kadoa") {
|
|
51146
|
+
throw new InvalidTokenError("Stored token has no valid principal");
|
|
51147
|
+
}
|
|
50324
51148
|
if (principal.type === "serviceAccount") {
|
|
50325
51149
|
return { principal, teamId: principal.teamId };
|
|
50326
51150
|
}
|
|
@@ -50746,6 +51570,9 @@ class KadoaOAuthProvider {
|
|
|
50746
51570
|
const persistedEntry = entry;
|
|
50747
51571
|
await this.store.del("refresh_tokens", refreshToken);
|
|
50748
51572
|
const storedPrincipal = readPrincipal(persistedEntry);
|
|
51573
|
+
if (storedPrincipal.type === "kadoa") {
|
|
51574
|
+
throw new InvalidTokenError("Stored token has no valid principal");
|
|
51575
|
+
}
|
|
50749
51576
|
if (storedPrincipal.type === "serviceAccount") {
|
|
50750
51577
|
const newAccessToken = randomToken();
|
|
50751
51578
|
const newRefreshToken = randomToken();
|
|
@@ -51547,6 +52374,179 @@ var init_managed_token_handler = __esm(() => {
|
|
|
51547
52374
|
init_managed_connector_registry();
|
|
51548
52375
|
});
|
|
51549
52376
|
|
|
52377
|
+
// src/kadoa-access-token.ts
|
|
52378
|
+
import { createPublicKey, verify } from "node:crypto";
|
|
52379
|
+
function loadKadoaAccessTokenVerifierConfig(env = process.env) {
|
|
52380
|
+
const issuer = env.MCP_AUTH_ISSUER?.trim();
|
|
52381
|
+
const jwksUrl = env.MCP_AUTH_JWKS_URL?.trim();
|
|
52382
|
+
const audience = env.MCP_AUTH_AUDIENCE?.trim();
|
|
52383
|
+
if (!issuer || !jwksUrl || !audience)
|
|
52384
|
+
return;
|
|
52385
|
+
return { issuer, jwksUrl, audience };
|
|
52386
|
+
}
|
|
52387
|
+
function decodeSegment(segment, label) {
|
|
52388
|
+
try {
|
|
52389
|
+
const value = JSON.parse(Buffer.from(segment, "base64url").toString("utf8"));
|
|
52390
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
52391
|
+
throw new Error("not an object");
|
|
52392
|
+
return value;
|
|
52393
|
+
} catch {
|
|
52394
|
+
throw new KadoaAccessTokenError(`Kadoa access token ${label} is malformed`);
|
|
52395
|
+
}
|
|
52396
|
+
}
|
|
52397
|
+
function isJwtShaped(token) {
|
|
52398
|
+
const parts = token.split(".");
|
|
52399
|
+
if (parts.length !== 3 || parts.some((part) => !part))
|
|
52400
|
+
return false;
|
|
52401
|
+
try {
|
|
52402
|
+
const header = decodeSegment(parts[0], "header");
|
|
52403
|
+
return header.alg === "RS256";
|
|
52404
|
+
} catch {
|
|
52405
|
+
return false;
|
|
52406
|
+
}
|
|
52407
|
+
}
|
|
52408
|
+
|
|
52409
|
+
class KadoaAccessTokenVerifier {
|
|
52410
|
+
config;
|
|
52411
|
+
keys = new Map;
|
|
52412
|
+
fetchedAt = 0;
|
|
52413
|
+
lastUnknownKidRefetchAt = 0;
|
|
52414
|
+
inFlightRefresh;
|
|
52415
|
+
fetchImpl;
|
|
52416
|
+
cacheTtlMs;
|
|
52417
|
+
now;
|
|
52418
|
+
constructor(config, options = {}) {
|
|
52419
|
+
this.config = config;
|
|
52420
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
52421
|
+
this.cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
52422
|
+
this.now = options.now ?? (() => Date.now());
|
|
52423
|
+
}
|
|
52424
|
+
refreshKeys() {
|
|
52425
|
+
if (this.inFlightRefresh)
|
|
52426
|
+
return this.inFlightRefresh;
|
|
52427
|
+
const run = this.doRefreshKeys().finally(() => {
|
|
52428
|
+
this.inFlightRefresh = undefined;
|
|
52429
|
+
});
|
|
52430
|
+
this.inFlightRefresh = run;
|
|
52431
|
+
return run;
|
|
52432
|
+
}
|
|
52433
|
+
async doRefreshKeys() {
|
|
52434
|
+
let response;
|
|
52435
|
+
try {
|
|
52436
|
+
response = await this.fetchImpl(this.config.jwksUrl, { signal: AbortSignal.timeout(JWKS_FETCH_TIMEOUT_MS) });
|
|
52437
|
+
} catch (error) {
|
|
52438
|
+
if (error instanceof Error && error.name === "TimeoutError") {
|
|
52439
|
+
throw new KadoaAccessTokenError("JWKS fetch timed out");
|
|
52440
|
+
}
|
|
52441
|
+
throw new KadoaAccessTokenError(`JWKS fetch failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
52442
|
+
}
|
|
52443
|
+
if (!response.ok)
|
|
52444
|
+
throw new KadoaAccessTokenError(`JWKS fetch returned HTTP ${response.status}`);
|
|
52445
|
+
const body = await response.json();
|
|
52446
|
+
if (!Array.isArray(body.keys))
|
|
52447
|
+
throw new KadoaAccessTokenError("JWKS response has no keys");
|
|
52448
|
+
const next = new Map;
|
|
52449
|
+
for (const key of body.keys) {
|
|
52450
|
+
if (typeof key.kid !== "string" || key.kty !== "RSA")
|
|
52451
|
+
continue;
|
|
52452
|
+
if (key.use !== undefined && key.use !== "sig")
|
|
52453
|
+
continue;
|
|
52454
|
+
if (key.alg !== undefined && key.alg !== "RS256")
|
|
52455
|
+
continue;
|
|
52456
|
+
try {
|
|
52457
|
+
next.set(key.kid, createPublicKey({ key, format: "jwk" }));
|
|
52458
|
+
} catch {}
|
|
52459
|
+
}
|
|
52460
|
+
this.keys = next;
|
|
52461
|
+
this.fetchedAt = this.now();
|
|
52462
|
+
}
|
|
52463
|
+
async keyFor(kid) {
|
|
52464
|
+
const stale = this.now() - this.fetchedAt > this.cacheTtlMs;
|
|
52465
|
+
if (stale || this.keys.size === 0)
|
|
52466
|
+
await this.refreshKeys();
|
|
52467
|
+
let key = this.keys.get(kid);
|
|
52468
|
+
if (!key && !stale) {
|
|
52469
|
+
const nowMs = this.now();
|
|
52470
|
+
if (nowMs - this.lastUnknownKidRefetchAt >= UNKNOWN_KID_REFETCH_INTERVAL_MS) {
|
|
52471
|
+
this.lastUnknownKidRefetchAt = nowMs;
|
|
52472
|
+
await this.refreshKeys();
|
|
52473
|
+
key = this.keys.get(kid);
|
|
52474
|
+
}
|
|
52475
|
+
}
|
|
52476
|
+
if (!key)
|
|
52477
|
+
throw new KadoaAccessTokenError("Kadoa access token signing key is not recognized");
|
|
52478
|
+
return key;
|
|
52479
|
+
}
|
|
52480
|
+
async verify(token) {
|
|
52481
|
+
const parts = token.split(".");
|
|
52482
|
+
if (parts.length !== 3 || parts.some((part) => !part))
|
|
52483
|
+
throw new KadoaAccessTokenError("Kadoa access token is malformed");
|
|
52484
|
+
const header = decodeSegment(parts[0], "header");
|
|
52485
|
+
if (header.alg !== "RS256")
|
|
52486
|
+
throw new KadoaAccessTokenError("Kadoa access token alg must be RS256");
|
|
52487
|
+
if (typeof header.kid !== "string" || !header.kid)
|
|
52488
|
+
throw new KadoaAccessTokenError("Kadoa access token signing key is missing");
|
|
52489
|
+
const key = await this.keyFor(header.kid);
|
|
52490
|
+
const signed = Buffer.from(`${parts[0]}.${parts[1]}`);
|
|
52491
|
+
const signature = Buffer.from(parts[2], "base64url");
|
|
52492
|
+
if (!signature.length || !verify("RSA-SHA256", signed, key, signature)) {
|
|
52493
|
+
throw new KadoaAccessTokenError("Kadoa access token signature is invalid");
|
|
52494
|
+
}
|
|
52495
|
+
const claims = decodeSegment(parts[1], "claims");
|
|
52496
|
+
const nowSeconds = Math.floor(this.now() / 1000);
|
|
52497
|
+
if (claims.iss !== this.config.issuer)
|
|
52498
|
+
throw new KadoaAccessTokenError("Kadoa access token issuer is invalid");
|
|
52499
|
+
const audiences = Array.isArray(claims.aud) ? claims.aud : [claims.aud];
|
|
52500
|
+
if (!audiences.includes(this.config.audience))
|
|
52501
|
+
throw new KadoaAccessTokenError("Kadoa access token audience is invalid");
|
|
52502
|
+
if (typeof claims.exp !== "number" || claims.exp <= nowSeconds)
|
|
52503
|
+
throw new KadoaAccessTokenError("Kadoa access token has expired");
|
|
52504
|
+
if (typeof claims.iat !== "number" || claims.iat > nowSeconds + CLOCK_SKEW_SECONDS) {
|
|
52505
|
+
throw new KadoaAccessTokenError("Kadoa access token issued-at is invalid");
|
|
52506
|
+
}
|
|
52507
|
+
if (typeof claims.nbf === "number" && claims.nbf > nowSeconds + CLOCK_SKEW_SECONDS) {
|
|
52508
|
+
throw new KadoaAccessTokenError("Kadoa access token is not yet valid");
|
|
52509
|
+
}
|
|
52510
|
+
if (claims.purpose !== KADOA_ACCESS_TOKEN_PURPOSE)
|
|
52511
|
+
throw new KadoaAccessTokenError("Kadoa access token purpose is invalid");
|
|
52512
|
+
if (typeof claims.sub !== "string" || !UUID_PATTERN.test(claims.sub))
|
|
52513
|
+
throw new KadoaAccessTokenError("Kadoa access token subject is invalid");
|
|
52514
|
+
if (typeof claims.active_team_id !== "string" || !UUID_PATTERN.test(claims.active_team_id)) {
|
|
52515
|
+
throw new KadoaAccessTokenError("Kadoa access token active_team_id is invalid");
|
|
52516
|
+
}
|
|
52517
|
+
let actor;
|
|
52518
|
+
if (claims.act !== undefined) {
|
|
52519
|
+
const act = claims.act;
|
|
52520
|
+
if (typeof act?.sub !== "string" || typeof act?.session_id !== "string" || !UUID_PATTERN.test(act.session_id)) {
|
|
52521
|
+
throw new KadoaAccessTokenError("Kadoa access token actor claim is malformed");
|
|
52522
|
+
}
|
|
52523
|
+
actor = { sub: act.sub, sessionId: act.session_id };
|
|
52524
|
+
}
|
|
52525
|
+
return {
|
|
52526
|
+
type: "kadoa",
|
|
52527
|
+
userId: claims.sub,
|
|
52528
|
+
teamId: claims.active_team_id,
|
|
52529
|
+
...typeof claims.team_role === "string" ? { teamRole: claims.team_role } : {},
|
|
52530
|
+
scopes: typeof claims.scope === "string" ? claims.scope.split(" ").filter(Boolean) : [],
|
|
52531
|
+
...actor ? { actor } : {},
|
|
52532
|
+
accessToken: token,
|
|
52533
|
+
expiresAt: claims.exp
|
|
52534
|
+
};
|
|
52535
|
+
}
|
|
52536
|
+
}
|
|
52537
|
+
var UUID_PATTERN, CLOCK_SKEW_SECONDS = 30, DEFAULT_CACHE_TTL_MS, UNKNOWN_KID_REFETCH_INTERVAL_MS, JWKS_FETCH_TIMEOUT_MS = 5000, KADOA_ACCESS_TOKEN_PURPOSE = "kadoa-mcp", KadoaAccessTokenError;
|
|
52538
|
+
var init_kadoa_access_token = __esm(() => {
|
|
52539
|
+
UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
52540
|
+
DEFAULT_CACHE_TTL_MS = 10 * 60 * 1000;
|
|
52541
|
+
UNKNOWN_KID_REFETCH_INTERVAL_MS = 60 * 1000;
|
|
52542
|
+
KadoaAccessTokenError = class KadoaAccessTokenError extends Error {
|
|
52543
|
+
constructor(message) {
|
|
52544
|
+
super(message);
|
|
52545
|
+
this.name = "KadoaAccessTokenError";
|
|
52546
|
+
}
|
|
52547
|
+
};
|
|
52548
|
+
});
|
|
52549
|
+
|
|
51550
52550
|
// src/http.ts
|
|
51551
52551
|
import express8 from "express";
|
|
51552
52552
|
function jwtClaims2(jwt) {
|
|
@@ -51570,6 +52570,9 @@ function resolveAuth(req) {
|
|
|
51570
52570
|
}
|
|
51571
52571
|
return { principal, mcpToken: req.auth.token };
|
|
51572
52572
|
}
|
|
52573
|
+
if (principal.type === "kadoa") {
|
|
52574
|
+
return { principal, mcpToken: req.auth.token };
|
|
52575
|
+
}
|
|
51573
52576
|
if (principal.type === "user") {
|
|
51574
52577
|
const claims = jwtClaims2(principal.supabaseJwt);
|
|
51575
52578
|
if (!claims.sub) {
|
|
@@ -51598,6 +52601,11 @@ async function startHttpServer(options) {
|
|
|
51598
52601
|
const managedRegistry = options?.managedRegistry ?? (process.env.MCP_REGISTRY_SERVICE_TOKEN ? new ManagedConnectorRegistry : undefined);
|
|
51599
52602
|
const provider = new KadoaOAuthProvider(store, managedRegistry);
|
|
51600
52603
|
const serverUrl = process.env.MCP_SERVER_URL || `http://localhost:${port}`;
|
|
52604
|
+
const verifierConfig = loadKadoaAccessTokenVerifierConfig();
|
|
52605
|
+
const kadoaTokenVerifier = options?.kadoaTokenVerifier ?? (verifierConfig ? new KadoaAccessTokenVerifier(verifierConfig) : undefined);
|
|
52606
|
+
if (!kadoaTokenVerifier) {
|
|
52607
|
+
console.warn("[AUTH] Kadoa access-token verifier disabled (MCP_AUTH_ISSUER, MCP_AUTH_JWKS_URL, MCP_AUTH_AUDIENCE unset); RS256 bearers will be rejected");
|
|
52608
|
+
}
|
|
51601
52609
|
app.post("/token", express8.urlencoded({ extended: false }), rate_limit_default({
|
|
51602
52610
|
windowMs: 15 * 60 * 1000,
|
|
51603
52611
|
limit: 50,
|
|
@@ -51636,7 +52644,41 @@ async function startHttpServer(options) {
|
|
|
51636
52644
|
redis: store.isConnected() ? "connected" : "fallback"
|
|
51637
52645
|
});
|
|
51638
52646
|
});
|
|
51639
|
-
const
|
|
52647
|
+
const oauthBearerAuth = requireBearerAuth({ verifier: provider });
|
|
52648
|
+
const bearerAuth = async (req, res, next) => {
|
|
52649
|
+
const match = req.header("authorization")?.match(/^Bearer ([^\s]+)$/i);
|
|
52650
|
+
const token = match?.[1];
|
|
52651
|
+
if (!token || !isJwtShaped(token))
|
|
52652
|
+
return oauthBearerAuth(req, res, next);
|
|
52653
|
+
if (!kadoaTokenVerifier) {
|
|
52654
|
+
res.status(401).json({
|
|
52655
|
+
jsonrpc: "2.0",
|
|
52656
|
+
error: { code: -32001, message: "Unauthorized: Kadoa access tokens are not accepted by this server" },
|
|
52657
|
+
id: req.body?.id ?? null
|
|
52658
|
+
});
|
|
52659
|
+
return;
|
|
52660
|
+
}
|
|
52661
|
+
try {
|
|
52662
|
+
const principal = await kadoaTokenVerifier.verify(token);
|
|
52663
|
+
req.auth = {
|
|
52664
|
+
token,
|
|
52665
|
+
clientId: principal.actor ? `kadoa-delegated:${principal.actor.sub}` : "kadoa-access-token",
|
|
52666
|
+
scopes: principal.scopes,
|
|
52667
|
+
expiresAt: principal.expiresAt,
|
|
52668
|
+
extra: { principal, teamId: principal.teamId }
|
|
52669
|
+
};
|
|
52670
|
+
next();
|
|
52671
|
+
} catch (error) {
|
|
52672
|
+
const message = error instanceof KadoaAccessTokenError ? error.message : "Kadoa access token rejected";
|
|
52673
|
+
console.error(`[AUTH] KADOA_TOKEN_FAIL: ${message}`);
|
|
52674
|
+
const publicMessage = message.startsWith("JWKS") ? "Kadoa access token could not be verified" : message;
|
|
52675
|
+
res.status(401).json({
|
|
52676
|
+
jsonrpc: "2.0",
|
|
52677
|
+
error: { code: -32001, message: `Unauthorized: ${publicMessage}` },
|
|
52678
|
+
id: req.body?.id ?? null
|
|
52679
|
+
});
|
|
52680
|
+
}
|
|
52681
|
+
};
|
|
51640
52682
|
app.post("/mcp", bearerAuth, async (req, res) => {
|
|
51641
52683
|
const auth = resolveAuth(req);
|
|
51642
52684
|
const method = req.body?.method ?? "unknown";
|
|
@@ -51650,7 +52692,8 @@ async function startHttpServer(options) {
|
|
|
51650
52692
|
return;
|
|
51651
52693
|
}
|
|
51652
52694
|
let principal = auth.principal;
|
|
51653
|
-
const
|
|
52695
|
+
const delegatedSession = principal.type === "kadoa" && principal.actor ? `:session=${principal.actor.sessionId}` : "";
|
|
52696
|
+
const identity = `mode=${principal.type}:team=${principal.teamId.slice(0, 8)}...${delegatedSession}`;
|
|
51654
52697
|
if (principal.type === "user" && isJwtExpired(principal.supabaseJwt)) {
|
|
51655
52698
|
try {
|
|
51656
52699
|
const refreshed = await refreshSupabaseJwtRaw(principal.supabaseRefreshToken);
|
|
@@ -51771,6 +52814,7 @@ var init_http2 = __esm(async () => {
|
|
|
51771
52814
|
init_managed_connector_client();
|
|
51772
52815
|
init_managed_connector_registry();
|
|
51773
52816
|
init_managed_token_handler();
|
|
52817
|
+
init_kadoa_access_token();
|
|
51774
52818
|
await init_src();
|
|
51775
52819
|
});
|
|
51776
52820
|
|
|
@@ -51825,11 +52869,24 @@ async function createServer(auth, options) {
|
|
|
51825
52869
|
}
|
|
51826
52870
|
}
|
|
51827
52871
|
registerTools(server, ctx, capabilities);
|
|
52872
|
+
if (principal.type === "kadoa") {
|
|
52873
|
+
const hidden = new Set(["team_switch"]);
|
|
52874
|
+
const rawServer = server.server;
|
|
52875
|
+
const baseHandler = rawServer._requestHandlers.get("tools/list");
|
|
52876
|
+
if (!baseHandler) {
|
|
52877
|
+
throw new Error("SDK tools/list handler not found; cannot hide team_switch");
|
|
52878
|
+
}
|
|
52879
|
+
server.server.setRequestHandler(ListToolsRequestSchema2, async (request, extra) => {
|
|
52880
|
+
const result = await baseHandler(request, extra);
|
|
52881
|
+
return { ...result, tools: result.tools.filter((tool) => !hidden.has(tool.name)) };
|
|
52882
|
+
});
|
|
52883
|
+
}
|
|
51828
52884
|
server.server.onerror = (error) => console.error("[MCP Error]", safeErrorSummary(error));
|
|
51829
52885
|
return server;
|
|
51830
52886
|
}
|
|
51831
52887
|
var init_src = __esm(async () => {
|
|
51832
52888
|
init_mcp();
|
|
52889
|
+
init_types3();
|
|
51833
52890
|
init_client();
|
|
51834
52891
|
init_tools();
|
|
51835
52892
|
init_package();
|