get_metrics
Retrieve performance metrics from the MCP Filesystem Server to monitor operations and troubleshoot issues effectively.
Instructions
Returns performance metrics about server operations. Useful for monitoring and debugging.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:721-734 (handler)Handler for the 'get_metrics' tool. Retrieves metrics data using metrics.getMetrics() and returns it as formatted JSON.
case 'get_metrics': { const metricsData = metrics.getMetrics() await logger.debug('Retrieved metrics') endMetric() return { content: [ { type: 'text', text: JSON.stringify(metricsData, null, 2), }, ], } } - src/index.ts:336-346 (registration)Registration of the 'get_metrics' tool in the list of available tools, including its description and empty input schema.
{ name: 'get_metrics', description: 'Returns performance metrics about server operations. ' + 'Useful for monitoring and debugging.', inputSchema: { type: 'object', properties: {}, required: [], }, }, - src/metrics/index.ts:23-27 (schema)Type definition for MetricsResult, used in the output of getMetrics(). Defines structure of metrics data for each operation.
export interface MetricsResult { count: number errors: number avgTime: number } - src/metrics/index.ts:93-112 (helper)Core implementation of getMetrics() method in OperationMetrics class. Computes and returns metrics for all tracked operations including uptime.
public getMetrics(): Record<string, MetricsResult> { const result: Record<string, MetricsResult> = {} for (const [name, data] of Object.entries(this.operations)) { result[name] = { count: data.count, errors: data.errors, avgTime: data.count > 0 ? data.totalTime / data.count : 0, } } // Add uptime metric result['uptime_ms'] = { count: 1, errors: 0, avgTime: performance.now() - this.startTime, } return result }