Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add periodic logging messages to Everything server. #847

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/everything/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ Resource features:
- `style` (string): Output style preference
- Returns: Multi-turn conversation with images

### Logging

The server sends random-leveled log messages every 15 seconds, e.g.:

```json
{
"method": "notifications/message",
"params": {
"level": "info",
"data": "Information is good"
}
}
```

## Usage with Claude Desktop

Add to your `claude_desktop_config.json`:
Expand Down
31 changes: 23 additions & 8 deletions src/everything/everything.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ export const createServer = () => {
);

let subscriptions: Set<string> = new Set();
let updateInterval: NodeJS.Timeout | undefined;
let subsUpdateInterval: NodeJS.Timeout | undefined;
let logsUpdateInterval: NodeJS.Timeout | undefined;

// Set up update interval for subscribed resources
updateInterval = setInterval(() => {
subsUpdateInterval = setInterval(() => {
for (const uri of subscriptions) {
server.notification({
method: "notifications/resources/updated",
Expand All @@ -111,6 +112,21 @@ export const createServer = () => {
}
}, 5000);

// Set up update interval for random log messages
logsUpdateInterval = setInterval(() => {
const messages = [
{level: "info", data: "Information is good"},
{level: "warning", data: "Warning is scary"},
{level: "error", data: "Error is bad"},
]
server.notification({
method: "notifications/message",
params: messages[Math.floor(Math.random()*3)],
});
}, 15000);



// Helper method to request sampling from client
const requestSampling = async (
context: string,
Expand Down Expand Up @@ -451,7 +467,7 @@ export const createServer = () => {

if (name === ToolName.ANNOTATED_MESSAGE) {
const { messageType, includeImage } = AnnotatedMessageSchema.parse(args);

const content = [];

// Main message with different priorities/audiences based on type
Expand Down Expand Up @@ -511,7 +527,7 @@ export const createServer = () => {
if (!resourceId) return { completion: { values: [] } };

// Filter resource IDs that start with the input value
const values = EXAMPLE_COMPLETIONS.resourceId.filter(id =>
const values = EXAMPLE_COMPLETIONS.resourceId.filter(id =>
id.startsWith(argument.value)
);
return { completion: { values, hasMore: false, total: values.length } };
Expand All @@ -522,7 +538,7 @@ export const createServer = () => {
const completions = EXAMPLE_COMPLETIONS[argument.name as keyof typeof EXAMPLE_COMPLETIONS];
if (!completions) return { completion: { values: [] } };

const values = completions.filter(value =>
const values = completions.filter(value =>
value.startsWith(argument.value)
);
return { completion: { values, hasMore: false, total: values.length } };
Expand All @@ -548,9 +564,8 @@ export const createServer = () => {
});

const cleanup = async () => {
if (updateInterval) {
clearInterval(updateInterval);
}
if (subsUpdateInterval) clearInterval(subsUpdateInterval);
if (logsUpdateInterval) clearInterval(logsUpdateInterval);
};

return { server, cleanup };
Expand Down
Loading