mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-02-19 11:54:58 -05:00
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 https://github.com/modelcontextprotocol/inspector/pull/286
This commit is contained in:
@@ -114,8 +114,9 @@ export const createServer = () => {
|
||||
|
||||
let subscriptions: Set<string> = new Set();
|
||||
let subsUpdateInterval: NodeJS.Timeout | undefined;
|
||||
// Set up update interval for subscribed resources
|
||||
let stdErrUpdateInterval: NodeJS.Timeout | undefined;
|
||||
|
||||
// Set up update interval for subscribed resources
|
||||
subsUpdateInterval = setInterval(() => {
|
||||
for (const uri of subscriptions) {
|
||||
server.notification({
|
||||
@@ -154,6 +155,19 @@ export const createServer = () => {
|
||||
server.notification(message);
|
||||
}, 15000);
|
||||
|
||||
|
||||
// Set up update interval for stderr messages
|
||||
stdErrUpdateInterval = setInterval(() => {
|
||||
const shortTimestamp = new Date().toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
}); server.notification({
|
||||
method: "notifications/stderr",
|
||||
params: { content: `${shortTimestamp}: A stderr message` },
|
||||
});
|
||||
}, 10000);
|
||||
|
||||
// Helper method to request sampling from client
|
||||
const requestSampling = async (
|
||||
context: string,
|
||||
@@ -676,6 +690,7 @@ export const createServer = () => {
|
||||
const cleanup = async () => {
|
||||
if (subsUpdateInterval) clearInterval(subsUpdateInterval);
|
||||
if (logsUpdateInterval) clearInterval(logsUpdateInterval);
|
||||
if (stdErrUpdateInterval) clearInterval(stdErrUpdateInterval);
|
||||
};
|
||||
|
||||
return { server, cleanup };
|
||||
|
||||
Reference in New Issue
Block a user