example and more documentation
This commit is contained in:
parent
b2fea383dd
commit
112eed999c
1 changed files with 74 additions and 5 deletions
|
|
@ -12,6 +12,21 @@ const server = new McpServer({
|
|||
version: '1.0.0',
|
||||
}, { capabilities: { logging: {} } });
|
||||
|
||||
// Log the capability invocation details
|
||||
server.onCapabilityChange((event) => {
|
||||
switch (event.action) {
|
||||
case 'invoked':
|
||||
console.log(`${event.capabilityType} invocation ${event.invocationIndex}: '${event.capabilityName}' started`);
|
||||
break;
|
||||
case 'completed':
|
||||
console.log(`${event.capabilityType} invocation ${event.invocationIndex}: '${event.capabilityName}' completed in ${event.durationMs}ms`);
|
||||
break;
|
||||
case 'error':
|
||||
console.log(`${event.capabilityType} invocation ${event.invocationIndex}: '${event.capabilityName}' failed in ${event.durationMs}ms: ${event.error}`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// Register a simple tool that returns a greeting
|
||||
server.tool(
|
||||
'greet',
|
||||
|
|
@ -291,4 +306,4 @@ process.on('SIGINT', async () => {
|
|||
await server.close();
|
||||
console.log('Server shutdown complete');
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue