Skip to content

Commit 9655d47

Browse files
committed
Add periodic stderr messages.
In everything.ts - add a 10 second interval for sending 'notifications/stderr' messages to the client This was created in order to test the display and clearing of stderr messages in the client. - see modelcontextprotocol/inspector#286
1 parent 1ba2678 commit 9655d47

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/everything/everything.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ export const createServer = () => {
114114

115115
let subscriptions: Set<string> = new Set();
116116
let subsUpdateInterval: NodeJS.Timeout | undefined;
117-
// Set up update interval for subscribed resources
117+
let stdErrUpdateInterval: NodeJS.Timeout | undefined;
118118

119+
// Set up update interval for subscribed resources
119120
subsUpdateInterval = setInterval(() => {
120121
for (const uri of subscriptions) {
121122
server.notification({
@@ -154,6 +155,19 @@ export const createServer = () => {
154155
server.notification(message);
155156
}, 15000);
156157

158+
159+
// Set up update interval for stderr messages
160+
stdErrUpdateInterval = setInterval(() => {
161+
const shortTimestamp = new Date().toLocaleTimeString([], {
162+
hour: '2-digit',
163+
minute: '2-digit',
164+
second: '2-digit'
165+
}); server.notification({
166+
method: "notifications/stderr",
167+
params: { content: `${shortTimestamp}: A stderr message` },
168+
});
169+
}, 10000);
170+
157171
// Helper method to request sampling from client
158172
const requestSampling = async (
159173
context: string,
@@ -676,6 +690,7 @@ export const createServer = () => {
676690
const cleanup = async () => {
677691
if (subsUpdateInterval) clearInterval(subsUpdateInterval);
678692
if (logsUpdateInterval) clearInterval(logsUpdateInterval);
693+
if (stdErrUpdateInterval) clearInterval(stdErrUpdateInterval);
679694
};
680695

681696
return { server, cleanup };

0 commit comments

Comments
 (0)