@virsanghavi/axis-server 1.6.0 → 1.7.1
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/mcp-server.mjs +48 -25
- package/package.json +1 -1
package/dist/mcp-server.mjs
CHANGED
|
@@ -1035,12 +1035,13 @@ ${conventions}`;
|
|
|
1035
1035
|
}
|
|
1036
1036
|
// --- Billing & Usage ---
|
|
1037
1037
|
async getSubscriptionStatus(email) {
|
|
1038
|
-
logger.info(`[getSubscriptionStatus] Starting - email: ${email}`);
|
|
1038
|
+
logger.info(`[getSubscriptionStatus] Starting - email: ${email || "(API key identity)"}`);
|
|
1039
1039
|
logger.info(`[getSubscriptionStatus] Config - apiUrl: ${this.contextManager.apiUrl}, apiSecret: ${this.contextManager.apiSecret ? "SET" : "NOT SET"}, useSupabase: ${this.useSupabase}`);
|
|
1040
1040
|
if (this.contextManager.apiUrl) {
|
|
1041
1041
|
try {
|
|
1042
|
-
|
|
1043
|
-
|
|
1042
|
+
const endpoint = email ? `usage?email=${encodeURIComponent(email)}` : "usage";
|
|
1043
|
+
logger.info(`[getSubscriptionStatus] Attempting API call to: ${endpoint}`);
|
|
1044
|
+
const result = await this.callCoordination(endpoint);
|
|
1044
1045
|
logger.info(`[getSubscriptionStatus] API call successful: ${JSON.stringify(result).substring(0, 200)}`);
|
|
1045
1046
|
return result;
|
|
1046
1047
|
} catch (e) {
|
|
@@ -1050,8 +1051,8 @@ ${conventions}`;
|
|
|
1050
1051
|
} else {
|
|
1051
1052
|
logger.warn("[getSubscriptionStatus] No API URL configured");
|
|
1052
1053
|
}
|
|
1053
|
-
if (this.useSupabase && this.supabase) {
|
|
1054
|
-
const { data: profile, error } = await this.supabase.from("profiles").select("subscription_status, stripe_customer_id, current_period_end").
|
|
1054
|
+
if (this.useSupabase && this.supabase && email) {
|
|
1055
|
+
const { data: profile, error } = await this.supabase.from("profiles").select("subscription_status, stripe_customer_id, current_period_end").ilike("email", email).single();
|
|
1055
1056
|
if (error || !profile) {
|
|
1056
1057
|
return { status: "unknown", message: "Profile not found." };
|
|
1057
1058
|
}
|
|
@@ -1066,21 +1067,22 @@ ${conventions}`;
|
|
|
1066
1067
|
return { error: "Coordination not configured. API URL not set and Supabase not available." };
|
|
1067
1068
|
}
|
|
1068
1069
|
async getUsageStats(email) {
|
|
1069
|
-
logger.info(`[getUsageStats] Starting - email: ${email}`);
|
|
1070
|
+
logger.info(`[getUsageStats] Starting - email: ${email || "(API key identity)"}`);
|
|
1070
1071
|
logger.info(`[getUsageStats] Config - apiUrl: ${this.contextManager.apiUrl}, apiSecret: ${this.contextManager.apiSecret ? "SET" : "NOT SET"}, useSupabase: ${this.useSupabase}`);
|
|
1071
1072
|
if (this.contextManager.apiUrl) {
|
|
1072
1073
|
try {
|
|
1073
|
-
|
|
1074
|
-
|
|
1074
|
+
const endpoint = email ? `usage?email=${encodeURIComponent(email)}` : "usage";
|
|
1075
|
+
logger.info(`[getUsageStats] Attempting API call to: ${endpoint}`);
|
|
1076
|
+
const result = await this.callCoordination(endpoint);
|
|
1075
1077
|
logger.info(`[getUsageStats] API call successful: ${JSON.stringify(result).substring(0, 200)}`);
|
|
1076
|
-
return { email, usageCount: result.usageCount || 0 };
|
|
1078
|
+
return { email: email || result.email, usageCount: result.usageCount || 0 };
|
|
1077
1079
|
} catch (e) {
|
|
1078
1080
|
logger.error(`[getUsageStats] API call failed: ${e.message}`, e);
|
|
1079
1081
|
return { error: `API call failed: ${e.message}` };
|
|
1080
1082
|
}
|
|
1081
1083
|
}
|
|
1082
|
-
if (this.useSupabase && this.supabase) {
|
|
1083
|
-
const { data: profile } = await this.supabase.from("profiles").select("usage_count").
|
|
1084
|
+
if (this.useSupabase && this.supabase && email) {
|
|
1085
|
+
const { data: profile } = await this.supabase.from("profiles").select("usage_count").ilike("email", email).single();
|
|
1084
1086
|
return { email, usageCount: profile?.usage_count || 0 };
|
|
1085
1087
|
}
|
|
1086
1088
|
return { error: "Coordination not configured. API URL not set and Supabase not available." };
|
|
@@ -1424,11 +1426,18 @@ async function searchFile(filePath, rootDir, keywords) {
|
|
|
1424
1426
|
const relativePath = path3.relative(rootDir, filePath);
|
|
1425
1427
|
const matchedKeywords = keywords.filter((kw) => contentLower.includes(kw));
|
|
1426
1428
|
if (matchedKeywords.length === 0) return null;
|
|
1429
|
+
const coverage = matchedKeywords.length / keywords.length;
|
|
1430
|
+
if (keywords.length >= 3 && coverage < 0.4) return null;
|
|
1431
|
+
if (keywords.length === 2 && matchedKeywords.length < 1) return null;
|
|
1427
1432
|
const lines = content.split("\n");
|
|
1428
|
-
let score = matchedKeywords.length;
|
|
1433
|
+
let score = coverage * coverage * matchedKeywords.length;
|
|
1429
1434
|
const relLower = relativePath.toLowerCase();
|
|
1435
|
+
let pathMatches = 0;
|
|
1430
1436
|
for (const kw of keywords) {
|
|
1431
|
-
if (relLower.includes(kw))
|
|
1437
|
+
if (relLower.includes(kw)) {
|
|
1438
|
+
score += 3;
|
|
1439
|
+
pathMatches++;
|
|
1440
|
+
}
|
|
1432
1441
|
}
|
|
1433
1442
|
const matchingLineIndices = [];
|
|
1434
1443
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -1437,6 +1446,22 @@ async function searchFile(filePath, rootDir, keywords) {
|
|
|
1437
1446
|
matchingLineIndices.push(i);
|
|
1438
1447
|
}
|
|
1439
1448
|
}
|
|
1449
|
+
let proximityBonus = 0;
|
|
1450
|
+
for (let i = 0; i < matchingLineIndices.length; i++) {
|
|
1451
|
+
const windowStart = matchingLineIndices[i];
|
|
1452
|
+
const windowEnd = windowStart + 10;
|
|
1453
|
+
const keywordsInWindow = /* @__PURE__ */ new Set();
|
|
1454
|
+
for (let j = i; j < matchingLineIndices.length && matchingLineIndices[j] <= windowEnd; j++) {
|
|
1455
|
+
const lineLower = lines[matchingLineIndices[j]].toLowerCase();
|
|
1456
|
+
for (const kw of matchedKeywords) {
|
|
1457
|
+
if (lineLower.includes(kw)) keywordsInWindow.add(kw);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (keywordsInWindow.size >= 2) {
|
|
1461
|
+
proximityBonus = Math.max(proximityBonus, keywordsInWindow.size * 1.5);
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
score += proximityBonus;
|
|
1440
1465
|
score += Math.min(matchingLineIndices.length, 20) * 0.1;
|
|
1441
1466
|
const regions = [];
|
|
1442
1467
|
let lastEnd = -1;
|
|
@@ -1888,24 +1913,22 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
1888
1913
|
// --- Billing & Usage ---
|
|
1889
1914
|
{
|
|
1890
1915
|
name: "get_subscription_status",
|
|
1891
|
-
description: "**BILLING CHECK**:
|
|
1916
|
+
description: "**BILLING CHECK**: Returns the user's subscription tier (Pro vs Free), Stripe customer ID, and current period end.\n- If no email is provided, returns the subscription status of the current API key owner.\n- Critical for gating features behind paywalls.",
|
|
1892
1917
|
inputSchema: {
|
|
1893
1918
|
type: "object",
|
|
1894
1919
|
properties: {
|
|
1895
|
-
email: { type: "string", description: "User email to check." }
|
|
1896
|
-
}
|
|
1897
|
-
required: ["email"]
|
|
1920
|
+
email: { type: "string", description: "Optional. User email to check. If omitted, checks the subscription of the current API key owner." }
|
|
1921
|
+
}
|
|
1898
1922
|
}
|
|
1899
1923
|
},
|
|
1900
1924
|
{
|
|
1901
1925
|
name: "get_usage_stats",
|
|
1902
|
-
description: "**API USAGE**: Returns
|
|
1926
|
+
description: "**API USAGE**: Returns token usage and request counts.\n- If no email is provided, returns usage for the current API key owner.\n- Useful for debugging rate limits or explaining quota usage to users.",
|
|
1903
1927
|
inputSchema: {
|
|
1904
1928
|
type: "object",
|
|
1905
1929
|
properties: {
|
|
1906
|
-
email: { type: "string", description: "User email to check." }
|
|
1907
|
-
}
|
|
1908
|
-
required: ["email"]
|
|
1930
|
+
email: { type: "string", description: "Optional. User email to check. If omitted, checks usage of the current API key owner." }
|
|
1931
|
+
}
|
|
1909
1932
|
}
|
|
1910
1933
|
},
|
|
1911
1934
|
{
|
|
@@ -2144,8 +2167,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2144
2167
|
return { content: [{ type: "text", text: parts.join("\n\n---\n\n") }] };
|
|
2145
2168
|
}
|
|
2146
2169
|
if (name === "get_subscription_status") {
|
|
2147
|
-
const email = String(args
|
|
2148
|
-
logger.info(`[get_subscription_status] Called with email: ${email}`);
|
|
2170
|
+
const email = args?.email ? String(args.email) : void 0;
|
|
2171
|
+
logger.info(`[get_subscription_status] Called with email: ${email || "(using API key identity)"}`);
|
|
2149
2172
|
try {
|
|
2150
2173
|
const result = await nerveCenter.getSubscriptionStatus(email);
|
|
2151
2174
|
logger.info(`[get_subscription_status] Result: ${JSON.stringify(result).substring(0, 200)}`);
|
|
@@ -2156,8 +2179,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2156
2179
|
}
|
|
2157
2180
|
}
|
|
2158
2181
|
if (name === "get_usage_stats") {
|
|
2159
|
-
const email = String(args
|
|
2160
|
-
logger.info(`[get_usage_stats] Called with email: ${email}`);
|
|
2182
|
+
const email = args?.email ? String(args.email) : void 0;
|
|
2183
|
+
logger.info(`[get_usage_stats] Called with email: ${email || "(using API key identity)"}`);
|
|
2161
2184
|
try {
|
|
2162
2185
|
const result = await nerveCenter.getUsageStats(email);
|
|
2163
2186
|
logger.info(`[get_usage_stats] Result: ${JSON.stringify(result).substring(0, 200)}`);
|