Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 16 additions & 1 deletion src/examples/server/simpleStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -291,4 +306,4 @@ process.on('SIGINT', async () => {
await server.close();
console.log('Server shutdown complete');
process.exit(0);
});
});
7 changes: 7 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ export class Server<
);
}

/**
* The server's name and version.
*/
getVersion(): { readonly name: string; readonly version: string } {
return this._serverInfo;
}

/**
* Registers new capabilities. This can only be called before connecting to a transport.
*
Expand Down
Loading