@nestr/mcp 0.1.72 → 0.1.73
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/build/api/client.d.ts +54 -3
- package/build/api/client.d.ts.map +1 -1
- package/build/api/client.js +82 -18
- package/build/api/client.js.map +1 -1
- package/build/help/topics.d.ts.map +1 -1
- package/build/help/topics.js +12 -0
- package/build/help/topics.js.map +1 -1
- package/build/http.d.ts +22 -0
- package/build/http.d.ts.map +1 -1
- package/build/http.js +233 -41
- package/build/http.js.map +1 -1
- package/build/oauth/flow.d.ts +6 -0
- package/build/oauth/flow.d.ts.map +1 -1
- package/build/oauth/flow.js +30 -4
- package/build/oauth/flow.js.map +1 -1
- package/build/oauth/store.d.ts +14 -0
- package/build/oauth/store.d.ts.map +1 -1
- package/build/oauth/store.js.map +1 -1
- package/build/server.d.ts +4 -0
- package/build/server.d.ts.map +1 -1
- package/build/server.js +15 -1
- package/build/server.js.map +1 -1
- package/build/tools/index.d.ts +88 -78
- package/build/tools/index.d.ts.map +1 -1
- package/build/tools/index.js +90 -25
- package/build/tools/index.js.map +1 -1
- package/build/util/diagnose.d.ts +40 -0
- package/build/util/diagnose.d.ts.map +1 -0
- package/build/util/diagnose.js +26 -0
- package/build/util/diagnose.js.map +1 -0
- package/build/util/request-context.d.ts +11 -0
- package/build/util/request-context.d.ts.map +1 -0
- package/build/util/request-context.js +30 -0
- package/build/util/request-context.js.map +1 -0
- package/package.json +1 -1
package/build/tools/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { type NestrClient } from "../api/client.js";
|
|
7
|
+
import type { DiagnoseSnapshot } from "../util/diagnose.js";
|
|
7
8
|
type CompletableSource = "inbox" | "daily-plan" | "children" | "projects" | "search";
|
|
8
9
|
export declare function completableResponse(data: unknown, source: CompletableSource, title: string): {
|
|
9
10
|
title: string;
|
|
@@ -946,6 +947,7 @@ export declare const schemas: {
|
|
|
946
947
|
}, {
|
|
947
948
|
topic: string;
|
|
948
949
|
}>;
|
|
950
|
+
diagnose: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
949
951
|
};
|
|
950
952
|
export declare const toolDefinitions: ({
|
|
951
953
|
annotations: {
|
|
@@ -1027,6 +1029,83 @@ export declare const toolDefinitions: ({
|
|
|
1027
1029
|
};
|
|
1028
1030
|
required: string[];
|
|
1029
1031
|
};
|
|
1032
|
+
} | {
|
|
1033
|
+
annotations: {
|
|
1034
|
+
readOnlyHint: boolean;
|
|
1035
|
+
destructiveHint: boolean;
|
|
1036
|
+
};
|
|
1037
|
+
name: string;
|
|
1038
|
+
description: string;
|
|
1039
|
+
inputSchema: {
|
|
1040
|
+
type: "object";
|
|
1041
|
+
properties: {
|
|
1042
|
+
topic?: undefined;
|
|
1043
|
+
search?: undefined;
|
|
1044
|
+
limit?: undefined;
|
|
1045
|
+
page?: undefined;
|
|
1046
|
+
stripDescription?: undefined;
|
|
1047
|
+
workspaceId?: undefined;
|
|
1048
|
+
title?: undefined;
|
|
1049
|
+
purpose?: undefined;
|
|
1050
|
+
type?: undefined;
|
|
1051
|
+
governance?: undefined;
|
|
1052
|
+
plan?: undefined;
|
|
1053
|
+
apps?: undefined;
|
|
1054
|
+
layout?: undefined;
|
|
1055
|
+
query?: undefined;
|
|
1056
|
+
_listTitle?: undefined;
|
|
1057
|
+
nestId?: undefined;
|
|
1058
|
+
fieldsMetaData?: undefined;
|
|
1059
|
+
hints?: undefined;
|
|
1060
|
+
parentId?: undefined;
|
|
1061
|
+
description?: undefined;
|
|
1062
|
+
labels?: undefined;
|
|
1063
|
+
fields?: undefined;
|
|
1064
|
+
users?: undefined;
|
|
1065
|
+
accountabilities?: undefined;
|
|
1066
|
+
domains?: undefined;
|
|
1067
|
+
data?: undefined;
|
|
1068
|
+
due?: undefined;
|
|
1069
|
+
completed?: undefined;
|
|
1070
|
+
body?: undefined;
|
|
1071
|
+
commentId?: undefined;
|
|
1072
|
+
circleId?: undefined;
|
|
1073
|
+
includeSubCircles?: undefined;
|
|
1074
|
+
userId?: undefined;
|
|
1075
|
+
endDate?: undefined;
|
|
1076
|
+
metricId?: undefined;
|
|
1077
|
+
depth?: undefined;
|
|
1078
|
+
username?: undefined;
|
|
1079
|
+
fullName?: undefined;
|
|
1080
|
+
language?: undefined;
|
|
1081
|
+
labelId?: undefined;
|
|
1082
|
+
from?: undefined;
|
|
1083
|
+
to?: undefined;
|
|
1084
|
+
completedAfter?: undefined;
|
|
1085
|
+
nestIds?: undefined;
|
|
1086
|
+
position?: undefined;
|
|
1087
|
+
relatedNestId?: undefined;
|
|
1088
|
+
color?: undefined;
|
|
1089
|
+
icon?: undefined;
|
|
1090
|
+
fullWorkspaces?: undefined;
|
|
1091
|
+
context?: undefined;
|
|
1092
|
+
skip?: undefined;
|
|
1093
|
+
showRead?: undefined;
|
|
1094
|
+
group?: undefined;
|
|
1095
|
+
feeling?: undefined;
|
|
1096
|
+
needs?: undefined;
|
|
1097
|
+
tensionId?: undefined;
|
|
1098
|
+
order?: undefined;
|
|
1099
|
+
_id?: undefined;
|
|
1100
|
+
partId?: undefined;
|
|
1101
|
+
childId?: undefined;
|
|
1102
|
+
status?: undefined;
|
|
1103
|
+
relation?: undefined;
|
|
1104
|
+
direction?: undefined;
|
|
1105
|
+
targetId?: undefined;
|
|
1106
|
+
};
|
|
1107
|
+
required?: undefined;
|
|
1108
|
+
};
|
|
1030
1109
|
} | {
|
|
1031
1110
|
annotations: {
|
|
1032
1111
|
readOnlyHint: boolean;
|
|
@@ -3814,83 +3893,6 @@ export declare const toolDefinitions: ({
|
|
|
3814
3893
|
};
|
|
3815
3894
|
required: string[];
|
|
3816
3895
|
};
|
|
3817
|
-
} | {
|
|
3818
|
-
annotations: {
|
|
3819
|
-
readOnlyHint: boolean;
|
|
3820
|
-
destructiveHint: boolean;
|
|
3821
|
-
};
|
|
3822
|
-
name: string;
|
|
3823
|
-
description: string;
|
|
3824
|
-
inputSchema: {
|
|
3825
|
-
type: "object";
|
|
3826
|
-
properties: {
|
|
3827
|
-
topic?: undefined;
|
|
3828
|
-
search?: undefined;
|
|
3829
|
-
limit?: undefined;
|
|
3830
|
-
page?: undefined;
|
|
3831
|
-
stripDescription?: undefined;
|
|
3832
|
-
workspaceId?: undefined;
|
|
3833
|
-
title?: undefined;
|
|
3834
|
-
purpose?: undefined;
|
|
3835
|
-
type?: undefined;
|
|
3836
|
-
governance?: undefined;
|
|
3837
|
-
plan?: undefined;
|
|
3838
|
-
apps?: undefined;
|
|
3839
|
-
layout?: undefined;
|
|
3840
|
-
query?: undefined;
|
|
3841
|
-
_listTitle?: undefined;
|
|
3842
|
-
nestId?: undefined;
|
|
3843
|
-
fieldsMetaData?: undefined;
|
|
3844
|
-
hints?: undefined;
|
|
3845
|
-
parentId?: undefined;
|
|
3846
|
-
description?: undefined;
|
|
3847
|
-
labels?: undefined;
|
|
3848
|
-
fields?: undefined;
|
|
3849
|
-
users?: undefined;
|
|
3850
|
-
accountabilities?: undefined;
|
|
3851
|
-
domains?: undefined;
|
|
3852
|
-
data?: undefined;
|
|
3853
|
-
due?: undefined;
|
|
3854
|
-
completed?: undefined;
|
|
3855
|
-
body?: undefined;
|
|
3856
|
-
commentId?: undefined;
|
|
3857
|
-
circleId?: undefined;
|
|
3858
|
-
includeSubCircles?: undefined;
|
|
3859
|
-
userId?: undefined;
|
|
3860
|
-
endDate?: undefined;
|
|
3861
|
-
metricId?: undefined;
|
|
3862
|
-
depth?: undefined;
|
|
3863
|
-
username?: undefined;
|
|
3864
|
-
fullName?: undefined;
|
|
3865
|
-
language?: undefined;
|
|
3866
|
-
labelId?: undefined;
|
|
3867
|
-
from?: undefined;
|
|
3868
|
-
to?: undefined;
|
|
3869
|
-
completedAfter?: undefined;
|
|
3870
|
-
nestIds?: undefined;
|
|
3871
|
-
position?: undefined;
|
|
3872
|
-
relatedNestId?: undefined;
|
|
3873
|
-
color?: undefined;
|
|
3874
|
-
icon?: undefined;
|
|
3875
|
-
fullWorkspaces?: undefined;
|
|
3876
|
-
context?: undefined;
|
|
3877
|
-
skip?: undefined;
|
|
3878
|
-
showRead?: undefined;
|
|
3879
|
-
group?: undefined;
|
|
3880
|
-
feeling?: undefined;
|
|
3881
|
-
needs?: undefined;
|
|
3882
|
-
tensionId?: undefined;
|
|
3883
|
-
order?: undefined;
|
|
3884
|
-
_id?: undefined;
|
|
3885
|
-
partId?: undefined;
|
|
3886
|
-
childId?: undefined;
|
|
3887
|
-
status?: undefined;
|
|
3888
|
-
relation?: undefined;
|
|
3889
|
-
direction?: undefined;
|
|
3890
|
-
targetId?: undefined;
|
|
3891
|
-
};
|
|
3892
|
-
required?: undefined;
|
|
3893
|
-
};
|
|
3894
3896
|
} | {
|
|
3895
3897
|
annotations: {
|
|
3896
3898
|
readOnlyHint: boolean;
|
|
@@ -5804,6 +5806,14 @@ export type ToolResult = {
|
|
|
5804
5806
|
};
|
|
5805
5807
|
export declare function stripDescriptionFields(data: unknown): unknown;
|
|
5806
5808
|
export declare function unescapeRichTextFields(args: Record<string, unknown>): Record<string, unknown>;
|
|
5807
|
-
|
|
5809
|
+
/**
|
|
5810
|
+
* Per-tool-call context. Carries session-level info that diagnose-style
|
|
5811
|
+
* tools need but ordinary tools don't. Optional so tests/callers that don't
|
|
5812
|
+
* have a session (CLI, stdio mode) can still call handleToolCall.
|
|
5813
|
+
*/
|
|
5814
|
+
export interface ToolCallContext {
|
|
5815
|
+
getDiagnose?: () => DiagnoseSnapshot;
|
|
5816
|
+
}
|
|
5817
|
+
export declare function handleToolCall(client: NestrClient, name: string, args: Record<string, unknown>, context?: ToolCallContext): Promise<ToolResult>;
|
|
5808
5818
|
export {};
|
|
5809
5819
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CA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wBAAsB,cAAc,CAClC,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,UAAU,CAAC,CAerB"}
|
package/build/tools/index.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { NestrApiError } from "../api/client.js";
|
|
7
7
|
import { appResources } from "../apps/index.js";
|
|
8
|
+
import { getCorrelationId } from "../util/request-context.js";
|
|
9
|
+
import { VERSION } from "../version.js";
|
|
8
10
|
// MCP Apps UI metadata for tools that can render in the completable list app.
|
|
9
11
|
// IMPORTANT: Only use for completable items (tasks, projects, todos, inbox items).
|
|
10
12
|
// Do NOT use for structural nests like roles, circles, metrics, policies, etc.
|
|
@@ -509,6 +511,7 @@ export const schemas = {
|
|
|
509
511
|
help: z.object({
|
|
510
512
|
topic: z.string().describe("Topic key (e.g., 'search', 'labels', 'tensions'). Use 'topics' for the full list."),
|
|
511
513
|
}),
|
|
514
|
+
diagnose: z.object({}).describe("No arguments — diagnose reads session state from the server."),
|
|
512
515
|
};
|
|
513
516
|
// Tool annotations for MCP - hints for clients on tool behavior
|
|
514
517
|
const readOnly = { annotations: { readOnlyHint: true, destructiveHint: false } };
|
|
@@ -518,7 +521,7 @@ const destructive = { annotations: { readOnlyHint: false, destructiveHint: true
|
|
|
518
521
|
export const toolDefinitions = [
|
|
519
522
|
{
|
|
520
523
|
name: "nestr_help",
|
|
521
|
-
description: "Get detailed Nestr documentation by topic. Call before unfamiliar operations. Topics: search, labels, nest-model, inbox, daily-plan, notifications, insights, tension-processing, skills, mcp-apps, authentication, and more. Use topic 'topics' for the full list.",
|
|
524
|
+
description: "Get detailed Nestr documentation by topic. Call before unfamiliar operations. Topics: search, labels, nest-model, inbox, daily-plan, notifications, insights, tension-processing, skills, mcp-apps, authentication, and more. Use topic 'topics' for the full list. Auth: none required.",
|
|
522
525
|
inputSchema: {
|
|
523
526
|
type: "object",
|
|
524
527
|
properties: {
|
|
@@ -528,6 +531,15 @@ export const toolDefinitions = [
|
|
|
528
531
|
},
|
|
529
532
|
...readOnly,
|
|
530
533
|
},
|
|
534
|
+
{
|
|
535
|
+
name: "nestr_diagnose",
|
|
536
|
+
description: "Server-side auth and session diagnostics. Call this FIRST when any other tool returns an auth error (AUTH_TOKEN_REJECTED_BY_NESTR / AUTH_REFRESH_FAILED / AUTH_SCOPE_INSUFFICIENT / AUTH_PROXY_HEADER_DROPPED). Returns: flow (A=server-managed refresh, B=client-managed refresh, unknown=API key), tokenPresented, tokenFingerprint, lastUpstream401At, lastRefreshAttempt, sessionCorrelationId, serverVersion, mcpClient, mcpClientVersion. Auth: none required — works whether or not the bearer is valid.",
|
|
537
|
+
inputSchema: {
|
|
538
|
+
type: "object",
|
|
539
|
+
properties: {},
|
|
540
|
+
},
|
|
541
|
+
...readOnly,
|
|
542
|
+
},
|
|
531
543
|
{
|
|
532
544
|
name: "nestr_list_workspaces",
|
|
533
545
|
description: "List workspaces. Prefer nestr_get_me with fullWorkspaces:true at session start. Paginated with meta.total.",
|
|
@@ -557,7 +569,7 @@ export const toolDefinitions = [
|
|
|
557
569
|
},
|
|
558
570
|
{
|
|
559
571
|
name: "nestr_create_workspace",
|
|
560
|
-
description: "Create a new workspace. OAuth only. See nestr_help('workspace-setup') for guided setup.",
|
|
572
|
+
description: "Create a new workspace. Auth: OAuth only (user-scoped — workspace API keys cannot create new workspaces). On auth failure call nestr_diagnose. See nestr_help('workspace-setup') for guided setup.",
|
|
561
573
|
inputSchema: {
|
|
562
574
|
type: "object",
|
|
563
575
|
properties: {
|
|
@@ -1016,7 +1028,7 @@ export const toolDefinitions = [
|
|
|
1016
1028
|
// Inbox tools (require OAuth token - won't work with workspace API keys)
|
|
1017
1029
|
{
|
|
1018
1030
|
name: "nestr_list_inbox",
|
|
1019
|
-
description: "List items in the user's personal inbox. Spans all workspaces. OAuth only.",
|
|
1031
|
+
description: "List items in the user's personal inbox. Spans all workspaces. Auth: OAuth only (user-scoped — workspace API keys lack user identity). On auth failure call nestr_diagnose.",
|
|
1020
1032
|
inputSchema: {
|
|
1021
1033
|
type: "object",
|
|
1022
1034
|
properties: {
|
|
@@ -1029,7 +1041,7 @@ export const toolDefinitions = [
|
|
|
1029
1041
|
},
|
|
1030
1042
|
{
|
|
1031
1043
|
name: "nestr_create_inbox_item",
|
|
1032
|
-
description: "Quick capture: add an item to the inbox for later processing. OAuth only.",
|
|
1044
|
+
description: "Quick capture: add an item to the inbox for later processing. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1033
1045
|
inputSchema: {
|
|
1034
1046
|
type: "object",
|
|
1035
1047
|
properties: {
|
|
@@ -1042,7 +1054,7 @@ export const toolDefinitions = [
|
|
|
1042
1054
|
},
|
|
1043
1055
|
{
|
|
1044
1056
|
name: "nestr_get_inbox_item",
|
|
1045
|
-
description: "Get details of a specific inbox item.
|
|
1057
|
+
description: "Get details of a specific inbox item. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1046
1058
|
inputSchema: {
|
|
1047
1059
|
type: "object",
|
|
1048
1060
|
properties: {
|
|
@@ -1055,7 +1067,7 @@ export const toolDefinitions = [
|
|
|
1055
1067
|
},
|
|
1056
1068
|
{
|
|
1057
1069
|
name: "nestr_update_inbox_item",
|
|
1058
|
-
description: "Update an inbox item. Set completed:true when processed. Use nestr_update_nest with parentId to move out of inbox. OAuth only.",
|
|
1070
|
+
description: "Update an inbox item. Set completed:true when processed. Use nestr_update_nest with parentId to move out of inbox. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1059
1071
|
inputSchema: {
|
|
1060
1072
|
type: "object",
|
|
1061
1073
|
properties: {
|
|
@@ -1071,7 +1083,7 @@ export const toolDefinitions = [
|
|
|
1071
1083
|
},
|
|
1072
1084
|
{
|
|
1073
1085
|
name: "nestr_reorder_inbox",
|
|
1074
|
-
description: "Reorder inbox items. Provide a subset of IDs — they go to the top in given order, rest unchanged. OAuth only.",
|
|
1086
|
+
description: "Reorder inbox items. Provide a subset of IDs — they go to the top in given order, rest unchanged. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1075
1087
|
inputSchema: {
|
|
1076
1088
|
type: "object",
|
|
1077
1089
|
properties: {
|
|
@@ -1087,7 +1099,7 @@ export const toolDefinitions = [
|
|
|
1087
1099
|
},
|
|
1088
1100
|
{
|
|
1089
1101
|
name: "nestr_reorder_inbox_item",
|
|
1090
|
-
description: "Reorder a single inbox item by positioning it before or after another inbox item.
|
|
1102
|
+
description: "Reorder a single inbox item by positioning it before or after another inbox item. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1091
1103
|
inputSchema: {
|
|
1092
1104
|
type: "object",
|
|
1093
1105
|
properties: {
|
|
@@ -1102,7 +1114,7 @@ export const toolDefinitions = [
|
|
|
1102
1114
|
// Personal labels (require OAuth token - user's own labels, not workspace labels)
|
|
1103
1115
|
{
|
|
1104
1116
|
name: "nestr_list_personal_labels",
|
|
1105
|
-
description: "List the current user's personal labels (not workspace labels). OAuth only.",
|
|
1117
|
+
description: "List the current user's personal labels (not workspace labels). Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1106
1118
|
inputSchema: {
|
|
1107
1119
|
type: "object",
|
|
1108
1120
|
properties: {},
|
|
@@ -1111,7 +1123,7 @@ export const toolDefinitions = [
|
|
|
1111
1123
|
},
|
|
1112
1124
|
{
|
|
1113
1125
|
name: "nestr_create_personal_label",
|
|
1114
|
-
description: "Create a personal label. Can be used across workspaces. OAuth only.",
|
|
1126
|
+
description: "Create a personal label. Can be used across workspaces. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1115
1127
|
inputSchema: {
|
|
1116
1128
|
type: "object",
|
|
1117
1129
|
properties: {
|
|
@@ -1159,7 +1171,7 @@ export const toolDefinitions = [
|
|
|
1159
1171
|
// Daily plan (requires OAuth token)
|
|
1160
1172
|
{
|
|
1161
1173
|
name: "nestr_get_daily_plan",
|
|
1162
|
-
description: "Get the user's daily plan — items marked for today. Spans all workspaces. OAuth only.",
|
|
1174
|
+
description: "Get the user's daily plan — items marked for today. Spans all workspaces. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1163
1175
|
inputSchema: {
|
|
1164
1176
|
type: "object",
|
|
1165
1177
|
properties: {
|
|
@@ -1198,7 +1210,7 @@ export const toolDefinitions = [
|
|
|
1198
1210
|
},
|
|
1199
1211
|
{
|
|
1200
1212
|
name: "nestr_add_to_daily_plan",
|
|
1201
|
-
description: "Add one or more items to the daily plan by applying the 'now' label.
|
|
1213
|
+
description: "Add one or more items to the daily plan by applying the 'now' label. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1202
1214
|
inputSchema: {
|
|
1203
1215
|
type: "object",
|
|
1204
1216
|
properties: {
|
|
@@ -1214,7 +1226,7 @@ export const toolDefinitions = [
|
|
|
1214
1226
|
},
|
|
1215
1227
|
{
|
|
1216
1228
|
name: "nestr_remove_from_daily_plan",
|
|
1217
|
-
description: "Remove one or more items from the daily plan by removing the 'now' label.
|
|
1229
|
+
description: "Remove one or more items from the daily plan by removing the 'now' label. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1218
1230
|
inputSchema: {
|
|
1219
1231
|
type: "object",
|
|
1220
1232
|
properties: {
|
|
@@ -1243,7 +1255,7 @@ export const toolDefinitions = [
|
|
|
1243
1255
|
// User tension tools (requires OAuth token)
|
|
1244
1256
|
{
|
|
1245
1257
|
name: "nestr_list_my_tensions",
|
|
1246
|
-
description: "List tensions created by or assigned to the current user. Check at session start and natural breakpoints. OAuth only.",
|
|
1258
|
+
description: "List tensions created by or assigned to the current user. Check at session start and natural breakpoints. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1247
1259
|
inputSchema: {
|
|
1248
1260
|
type: "object",
|
|
1249
1261
|
properties: {
|
|
@@ -1254,7 +1266,7 @@ export const toolDefinitions = [
|
|
|
1254
1266
|
},
|
|
1255
1267
|
{
|
|
1256
1268
|
name: "nestr_list_tensions_awaiting_consent",
|
|
1257
|
-
description: "List tensions awaiting the current user's consent vote. Check proactively. OAuth only.",
|
|
1269
|
+
description: "List tensions awaiting the current user's consent vote. Check proactively. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1258
1270
|
inputSchema: {
|
|
1259
1271
|
type: "object",
|
|
1260
1272
|
properties: {
|
|
@@ -1266,7 +1278,7 @@ export const toolDefinitions = [
|
|
|
1266
1278
|
// Notification tools (requires OAuth token)
|
|
1267
1279
|
{
|
|
1268
1280
|
name: "nestr_list_notifications",
|
|
1269
|
-
description: "List notifications. Use type 'me' for direct (mentions, replies) or 'relevant' for organizational changes. OAuth only.",
|
|
1281
|
+
description: "List notifications. Use type 'me' for direct (mentions, replies) or 'relevant' for organizational changes. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1270
1282
|
inputSchema: {
|
|
1271
1283
|
type: "object",
|
|
1272
1284
|
properties: {
|
|
@@ -1281,7 +1293,7 @@ export const toolDefinitions = [
|
|
|
1281
1293
|
},
|
|
1282
1294
|
{
|
|
1283
1295
|
name: "nestr_mark_notifications_read",
|
|
1284
|
-
description: "Mark all unread in-app notifications as read for the current user. Returns { status, data: { markedCount } }.
|
|
1296
|
+
description: "Mark all unread in-app notifications as read for the current user. Returns { status, data: { markedCount } }. Auth: OAuth only (user-scoped). On auth failure call nestr_diagnose.",
|
|
1285
1297
|
inputSchema: {
|
|
1286
1298
|
type: "object",
|
|
1287
1299
|
properties: {},
|
|
@@ -1630,10 +1642,10 @@ export function unescapeRichTextFields(args) {
|
|
|
1630
1642
|
}
|
|
1631
1643
|
return changed ? result : args;
|
|
1632
1644
|
}
|
|
1633
|
-
export async function handleToolCall(client, name, args) {
|
|
1645
|
+
export async function handleToolCall(client, name, args, context) {
|
|
1634
1646
|
const sanitizedArgs = unescapeRichTextFields(args);
|
|
1635
1647
|
const shouldStripDescription = sanitizedArgs.stripDescription === true;
|
|
1636
|
-
const result = await _handleToolCall(client, name, sanitizedArgs);
|
|
1648
|
+
const result = await _handleToolCall(client, name, sanitizedArgs, context);
|
|
1637
1649
|
if (shouldStripDescription && !result.isError) {
|
|
1638
1650
|
try {
|
|
1639
1651
|
const parsed = JSON.parse(result.content[0].text);
|
|
@@ -1645,7 +1657,7 @@ export async function handleToolCall(client, name, args) {
|
|
|
1645
1657
|
}
|
|
1646
1658
|
return result;
|
|
1647
1659
|
}
|
|
1648
|
-
async function _handleToolCall(client, name, args) {
|
|
1660
|
+
async function _handleToolCall(client, name, args, context) {
|
|
1649
1661
|
try {
|
|
1650
1662
|
switch (name) {
|
|
1651
1663
|
case "nestr_help": {
|
|
@@ -1657,6 +1669,37 @@ async function _handleToolCall(client, name, args) {
|
|
|
1657
1669
|
}
|
|
1658
1670
|
return { content: [{ type: "text", text: content }] };
|
|
1659
1671
|
}
|
|
1672
|
+
case "nestr_diagnose": {
|
|
1673
|
+
schemas.diagnose.parse(args);
|
|
1674
|
+
const snapshot = context?.getDiagnose?.();
|
|
1675
|
+
const correlationId = getCorrelationId();
|
|
1676
|
+
const result = {
|
|
1677
|
+
serverVersion: VERSION,
|
|
1678
|
+
correlationId,
|
|
1679
|
+
// No request context (e.g. stdio mode): we still report the basic facts.
|
|
1680
|
+
flow: snapshot?.flow ?? "unknown",
|
|
1681
|
+
tokenPresented: snapshot?.tokenPresented ?? false,
|
|
1682
|
+
tokenFingerprint: snapshot?.tokenFingerprint ?? "none",
|
|
1683
|
+
tokenAge: snapshot?.tokenAge ?? null,
|
|
1684
|
+
lastUpstream401At: snapshot?.lastUpstream401At
|
|
1685
|
+
? new Date(snapshot.lastUpstream401At).toISOString()
|
|
1686
|
+
: null,
|
|
1687
|
+
lastRefreshAttempt: snapshot?.lastRefreshAttempt
|
|
1688
|
+
? {
|
|
1689
|
+
at: new Date(snapshot.lastRefreshAttempt.at).toISOString(),
|
|
1690
|
+
success: snapshot.lastRefreshAttempt.success,
|
|
1691
|
+
error: snapshot.lastRefreshAttempt.error,
|
|
1692
|
+
}
|
|
1693
|
+
: null,
|
|
1694
|
+
sessionCorrelationId: snapshot?.sessionCorrelationId,
|
|
1695
|
+
authMode: snapshot?.isApiKey ? "api-key" : snapshot?.tokenPresented ? "oauth" : "none",
|
|
1696
|
+
mcpClient: snapshot?.mcpClient,
|
|
1697
|
+
mcpClientVersion: snapshot?.mcpClientVersion,
|
|
1698
|
+
userId: snapshot?.userId,
|
|
1699
|
+
hint: buildDiagnoseHint(snapshot),
|
|
1700
|
+
};
|
|
1701
|
+
return formatResult(result);
|
|
1702
|
+
}
|
|
1660
1703
|
case "nestr_list_workspaces": {
|
|
1661
1704
|
const parsed = schemas.listWorkspaces.parse(args);
|
|
1662
1705
|
const workspaces = await client.listWorkspaces({
|
|
@@ -2055,8 +2098,8 @@ async function _handleToolCall(client, name, args) {
|
|
|
2055
2098
|
catch (err) {
|
|
2056
2099
|
// 401 means the token itself is invalid — propagate so callers don't
|
|
2057
2100
|
// see a false "success" here while every other tool fails on the
|
|
2058
|
-
// same auth state.
|
|
2059
|
-
if (err instanceof NestrApiError && err.
|
|
2101
|
+
// same auth state. Match by status (any AUTH_* 401 code).
|
|
2102
|
+
if (err instanceof NestrApiError && err.status === 401) {
|
|
2060
2103
|
throw err;
|
|
2061
2104
|
}
|
|
2062
2105
|
// 403 likely means the token is valid but has no user scope (workspace
|
|
@@ -2064,7 +2107,7 @@ async function _handleToolCall(client, name, args) {
|
|
|
2064
2107
|
// endpoint that accepts both OAuth and workspace keys before reporting
|
|
2065
2108
|
// "workspace mode" — that way a forbidden coming from anywhere else
|
|
2066
2109
|
// (e.g. an unauthorized token that happens to 403) doesn't get masked.
|
|
2067
|
-
if (err instanceof NestrApiError && err.code === "
|
|
2110
|
+
if (err instanceof NestrApiError && err.code === "AUTH_SCOPE_INSUFFICIENT") {
|
|
2068
2111
|
const workspaceModeResponse = formatResult({
|
|
2069
2112
|
authMode: "api-key",
|
|
2070
2113
|
user: null,
|
|
@@ -2078,7 +2121,7 @@ async function _handleToolCall(client, name, args) {
|
|
|
2078
2121
|
catch (verifyErr) {
|
|
2079
2122
|
// The verification's job is to rule out "this token is bad". An
|
|
2080
2123
|
// explicit auth failure on listWorkspaces does that — propagate.
|
|
2081
|
-
if (verifyErr instanceof NestrApiError && verifyErr.
|
|
2124
|
+
if (verifyErr instanceof NestrApiError && verifyErr.status === 401) {
|
|
2082
2125
|
throw verifyErr;
|
|
2083
2126
|
}
|
|
2084
2127
|
// Anything else (5xx, network, rate limit) is a transient hiccup
|
|
@@ -2261,7 +2304,9 @@ async function _handleToolCall(client, name, args) {
|
|
|
2261
2304
|
}
|
|
2262
2305
|
}
|
|
2263
2306
|
catch (error) {
|
|
2264
|
-
// Handle Nestr API errors with structured response
|
|
2307
|
+
// Handle Nestr API errors with structured response. NestrApiError.toToolError
|
|
2308
|
+
// already attaches the correlationId from the active request context, so no
|
|
2309
|
+
// extra wiring is needed here.
|
|
2265
2310
|
if (error instanceof NestrApiError) {
|
|
2266
2311
|
return formatError(error.toToolError());
|
|
2267
2312
|
}
|
|
@@ -2273,6 +2318,7 @@ async function _handleToolCall(client, name, args) {
|
|
|
2273
2318
|
message: error.errors.map(e => `${e.path.join(".")}: ${e.message}`).join("; "),
|
|
2274
2319
|
retryable: false,
|
|
2275
2320
|
hint: "Check the tool parameters match the expected schema.",
|
|
2321
|
+
correlationId: getCorrelationId(),
|
|
2276
2322
|
});
|
|
2277
2323
|
}
|
|
2278
2324
|
// Handle other errors
|
|
@@ -2282,9 +2328,28 @@ async function _handleToolCall(client, name, args) {
|
|
|
2282
2328
|
code: "UNKNOWN",
|
|
2283
2329
|
message,
|
|
2284
2330
|
retryable: false,
|
|
2331
|
+
correlationId: getCorrelationId(),
|
|
2285
2332
|
});
|
|
2286
2333
|
}
|
|
2287
2334
|
}
|
|
2335
|
+
function buildDiagnoseHint(snapshot) {
|
|
2336
|
+
if (!snapshot || !snapshot.tokenPresented) {
|
|
2337
|
+
return "No bearer was presented to the server. The MCP client should run the OAuth flow (or pass an X-Nestr-API-Key header) and retry.";
|
|
2338
|
+
}
|
|
2339
|
+
if (snapshot.lastRefreshAttempt && snapshot.lastRefreshAttempt.success === false) {
|
|
2340
|
+
return "Most recent refresh failed. Tell the user to reconnect Nestr.";
|
|
2341
|
+
}
|
|
2342
|
+
if (snapshot.lastUpstream401At) {
|
|
2343
|
+
if (snapshot.flow === "B") {
|
|
2344
|
+
return "Nestr recently rejected the bearer. For Flow B, refresh is the client's responsibility — the MCP client should call /oauth/token with grant_type=refresh_token, then retry. If refresh also fails, tell the user to reconnect Nestr.";
|
|
2345
|
+
}
|
|
2346
|
+
return "Nestr recently rejected the bearer. Tell the user to reconnect Nestr.";
|
|
2347
|
+
}
|
|
2348
|
+
if (snapshot.tokenAge?.exp && snapshot.tokenAge.exp < snapshot.tokenAge.now) {
|
|
2349
|
+
return "Bearer is expired (exp < now). The client should refresh.";
|
|
2350
|
+
}
|
|
2351
|
+
return "Server-side state looks healthy. If a tool is failing, include sessionCorrelationId in the bug report.";
|
|
2352
|
+
}
|
|
2288
2353
|
function formatResult(data) {
|
|
2289
2354
|
return {
|
|
2290
2355
|
content: [
|