midnight-mcp 0.1.38 → 0.1.39
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/server.js +10 -1
- package/dist/utils/hosted-api.d.ts +5 -0
- package/dist/utils/hosted-api.js +13 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourceTemplatesRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, SetLevelRequestSchema, CompleteRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import { logger, formatErrorResponse, setMCPLogCallback, } from "./utils/index.js";
|
|
4
|
+
import { logger, formatErrorResponse, setMCPLogCallback, trackToolCall, } from "./utils/index.js";
|
|
5
5
|
import { vectorStore } from "./db/index.js";
|
|
6
6
|
import { allTools } from "./tools/index.js";
|
|
7
7
|
import { allResources, getDocumentation, getCode, getSchema, } from "./resources/index.js";
|
|
@@ -329,12 +329,15 @@ function registerToolHandlers(server) {
|
|
|
329
329
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
330
330
|
const { name, arguments: args } = request.params;
|
|
331
331
|
logger.info(`Tool called: ${name}`, { args });
|
|
332
|
+
const startTime = Date.now();
|
|
332
333
|
const tool = allTools.find((t) => t.name === name);
|
|
333
334
|
if (!tool) {
|
|
334
335
|
const availableTools = allTools
|
|
335
336
|
.map((t) => t.name)
|
|
336
337
|
.slice(0, 5)
|
|
337
338
|
.join(", ");
|
|
339
|
+
// Track failed tool call (unknown tool)
|
|
340
|
+
trackToolCall(name, false, Date.now() - startTime, CURRENT_VERSION);
|
|
338
341
|
return {
|
|
339
342
|
content: [
|
|
340
343
|
{
|
|
@@ -351,6 +354,9 @@ function registerToolHandlers(server) {
|
|
|
351
354
|
}
|
|
352
355
|
try {
|
|
353
356
|
const result = await tool.handler(args);
|
|
357
|
+
const durationMs = Date.now() - startTime;
|
|
358
|
+
// Track successful tool call (fire-and-forget, won't block response)
|
|
359
|
+
trackToolCall(name, true, durationMs, CURRENT_VERSION);
|
|
354
360
|
// Include prominent update prompt in ALL responses when outdated
|
|
355
361
|
const updateWarning = getUpdateWarning();
|
|
356
362
|
if (updateWarning && versionCheckResult.isOutdated) {
|
|
@@ -398,7 +404,10 @@ function registerToolHandlers(server) {
|
|
|
398
404
|
};
|
|
399
405
|
}
|
|
400
406
|
catch (error) {
|
|
407
|
+
const durationMs = Date.now() - startTime;
|
|
401
408
|
logger.error(`Tool error: ${name}`, { error: String(error) });
|
|
409
|
+
// Track failed tool call
|
|
410
|
+
trackToolCall(name, false, durationMs, CURRENT_VERSION);
|
|
402
411
|
const errorResponse = formatErrorResponse(error, `tool:${name}`);
|
|
403
412
|
return {
|
|
404
413
|
content: [
|
|
@@ -59,4 +59,9 @@ export declare function getHostedApiStats(): Promise<{
|
|
|
59
59
|
documentsIndexed: number;
|
|
60
60
|
repositories: number;
|
|
61
61
|
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Track a tool call to the hosted API
|
|
64
|
+
* Fire-and-forget - doesn't block on response
|
|
65
|
+
*/
|
|
66
|
+
export declare function trackToolCall(tool: string, success: boolean, durationMs?: number, version?: string): void;
|
|
62
67
|
//# sourceMappingURL=hosted-api.d.ts.map
|
package/dist/utils/hosted-api.js
CHANGED
|
@@ -103,4 +103,17 @@ export async function checkHostedApiHealth() {
|
|
|
103
103
|
export async function getHostedApiStats() {
|
|
104
104
|
return apiRequest("/v1/stats");
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Track a tool call to the hosted API
|
|
108
|
+
* Fire-and-forget - doesn't block on response
|
|
109
|
+
*/
|
|
110
|
+
export function trackToolCall(tool, success, durationMs, version) {
|
|
111
|
+
// Fire and forget - don't await, don't block
|
|
112
|
+
apiRequest("/v1/track/tool", {
|
|
113
|
+
method: "POST",
|
|
114
|
+
body: JSON.stringify({ tool, success, durationMs, version }),
|
|
115
|
+
}).catch(() => {
|
|
116
|
+
// Silently ignore tracking errors
|
|
117
|
+
});
|
|
118
|
+
}
|
|
106
119
|
//# sourceMappingURL=hosted-api.js.map
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export { updateRateLimitFromHeaders, updateRateLimit, getRateLimitStatus, should
|
|
|
11
11
|
export type { RateLimitInfo, RateLimitStatus } from "./rate-limit.js";
|
|
12
12
|
export { Cache, createCacheKey, searchCache, fileCache, metadataCache, pruneAllCaches, } from "./cache.js";
|
|
13
13
|
export type { CacheOptions, CacheEntry, CacheStats } from "./cache.js";
|
|
14
|
-
export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, } from "./hosted-api.js";
|
|
14
|
+
export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, trackToolCall, } from "./hosted-api.js";
|
|
15
15
|
export type { HostedSearchResult, HostedSearchResponse, HostedSearchFilter, } from "./hosted-api.js";
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/utils/index.js
CHANGED
|
@@ -11,5 +11,5 @@ export { updateRateLimitFromHeaders, updateRateLimit, getRateLimitStatus, should
|
|
|
11
11
|
// Caching utilities
|
|
12
12
|
export { Cache, createCacheKey, searchCache, fileCache, metadataCache, pruneAllCaches, } from "./cache.js";
|
|
13
13
|
// Hosted API client
|
|
14
|
-
export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, } from "./hosted-api.js";
|
|
14
|
+
export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, trackToolCall, } from "./hosted-api.js";
|
|
15
15
|
//# sourceMappingURL=index.js.map
|