get_metrics
Retrieve performance metrics for the MCP Filesystem Server to monitor operations, optimize efficiency, and debug issues in real-time.
Instructions
Returns performance metrics about server operations. Useful for monitoring and debugging.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:721-734 (handler)Handler for the 'get_metrics' tool. Calls metrics.getMetrics() and returns the data as formatted JSON text content.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)Tool registration entry in the list_tools response, including name, 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:93-112 (helper)The getMetrics() method in the metrics class that aggregates operation statistics and uptime, returning a record of metrics results. Called by the tool handler.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 }