@modelcontextprotocol/server-everything 1.0.0 → 2.0.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 +37 -20
- package/dist/docs/architecture.md +6 -5
- package/dist/docs/extension.md +5 -3
- package/dist/docs/features.md +65 -71
- package/dist/docs/how-it-works.md +31 -16
- package/dist/docs/instructions.md +14 -7
- package/dist/docs/startup.md +28 -33
- package/dist/docs/structure.md +63 -29
- package/dist/prompts/args.js +2 -2
- package/dist/prompts/completions.js +3 -3
- package/dist/prompts/resource.js +3 -2
- package/dist/resources/files.js +9 -1
- package/dist/resources/index.js +7 -2
- package/dist/resources/minted.js +119 -0
- package/dist/resources/subscriptions.js +44 -122
- package/dist/resources/templates.js +5 -4
- package/dist/server/context.js +47 -0
- package/dist/server/index.js +113 -55
- package/dist/server/logging.js +39 -66
- package/dist/server/roots.js +41 -62
- package/dist/server/tasks.js +295 -0
- package/dist/tools/get-header-params.js +95 -0
- package/dist/tools/get-roots-list.js +49 -50
- package/dist/tools/gzip-file-as-resource.js +24 -5
- package/dist/tools/index.js +72 -14
- package/dist/tools/simulate-research-query.js +166 -201
- package/dist/tools/toggle-simulated-logging.js +33 -20
- package/dist/tools/toggle-subscriber-updates.js +33 -23
- package/dist/tools/trigger-elicitation-request-async.js +99 -204
- package/dist/tools/trigger-elicitation-request.js +197 -196
- package/dist/tools/trigger-list-changed.js +57 -0
- package/dist/tools/trigger-log-messages.js +60 -0
- package/dist/tools/trigger-long-running-operation.js +3 -3
- package/dist/tools/trigger-multi-step-elicitation.js +125 -0
- package/dist/tools/trigger-resource-update.js +52 -0
- package/dist/tools/trigger-sampling-request-async.js +79 -143
- package/dist/tools/trigger-sampling-request.js +51 -45
- package/dist/tools/trigger-url-elicitation.js +148 -111
- package/dist/transports/sse.js +26 -6
- package/dist/transports/stdio.js +42 -22
- package/dist/transports/streamableHttp.js +110 -14
- package/package.json +12 -5
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
// The `trigger-elicitation-request` tool: asks the user to fill in a form
|
|
2
|
+
// that exercises every field type form-mode elicitation supports, and
|
|
3
|
+
// summarizes the answer.
|
|
4
|
+
//
|
|
5
|
+
// Written once for both protocol eras with a multi-round-trip request
|
|
6
|
+
// (#4852): the first call returns `input_required` carrying an
|
|
7
|
+
// `elicitation/create` request, the client shows the form and retries with
|
|
8
|
+
// the answer, and the retry summarizes it. A 2026-07-28 client does that
|
|
9
|
+
// in-band; for a 2025-era client the SDK's legacy shim sends a real
|
|
10
|
+
// `elicitation/create` request and re-enters the handler with the answer.
|
|
11
|
+
import { inputRequired, inputResponse, } from "@modelcontextprotocol/server";
|
|
2
12
|
// Tool configuration
|
|
3
13
|
const name = "trigger-elicitation-request";
|
|
4
14
|
const config = {
|
|
@@ -12,211 +22,202 @@ const config = {
|
|
|
12
22
|
openWorldHint: false,
|
|
13
23
|
},
|
|
14
24
|
};
|
|
25
|
+
/** The form: one field of each type form-mode elicitation supports. */
|
|
26
|
+
const requestedSchema = {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
name: {
|
|
30
|
+
title: "String",
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Your full, legal name",
|
|
33
|
+
},
|
|
34
|
+
check: {
|
|
35
|
+
title: "Boolean",
|
|
36
|
+
type: "boolean",
|
|
37
|
+
description: "Agree to the terms and conditions",
|
|
38
|
+
},
|
|
39
|
+
firstLine: {
|
|
40
|
+
title: "String with default",
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Favorite first line of a story",
|
|
43
|
+
default: "It was a dark and stormy night.",
|
|
44
|
+
},
|
|
45
|
+
email: {
|
|
46
|
+
title: "String with email format",
|
|
47
|
+
type: "string",
|
|
48
|
+
format: "email",
|
|
49
|
+
description: "Your email address (will be verified, and never shared with anyone else)",
|
|
50
|
+
},
|
|
51
|
+
homepage: {
|
|
52
|
+
type: "string",
|
|
53
|
+
format: "uri",
|
|
54
|
+
title: "String with uri format",
|
|
55
|
+
description: "Portfolio / personal website",
|
|
56
|
+
},
|
|
57
|
+
birthdate: {
|
|
58
|
+
title: "String with date format",
|
|
59
|
+
type: "string",
|
|
60
|
+
format: "date",
|
|
61
|
+
description: "Your date of birth",
|
|
62
|
+
},
|
|
63
|
+
integer: {
|
|
64
|
+
title: "Integer",
|
|
65
|
+
type: "integer",
|
|
66
|
+
description: "Your favorite integer (do not give us your phone number, pin, or other sensitive info)",
|
|
67
|
+
minimum: 1,
|
|
68
|
+
maximum: 100,
|
|
69
|
+
default: 42,
|
|
70
|
+
},
|
|
71
|
+
number: {
|
|
72
|
+
title: "Number in range 1-1000",
|
|
73
|
+
type: "number",
|
|
74
|
+
description: "Favorite number (there are no wrong answers)",
|
|
75
|
+
minimum: 0,
|
|
76
|
+
maximum: 1000,
|
|
77
|
+
default: 3.14,
|
|
78
|
+
},
|
|
79
|
+
untitledSingleSelectEnum: {
|
|
80
|
+
type: "string",
|
|
81
|
+
title: "Untitled Single Select Enum",
|
|
82
|
+
description: "Choose your favorite friend",
|
|
83
|
+
enum: ["Monica", "Rachel", "Joey", "Chandler", "Ross", "Phoebe"],
|
|
84
|
+
default: "Monica",
|
|
85
|
+
},
|
|
86
|
+
untitledMultipleSelectEnum: {
|
|
87
|
+
type: "array",
|
|
88
|
+
title: "Untitled Multiple Select Enum",
|
|
89
|
+
description: "Choose your favorite instruments",
|
|
90
|
+
minItems: 1,
|
|
91
|
+
maxItems: 3,
|
|
92
|
+
items: {
|
|
93
|
+
type: "string",
|
|
94
|
+
enum: ["Guitar", "Piano", "Violin", "Drums", "Bass"],
|
|
95
|
+
},
|
|
96
|
+
default: ["Guitar"],
|
|
97
|
+
},
|
|
98
|
+
titledSingleSelectEnum: {
|
|
99
|
+
type: "string",
|
|
100
|
+
title: "Titled Single Select Enum",
|
|
101
|
+
description: "Choose your favorite hero",
|
|
102
|
+
oneOf: [
|
|
103
|
+
{ const: "hero-1", title: "Superman" },
|
|
104
|
+
{ const: "hero-2", title: "Green Lantern" },
|
|
105
|
+
{ const: "hero-3", title: "Wonder Woman" },
|
|
106
|
+
],
|
|
107
|
+
default: "hero-1",
|
|
108
|
+
},
|
|
109
|
+
titledMultipleSelectEnum: {
|
|
110
|
+
type: "array",
|
|
111
|
+
title: "Titled Multiple Select Enum",
|
|
112
|
+
description: "Choose your favorite types of fish",
|
|
113
|
+
minItems: 1,
|
|
114
|
+
maxItems: 3,
|
|
115
|
+
items: {
|
|
116
|
+
anyOf: [
|
|
117
|
+
{ const: "fish-1", title: "Tuna" },
|
|
118
|
+
{ const: "fish-2", title: "Salmon" },
|
|
119
|
+
{ const: "fish-3", title: "Trout" },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
default: ["fish-1"],
|
|
123
|
+
},
|
|
124
|
+
legacyTitledEnum: {
|
|
125
|
+
type: "string",
|
|
126
|
+
title: "Legacy Titled Single Select Enum",
|
|
127
|
+
description: "Choose your favorite type of pet",
|
|
128
|
+
enum: ["pet-1", "pet-2", "pet-3", "pet-4", "pet-5"],
|
|
129
|
+
enumNames: ["Cats", "Dogs", "Birds", "Fish", "Reptiles"],
|
|
130
|
+
default: "pet-1",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
required: ["name"],
|
|
134
|
+
};
|
|
15
135
|
/**
|
|
16
136
|
* Registers the 'trigger-elicitation-request' tool.
|
|
17
137
|
*
|
|
18
|
-
* The tool
|
|
19
|
-
*
|
|
20
|
-
* `elicitation` object with neither `form` nor
|
|
21
|
-
* form mode for backwards compatibility
|
|
22
|
-
* `elicitation.url` does not get it (#4985).
|
|
138
|
+
* The tool needs a client that supports form-mode elicitation. On a 2025-era
|
|
139
|
+
* connection the server factory registers it only for a client that declared
|
|
140
|
+
* `elicitation.form`, or an `elicitation` object with neither `form` nor
|
|
141
|
+
* `url`, which the spec treats as form mode for backwards compatibility; a
|
|
142
|
+
* client that declared only `elicitation.url` does not get it (#4985). On
|
|
143
|
+
* 2026-07-28 the SDK refuses the embedded request (-32021) of a client whose
|
|
144
|
+
* request did not declare form-mode elicitation.
|
|
23
145
|
*
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* possible outcomes from the user's response, such as acceptance with content, decline,
|
|
28
|
-
* or cancellation of the dialog. The process also ensures parsing and validating
|
|
29
|
-
* the elicitation input arguments at runtime.
|
|
146
|
+
* The first round sends the form. The retry reads the user's response, which
|
|
147
|
+
* may be acceptance with content, decline, or cancellation of the dialog, and
|
|
148
|
+
* returns a structured summary with the raw result for debugging.
|
|
30
149
|
*
|
|
31
|
-
*
|
|
32
|
-
* which contains both user-submitted input data (if provided) and debugging information,
|
|
33
|
-
* including raw results.
|
|
34
|
-
*
|
|
35
|
-
* @param {McpServer} server - TThe McpServer instance where the tool will be registered.
|
|
150
|
+
* @param {McpServer} server - The McpServer instance where the tool will be registered.
|
|
36
151
|
*/
|
|
37
152
|
export const registerTriggerElicitationRequestTool = (server) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
params: {
|
|
49
|
-
message: "Please provide inputs for the following fields:",
|
|
50
|
-
requestedSchema: {
|
|
51
|
-
type: "object",
|
|
52
|
-
properties: {
|
|
53
|
-
name: {
|
|
54
|
-
title: "String",
|
|
55
|
-
type: "string",
|
|
56
|
-
description: "Your full, legal name",
|
|
57
|
-
},
|
|
58
|
-
check: {
|
|
59
|
-
title: "Boolean",
|
|
60
|
-
type: "boolean",
|
|
61
|
-
description: "Agree to the terms and conditions",
|
|
62
|
-
},
|
|
63
|
-
firstLine: {
|
|
64
|
-
title: "String with default",
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "Favorite first line of a story",
|
|
67
|
-
default: "It was a dark and stormy night.",
|
|
68
|
-
},
|
|
69
|
-
email: {
|
|
70
|
-
title: "String with email format",
|
|
71
|
-
type: "string",
|
|
72
|
-
format: "email",
|
|
73
|
-
description: "Your email address (will be verified, and never shared with anyone else)",
|
|
74
|
-
},
|
|
75
|
-
homepage: {
|
|
76
|
-
type: "string",
|
|
77
|
-
format: "uri",
|
|
78
|
-
title: "String with uri format",
|
|
79
|
-
description: "Portfolio / personal website",
|
|
80
|
-
},
|
|
81
|
-
birthdate: {
|
|
82
|
-
title: "String with date format",
|
|
83
|
-
type: "string",
|
|
84
|
-
format: "date",
|
|
85
|
-
description: "Your date of birth",
|
|
86
|
-
},
|
|
87
|
-
integer: {
|
|
88
|
-
title: "Integer",
|
|
89
|
-
type: "integer",
|
|
90
|
-
description: "Your favorite integer (do not give us your phone number, pin, or other sensitive info)",
|
|
91
|
-
minimum: 1,
|
|
92
|
-
maximum: 100,
|
|
93
|
-
default: 42,
|
|
94
|
-
},
|
|
95
|
-
number: {
|
|
96
|
-
title: "Number in range 1-1000",
|
|
97
|
-
type: "number",
|
|
98
|
-
description: "Favorite number (there are no wrong answers)",
|
|
99
|
-
minimum: 0,
|
|
100
|
-
maximum: 1000,
|
|
101
|
-
default: 3.14,
|
|
102
|
-
},
|
|
103
|
-
untitledSingleSelectEnum: {
|
|
104
|
-
type: "string",
|
|
105
|
-
title: "Untitled Single Select Enum",
|
|
106
|
-
description: "Choose your favorite friend",
|
|
107
|
-
enum: [
|
|
108
|
-
"Monica",
|
|
109
|
-
"Rachel",
|
|
110
|
-
"Joey",
|
|
111
|
-
"Chandler",
|
|
112
|
-
"Ross",
|
|
113
|
-
"Phoebe",
|
|
114
|
-
],
|
|
115
|
-
default: "Monica",
|
|
116
|
-
},
|
|
117
|
-
untitledMultipleSelectEnum: {
|
|
118
|
-
type: "array",
|
|
119
|
-
title: "Untitled Multiple Select Enum",
|
|
120
|
-
description: "Choose your favorite instruments",
|
|
121
|
-
minItems: 1,
|
|
122
|
-
maxItems: 3,
|
|
123
|
-
items: {
|
|
124
|
-
type: "string",
|
|
125
|
-
enum: ["Guitar", "Piano", "Violin", "Drums", "Bass"],
|
|
126
|
-
},
|
|
127
|
-
default: ["Guitar"],
|
|
128
|
-
},
|
|
129
|
-
titledSingleSelectEnum: {
|
|
130
|
-
type: "string",
|
|
131
|
-
title: "Titled Single Select Enum",
|
|
132
|
-
description: "Choose your favorite hero",
|
|
133
|
-
oneOf: [
|
|
134
|
-
{ const: "hero-1", title: "Superman" },
|
|
135
|
-
{ const: "hero-2", title: "Green Lantern" },
|
|
136
|
-
{ const: "hero-3", title: "Wonder Woman" },
|
|
137
|
-
],
|
|
138
|
-
default: "hero-1",
|
|
139
|
-
},
|
|
140
|
-
titledMultipleSelectEnum: {
|
|
141
|
-
type: "array",
|
|
142
|
-
title: "Titled Multiple Select Enum",
|
|
143
|
-
description: "Choose your favorite types of fish",
|
|
144
|
-
minItems: 1,
|
|
145
|
-
maxItems: 3,
|
|
146
|
-
items: {
|
|
147
|
-
anyOf: [
|
|
148
|
-
{ const: "fish-1", title: "Tuna" },
|
|
149
|
-
{ const: "fish-2", title: "Salmon" },
|
|
150
|
-
{ const: "fish-3", title: "Trout" },
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
default: ["fish-1"],
|
|
154
|
-
},
|
|
155
|
-
legacyTitledEnum: {
|
|
156
|
-
type: "string",
|
|
157
|
-
title: "Legacy Titled Single Select Enum",
|
|
158
|
-
description: "Choose your favorite type of pet",
|
|
159
|
-
enum: ["pet-1", "pet-2", "pet-3", "pet-4", "pet-5"],
|
|
160
|
-
enumNames: ["Cats", "Dogs", "Birds", "Fish", "Reptiles"],
|
|
161
|
-
default: "pet-1",
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
required: ["name"],
|
|
165
|
-
},
|
|
153
|
+
server.registerTool(name, config, async (_args, ctx) => {
|
|
154
|
+
const answer = inputResponse(ctx.mcpReq.inputResponses, "form");
|
|
155
|
+
// First round: show the user the form
|
|
156
|
+
if (answer.kind !== "elicit") {
|
|
157
|
+
return inputRequired({
|
|
158
|
+
inputRequests: {
|
|
159
|
+
form: inputRequired.elicit({
|
|
160
|
+
message: "Please provide inputs for the following fields:",
|
|
161
|
+
requestedSchema,
|
|
162
|
+
}),
|
|
166
163
|
},
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
// Include raw result for debugging
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// The answer as the client sent it, for the debugging output
|
|
167
|
+
const rawResult = {
|
|
168
|
+
action: answer.action,
|
|
169
|
+
...(answer.content !== undefined && { content: answer.content }),
|
|
170
|
+
};
|
|
171
|
+
// Handle different response actions
|
|
172
|
+
const content = [];
|
|
173
|
+
if (answer.action === "accept" && answer.content) {
|
|
174
|
+
content.push({
|
|
175
|
+
type: "text",
|
|
176
|
+
text: `✅ User provided the requested information!`,
|
|
177
|
+
});
|
|
178
|
+
// Only access answer.content when action is accept
|
|
179
|
+
const userData = answer.content;
|
|
180
|
+
const lines = [];
|
|
181
|
+
if (userData.name)
|
|
182
|
+
lines.push(`- Name: ${userData.name}`);
|
|
183
|
+
if (userData.check !== undefined)
|
|
184
|
+
lines.push(`- Agreed to terms: ${userData.check}`);
|
|
185
|
+
if (userData.color)
|
|
186
|
+
lines.push(`- Favorite Color: ${userData.color}`);
|
|
187
|
+
if (userData.email)
|
|
188
|
+
lines.push(`- Email: ${userData.email}`);
|
|
189
|
+
if (userData.homepage)
|
|
190
|
+
lines.push(`- Homepage: ${userData.homepage}`);
|
|
191
|
+
if (userData.birthdate)
|
|
192
|
+
lines.push(`- Birthdate: ${userData.birthdate}`);
|
|
193
|
+
if (userData.integer !== undefined)
|
|
194
|
+
lines.push(`- Favorite Integer: ${userData.integer}`);
|
|
195
|
+
if (userData.number !== undefined)
|
|
196
|
+
lines.push(`- Favorite Number: ${userData.number}`);
|
|
197
|
+
if (userData.petType)
|
|
198
|
+
lines.push(`- Pet Type: ${userData.petType}`);
|
|
199
|
+
content.push({
|
|
200
|
+
type: "text",
|
|
201
|
+
text: `User inputs:\n${lines.join("\n")}`,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
else if (answer.action === "decline") {
|
|
205
|
+
content.push({
|
|
206
|
+
type: "text",
|
|
207
|
+
text: `❌ User declined to provide the requested information.`,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else if (answer.action === "cancel") {
|
|
215
211
|
content.push({
|
|
216
212
|
type: "text",
|
|
217
|
-
text:
|
|
213
|
+
text: `⚠️ User cancelled the elicitation dialog.`,
|
|
218
214
|
});
|
|
219
|
-
|
|
215
|
+
}
|
|
216
|
+
// Include raw result for debugging
|
|
217
|
+
content.push({
|
|
218
|
+
type: "text",
|
|
219
|
+
text: `\nRaw result: ${JSON.stringify(rawResult, null, 2)}`,
|
|
220
220
|
});
|
|
221
|
-
|
|
221
|
+
return { content };
|
|
222
|
+
});
|
|
222
223
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// The `trigger-list-changed` tool: announces that the server's tool, prompt
|
|
2
|
+
// or resource list changed, so a client can watch the notification arrive.
|
|
3
|
+
//
|
|
4
|
+
// Where the notification goes depends on the protocol era (#4852). A
|
|
5
|
+
// 2025-era client gets it unsolicited. A 2026-07-28 client gets it only on a
|
|
6
|
+
// `subscriptions/listen` stream whose filter asked for that list
|
|
7
|
+
// (`toolsListChanged`, `promptsListChanged` or `resourcesListChanged`). The
|
|
8
|
+
// server context's publisher picks the route: the instance itself on stdio
|
|
9
|
+
// and on a 2025-era session, the handler's subscription bus on the 2026-07-28
|
|
10
|
+
// HTTP path.
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
// Tool input schema
|
|
13
|
+
const TriggerListChangedSchema = z.object({
|
|
14
|
+
list: z
|
|
15
|
+
.enum(["tools", "prompts", "resources"])
|
|
16
|
+
.describe("Which list to announce as changed"),
|
|
17
|
+
});
|
|
18
|
+
// Tool configuration
|
|
19
|
+
const name = "trigger-list-changed";
|
|
20
|
+
const config = {
|
|
21
|
+
title: "Trigger List Changed Tool",
|
|
22
|
+
description: "Sends a notifications/<list>/list_changed for the tool, prompt or resource list. On protocol version " +
|
|
23
|
+
"2026-07-28 it is delivered on each subscriptions/listen stream that asked for that list; a 2025-era " +
|
|
24
|
+
"client receives it unsolicited.",
|
|
25
|
+
inputSchema: TriggerListChangedSchema,
|
|
26
|
+
annotations: {
|
|
27
|
+
readOnlyHint: true,
|
|
28
|
+
destructiveHint: false,
|
|
29
|
+
idempotentHint: false,
|
|
30
|
+
openWorldHint: false,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Registers the 'trigger-list-changed' tool.
|
|
35
|
+
*
|
|
36
|
+
* @param {McpServer} server - The McpServer instance where the tool will be registered.
|
|
37
|
+
* @param {ServerContext} context - Where the instance's change notifications go.
|
|
38
|
+
*/
|
|
39
|
+
export const registerTriggerListChangedTool = (server, context) => {
|
|
40
|
+
server.registerTool(name, config, async (args) => {
|
|
41
|
+
const { list } = TriggerListChangedSchema.parse(args);
|
|
42
|
+
if (list === "tools")
|
|
43
|
+
context.publish.toolsChanged();
|
|
44
|
+
else if (list === "prompts")
|
|
45
|
+
context.publish.promptsChanged();
|
|
46
|
+
else
|
|
47
|
+
context.publish.resourcesChanged();
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: `Sent notifications/${list}/list_changed`,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// The `trigger-log-messages` tool: sends one log message at each logging
|
|
2
|
+
// level during the call, so a client can see which ones its level lets
|
|
3
|
+
// through.
|
|
4
|
+
//
|
|
5
|
+
// The level is set differently on each protocol era (#4852). A 2026-07-28
|
|
6
|
+
// client names it per request, in the request's `_meta`
|
|
7
|
+
// (`io.modelcontextprotocol/logLevel`), and a request that names none gets no
|
|
8
|
+
// log messages at all. A 2025-era client sets it for the whole session with
|
|
9
|
+
// `logging/setLevel`. The SDK applies whichever filter the request has, so
|
|
10
|
+
// the handler is the same for both. Logging is deprecated as of 2026-07-28
|
|
11
|
+
// (SEP-2577); this replaces `toggle-simulated-logging`, whose timer relies on
|
|
12
|
+
// `logging/setLevel` and unsolicited messages, which 2026-07-28 removes.
|
|
13
|
+
/** Every logging level, from least to most severe. */
|
|
14
|
+
export const LOGGING_LEVELS = [
|
|
15
|
+
"debug",
|
|
16
|
+
"info",
|
|
17
|
+
"notice",
|
|
18
|
+
"warning",
|
|
19
|
+
"error",
|
|
20
|
+
"critical",
|
|
21
|
+
"alert",
|
|
22
|
+
"emergency",
|
|
23
|
+
];
|
|
24
|
+
// Tool configuration
|
|
25
|
+
const name = "trigger-log-messages";
|
|
26
|
+
const config = {
|
|
27
|
+
title: "Trigger Log Messages Tool",
|
|
28
|
+
description: "Sends one log message at each logging level during the call. On protocol version 2026-07-28 only " +
|
|
29
|
+
"the messages at or above the level the request names in _meta (io.modelcontextprotocol/logLevel) " +
|
|
30
|
+
"are sent, and none if it names no level; a 2025-era client gets those at or above the level it set " +
|
|
31
|
+
"with logging/setLevel. Deprecated: logging is deprecated as of protocol version 2026-07-28.",
|
|
32
|
+
inputSchema: {},
|
|
33
|
+
annotations: {
|
|
34
|
+
readOnlyHint: true,
|
|
35
|
+
destructiveHint: false,
|
|
36
|
+
idempotentHint: true,
|
|
37
|
+
openWorldHint: false,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Registers the 'trigger-log-messages' tool.
|
|
42
|
+
*
|
|
43
|
+
* @param {McpServer} server - The McpServer instance where the tool will be registered.
|
|
44
|
+
*/
|
|
45
|
+
export const registerTriggerLogMessagesTool = (server) => {
|
|
46
|
+
server.registerTool(name, config, async (_args, ctx) => {
|
|
47
|
+
for (const level of LOGGING_LEVELS) {
|
|
48
|
+
await ctx.mcpReq.log(level, `${level}-level message`, "everything");
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: "text",
|
|
54
|
+
text: `Sent one log message at each of ${LOGGING_LEVELS.length} levels (${LOGGING_LEVELS.join(", ")}). ` +
|
|
55
|
+
"The ones below this request's log level were dropped.",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
};
|
|
@@ -35,11 +35,11 @@ const config = {
|
|
|
35
35
|
* @param {McpServer} server - The McpServer instance where the tool will be registered.
|
|
36
36
|
*/
|
|
37
37
|
export const registerTriggerLongRunningOperationTool = (server) => {
|
|
38
|
-
server.registerTool(name, config, async (args,
|
|
38
|
+
server.registerTool(name, config, async (args, ctx) => {
|
|
39
39
|
const validatedArgs = TriggerLongRunningOperationSchema.parse(args);
|
|
40
40
|
const { duration, steps } = validatedArgs;
|
|
41
41
|
const stepDuration = duration / steps;
|
|
42
|
-
const progressToken =
|
|
42
|
+
const progressToken = ctx.mcpReq._meta?.progressToken;
|
|
43
43
|
for (let i = 1; i < steps + 1; i++) {
|
|
44
44
|
await new Promise((resolve) => setTimeout(resolve, stepDuration * 1000));
|
|
45
45
|
if (progressToken !== undefined) {
|
|
@@ -50,7 +50,7 @@ export const registerTriggerLongRunningOperationTool = (server) => {
|
|
|
50
50
|
total: steps,
|
|
51
51
|
progressToken,
|
|
52
52
|
},
|
|
53
|
-
}, { relatedRequestId:
|
|
53
|
+
}, { relatedRequestId: ctx.mcpReq.id });
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
return {
|