vcluster-yaml-mcp-server 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http-server.js +9 -4
- package/package.json +1 -1
package/dist/http-server.js
CHANGED
|
@@ -17,7 +17,7 @@ promClient.collectDefaultMetrics({ register });
|
|
|
17
17
|
const mcpRequestCounter = new promClient.Counter({
|
|
18
18
|
name: 'mcp_requests_total',
|
|
19
19
|
help: 'Total MCP requests',
|
|
20
|
-
labelNames: ['method', 'status'],
|
|
20
|
+
labelNames: ['method', 'status', 'mcp_method', 'tool_name'],
|
|
21
21
|
registers: [register]
|
|
22
22
|
});
|
|
23
23
|
const mcpRequestDuration = new promClient.Histogram({
|
|
@@ -93,7 +93,10 @@ app.get('/', (_req, res) => {
|
|
|
93
93
|
const mcpHandler = async (req, res) => {
|
|
94
94
|
const start = Date.now();
|
|
95
95
|
const clientIp = req.ip || req.headers['x-forwarded-for'] || req.socket.remoteAddress;
|
|
96
|
-
|
|
96
|
+
const jsonrpcPreview = req.body;
|
|
97
|
+
const mcpMethodLog = jsonrpcPreview?.method || 'unknown';
|
|
98
|
+
const toolLog = (mcpMethodLog === 'tools/call' && jsonrpcPreview?.params?.name) ? ` tool=${jsonrpcPreview.params.name}` : '';
|
|
99
|
+
console.log(`MCP ${req.method} ${mcpMethodLog}${toolLog} from ${clientIp}`);
|
|
97
100
|
// Extract JSONRPC request details for tracing
|
|
98
101
|
const jsonrpcRequest = req.body;
|
|
99
102
|
const mcpMethod = jsonrpcRequest?.method || 'unknown';
|
|
@@ -128,11 +131,13 @@ const mcpHandler = async (req, res) => {
|
|
|
128
131
|
const server = createServer();
|
|
129
132
|
await server.connect(transport);
|
|
130
133
|
await transport.handleRequest(req, res, req.body);
|
|
131
|
-
|
|
134
|
+
const toolName = (mcpMethod === 'tools/call' && mcpParams?.name) ? mcpParams.name : '';
|
|
135
|
+
mcpRequestCounter.inc({ method: req.method, status: 'success', mcp_method: mcpMethod, tool_name: toolName });
|
|
132
136
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
133
137
|
}
|
|
134
138
|
catch (error) {
|
|
135
|
-
|
|
139
|
+
const toolNameErr = (mcpMethod === 'tools/call' && mcpParams?.name) ? mcpParams.name : '';
|
|
140
|
+
mcpRequestCounter.inc({ method: req.method, status: 'error', mcp_method: mcpMethod, tool_name: toolNameErr });
|
|
136
141
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
137
142
|
span.setStatus({ code: SpanStatusCode.ERROR, message: errorMessage });
|
|
138
143
|
span.recordException(error instanceof Error ? error : new Error(errorMessage));
|