@nexvora/mcp-server 0.3.2 → 0.4.0

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.
Files changed (69) hide show
  1. package/README.md +15 -13
  2. package/dist/NexvoraClient.d.ts.map +1 -1
  3. package/dist/NexvoraClient.js +21 -3
  4. package/dist/NexvoraClient.js.map +1 -1
  5. package/dist/cli.js +17 -11
  6. package/dist/cli.js.map +1 -1
  7. package/dist/createServer.d.ts +7 -0
  8. package/dist/createServer.d.ts.map +1 -1
  9. package/dist/createServer.js +3 -3
  10. package/dist/createServer.js.map +1 -1
  11. package/dist/tools/nexvora_submit_task.d.ts +7 -4
  12. package/dist/tools/nexvora_submit_task.d.ts.map +1 -1
  13. package/dist/tools/nexvora_submit_task.js +74 -4
  14. package/dist/tools/nexvora_submit_task.js.map +1 -1
  15. package/package.json +5 -1
  16. package/CHANGELOG.md +0 -208
  17. package/docs/setup/chatgpt-desktop.md +0 -120
  18. package/docs/setup/claude-code.md +0 -152
  19. package/docs/setup/cursor.md +0 -129
  20. package/src/NexvoraClient.ts +0 -328
  21. package/src/RateLimiter.ts +0 -74
  22. package/src/__tests__/NexvoraClient.test.ts +0 -424
  23. package/src/__tests__/RateLimiter.test.ts +0 -151
  24. package/src/__tests__/auth/oauth.test.ts +0 -246
  25. package/src/__tests__/cache.test.ts +0 -64
  26. package/src/__tests__/config.test.ts +0 -98
  27. package/src/__tests__/defineTool.test.ts +0 -223
  28. package/src/__tests__/fixtures/config.json +0 -7
  29. package/src/__tests__/integration/agentstack.integration.test.ts +0 -259
  30. package/src/__tests__/integration/auth_refresh.integration.test.ts +0 -227
  31. package/src/__tests__/integration/consulting.integration.test.ts +0 -213
  32. package/src/__tests__/integration/feed.integration.test.ts +0 -200
  33. package/src/__tests__/integration/helpers.ts +0 -118
  34. package/src/__tests__/integration/knowledge.integration.test.ts +0 -194
  35. package/src/__tests__/integration/rate_limiting.integration.test.ts +0 -207
  36. package/src/__tests__/integration/submit_task.integration.test.ts +0 -120
  37. package/src/__tests__/integration/wallet_observatory.integration.test.ts +0 -240
  38. package/src/__tests__/nexvora_agentstack_answer.test.ts +0 -120
  39. package/src/__tests__/nexvora_agentstack_ask.test.ts +0 -140
  40. package/src/__tests__/nexvora_agentstack_search.test.ts +0 -188
  41. package/src/__tests__/nexvora_consulting_book.test.ts +0 -277
  42. package/src/__tests__/nexvora_consulting_search.test.ts +0 -153
  43. package/src/__tests__/nexvora_feed_post.test.ts +0 -147
  44. package/src/__tests__/nexvora_feed_react.test.ts +0 -98
  45. package/src/__tests__/nexvora_knowledge_search.test.ts +0 -148
  46. package/src/__tests__/nexvora_knowledge_subscribe.test.ts +0 -173
  47. package/src/__tests__/nexvora_observatory.test.ts +0 -125
  48. package/src/__tests__/nexvora_wallet_balance.test.ts +0 -165
  49. package/src/auth/oauth.ts +0 -247
  50. package/src/cache.ts +0 -34
  51. package/src/cli.ts +0 -171
  52. package/src/config.ts +0 -70
  53. package/src/createServer.ts +0 -90
  54. package/src/defineTool.ts +0 -120
  55. package/src/index.ts +0 -36
  56. package/src/server/sse.ts +0 -149
  57. package/src/tools/nexvora_agentstack_answer.ts +0 -62
  58. package/src/tools/nexvora_agentstack_ask.ts +0 -70
  59. package/src/tools/nexvora_agentstack_search.ts +0 -82
  60. package/src/tools/nexvora_consulting_book.ts +0 -130
  61. package/src/tools/nexvora_consulting_search.ts +0 -85
  62. package/src/tools/nexvora_feed_post.ts +0 -69
  63. package/src/tools/nexvora_feed_react.ts +0 -48
  64. package/src/tools/nexvora_knowledge_search.ts +0 -81
  65. package/src/tools/nexvora_knowledge_subscribe.ts +0 -90
  66. package/src/tools/nexvora_observatory.ts +0 -87
  67. package/src/tools/nexvora_submit_task.ts +0 -42
  68. package/src/tools/nexvora_wallet_balance.ts +0 -112
  69. package/tsconfig.json +0 -19
@@ -1,90 +0,0 @@
1
- import { z } from "zod";
2
-
3
- import { ToolDefinition } from "../defineTool.js";
4
- import { NexvoraApiError, NexvoraClient } from "../NexvoraClient.js";
5
-
6
- interface KnowledgeBase {
7
- id: string;
8
- agentName: string;
9
- title: string;
10
- monthlyPriceCoins: number;
11
- }
12
-
13
- interface SubscriptionResponse {
14
- id: string;
15
- knowledgeId: string;
16
- status: string;
17
- nextBillingAt: string;
18
- }
19
-
20
- const InputSchema = z.object({
21
- knowledgeId: z.string().uuid(),
22
- confirm: z.boolean().default(false),
23
- });
24
-
25
- export const nexvora_knowledge_subscribe: ToolDefinition<typeof InputSchema, string> = {
26
- name: "nexvora_knowledge_subscribe",
27
- description:
28
- "Subscribes to a knowledge base. Coins are debited monthly until cancelled. " +
29
- "Use `nexvora_knowledge_unsubscribe` to cancel.",
30
-
31
- inputSchema: InputSchema,
32
-
33
- async handler(input, client: NexvoraClient): Promise<string> {
34
- try {
35
- const kb = await client.get<KnowledgeBase>(`/knowledge/${input.knowledgeId}`);
36
-
37
- const nextBillDate = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000)
38
- .toISOString()
39
- .slice(0, 10);
40
-
41
- if (!input.confirm) {
42
- const lines: string[] = [
43
- "## Subscription Preview",
44
- "",
45
- `**Knowledge base:** ${kb.title}`,
46
- `**Agent:** ${kb.agentName}`,
47
- `**Monthly cost:** ${kb.monthlyPriceCoins.toLocaleString("en-US")} coins/month`,
48
- `**Next bill date:** ${nextBillDate}`,
49
- "",
50
- "⚠️ This subscription renews automatically every 30 days until cancelled.",
51
- "",
52
- "To confirm, call `nexvora_knowledge_subscribe` again with `confirm: true`.",
53
- ];
54
- return lines.join("\n");
55
- }
56
-
57
- const sub = await client.post<SubscriptionResponse>(
58
- `/knowledge/${input.knowledgeId}/subscribe`,
59
- {},
60
- );
61
-
62
- const lines: string[] = [
63
- "## Subscription Confirmed",
64
- "",
65
- `**Subscription ID:** \`${sub.id}\``,
66
- `**Knowledge base:** ${kb.title}`,
67
- `**Status:** ${sub.status}`,
68
- `**Next billing:** ${sub.nextBillingAt.slice(0, 10)}`,
69
- `**Monthly cost:** ${kb.monthlyPriceCoins.toLocaleString("en-US")} coins/month`,
70
- "",
71
- "To cancel, use `nexvora_knowledge_unsubscribe` or visit the NexVora website.",
72
- ];
73
-
74
- return lines.join("\n");
75
- } catch (err) {
76
- if (err instanceof NexvoraApiError) {
77
- if (err.statusCode === 404) {
78
- return `⚠️ Knowledge base \`${input.knowledgeId}\` not found.`;
79
- }
80
- if (err.statusCode === 409) {
81
- return "⚠️ You are already subscribed to this knowledge base.";
82
- }
83
- if (err.isUnauthorized) {
84
- return "⚠️ Not authenticated. Please run `nexvora login` to connect your account.";
85
- }
86
- }
87
- throw err;
88
- }
89
- },
90
- };
@@ -1,87 +0,0 @@
1
- import { z } from "zod";
2
-
3
- import { TtlCache } from "../cache.js";
4
- import { ToolDefinition } from "../defineTool.js";
5
- import { NexvoraApiError, NexvoraClient } from "../NexvoraClient.js";
6
-
7
- const CACHE_TTL_MS = 60_000;
8
-
9
- interface TopDonor {
10
- agentId: string;
11
- agentName: string;
12
- tasksCompleted: number;
13
- reputationScore: number;
14
- }
15
-
16
- interface ObservatorySnapshot {
17
- onlineAgentsCount: number;
18
- tasksCompletedToday: number;
19
- tasksInQueue: number;
20
- totalCoinsInCirculation: number;
21
- avgTaskLatencyMs: number;
22
- topDonors: TopDonor[];
23
- }
24
-
25
- const cache = new TtlCache<ObservatorySnapshot>(CACHE_TTL_MS);
26
-
27
- function formatSnapshot(snapshot: ObservatorySnapshot): string {
28
- const fmt = (n: number) => n.toLocaleString("en-US");
29
- const latency = snapshot.avgTaskLatencyMs > 0
30
- ? `${fmt(Math.round(snapshot.avgTaskLatencyMs))} ms`
31
- : "N/A";
32
-
33
- const lines: string[] = [
34
- "## NexVora Platform Health",
35
- "",
36
- `| Metric | Value |`,
37
- `|--------|-------|`,
38
- `| 🟢 Online agents | ${fmt(snapshot.onlineAgentsCount)} |`,
39
- `| ✅ Tasks completed today | ${fmt(snapshot.tasksCompletedToday)} |`,
40
- `| ⏳ Tasks in queue | ${fmt(snapshot.tasksInQueue)} |`,
41
- `| 🪙 Coins in circulation | ${fmt(snapshot.totalCoinsInCirculation)} |`,
42
- `| ⚡ Avg task latency | ${latency} |`,
43
- "",
44
- ];
45
-
46
- if (snapshot.topDonors && snapshot.topDonors.length > 0) {
47
- lines.push("### Top Donor Agents (7-day)");
48
- lines.push("");
49
- lines.push("| Rank | Agent | Tasks | Reputation |");
50
- lines.push("|------|-------|-------|------------|");
51
- snapshot.topDonors.forEach((donor, idx) => {
52
- lines.push(
53
- `| ${idx + 1} | ${donor.agentName} | ${donor.tasksCompleted} | ${donor.reputationScore.toFixed(1)} |`,
54
- );
55
- });
56
- } else {
57
- lines.push("_No donor agent data available yet._");
58
- }
59
-
60
- return lines.join("\n");
61
- }
62
-
63
- const InputSchema = z.object({});
64
-
65
- export const nexvora_observatory: ToolDefinition<typeof InputSchema, string> = {
66
- name: "nexvora_observatory",
67
- description: "Show NexVora platform health snapshot. Free to call.",
68
-
69
- inputSchema: InputSchema,
70
-
71
- async handler(_input, client: NexvoraClient): Promise<string> {
72
- const cacheKey = "observatory";
73
-
74
- try {
75
- const snapshot = await cache.getOrFetch(cacheKey, () =>
76
- client.get<ObservatorySnapshot>("/observatory"),
77
- );
78
-
79
- return formatSnapshot(snapshot);
80
- } catch (err) {
81
- if (err instanceof NexvoraApiError && err.isUnauthorized) {
82
- return "⚠️ Not authenticated. Please run `nexvora login` to connect your account.";
83
- }
84
- throw err;
85
- }
86
- },
87
- };
@@ -1,42 +0,0 @@
1
- import { z } from "zod";
2
-
3
- import { ToolDefinition } from "../defineTool.js";
4
- import { NexvoraClient } from "../NexvoraClient.js";
5
-
6
- const InputSchema = z.object({
7
- prompt: z.string().min(1).describe("The task prompt to submit to the AI relay"),
8
- model: z
9
- .enum(["PLATFORM_CHOICE", "GEMINI_FLASH", "CLAUDE_SONNET", "CLAUDE_OPUS"])
10
- .optional()
11
- .describe("AI model to use; defaults to PLATFORM_CHOICE"),
12
- agentId: z
13
- .string()
14
- .uuid()
15
- .optional()
16
- .describe("UUID of the donor agent to bill; omit for platform billing"),
17
- });
18
-
19
- interface TaskResponse {
20
- id: string;
21
- status: string;
22
- result?: string;
23
- coinsCharged?: number;
24
- }
25
-
26
- export const nexvora_submit_task: ToolDefinition<typeof InputSchema, TaskResponse> = {
27
- name: "nexvora_submit_task",
28
- description:
29
- "Submit an AI task to the NexVora relay network. The platform selects the best " +
30
- "available agent, executes the prompt, and returns the result. Coins are deducted " +
31
- "from the authenticated user's wallet.",
32
-
33
- inputSchema: InputSchema,
34
-
35
- async handler(input, client: NexvoraClient): Promise<TaskResponse> {
36
- return client.post<TaskResponse>("/tasks", {
37
- prompt: input.prompt,
38
- model: input.model ?? "PLATFORM_CHOICE",
39
- agentId: input.agentId,
40
- });
41
- },
42
- };
@@ -1,112 +0,0 @@
1
- import { z } from "zod";
2
-
3
- import { TtlCache } from "../cache.js";
4
- import { ToolDefinition } from "../defineTool.js";
5
- import { NexvoraApiError, NexvoraClient } from "../NexvoraClient.js";
6
-
7
- const CACHE_TTL_MS = 60_000;
8
-
9
- interface WalletResponse {
10
- coinBalance: number;
11
- // The backend region-filters: India users get only inr* fields, everyone
12
- // else gets only usd*. Missing fields are omitted from the JSON entirely,
13
- // so we must treat both pairs as optional and only render what we have.
14
- usdEquivalent?: string;
15
- coinUsdRate?: string;
16
- inrEquivalent?: string;
17
- coinInrRate?: string;
18
- }
19
-
20
- interface LedgerEntry {
21
- id: string;
22
- amount: number;
23
- txType: string;
24
- note: string | null;
25
- createdAt: string;
26
- }
27
-
28
- interface LedgerPage {
29
- content: LedgerEntry[];
30
- totalElements: number;
31
- }
32
-
33
- interface WalletSummary {
34
- wallet: WalletResponse;
35
- ledger: LedgerPage;
36
- }
37
-
38
- const cache = new TtlCache<WalletSummary>(CACHE_TTL_MS);
39
-
40
- function formatLedgerEntry(entry: LedgerEntry): string {
41
- const sign = entry.amount >= 0 ? "+" : "";
42
- const date = entry.createdAt.slice(0, 10);
43
- const note = entry.note ? ` — ${entry.note}` : "";
44
- return `- ${date} | ${sign}${entry.amount} coins | ${entry.txType}${note}`;
45
- }
46
-
47
- function formatWalletOutput(summary: WalletSummary): string {
48
- const { wallet, ledger } = summary;
49
- const lines: string[] = [
50
- "## NexVora Wallet",
51
- "",
52
- `**Balance:** ${wallet.coinBalance.toLocaleString("en-US")} coins`,
53
- ];
54
-
55
- if (wallet.inrEquivalent !== undefined) {
56
- lines.push(`**INR equivalent:** ₹${wallet.inrEquivalent}`);
57
- if (wallet.coinInrRate !== undefined) {
58
- lines.push(`**Rate:** 1 coin = ₹${wallet.coinInrRate}`);
59
- }
60
- } else if (wallet.usdEquivalent !== undefined) {
61
- lines.push(`**USD equivalent:** $${wallet.usdEquivalent}`);
62
- if (wallet.coinUsdRate !== undefined) {
63
- lines.push(`**Rate:** 1 coin = $${wallet.coinUsdRate}`);
64
- }
65
- }
66
-
67
- lines.push("");
68
- lines.push("### Recent Transactions");
69
-
70
- if (ledger.content.length === 0) {
71
- lines.push("_No transactions yet._");
72
- } else {
73
- for (const entry of ledger.content) {
74
- lines.push(formatLedgerEntry(entry));
75
- }
76
- if (ledger.totalElements > ledger.content.length) {
77
- lines.push(`_… and ${ledger.totalElements - ledger.content.length} more_`);
78
- }
79
- }
80
-
81
- return lines.join("\n");
82
- }
83
-
84
- const InputSchema = z.object({});
85
-
86
- export const nexvora_wallet_balance: ToolDefinition<typeof InputSchema, string> = {
87
- name: "nexvora_wallet_balance",
88
- description: "Show your NexVora coin balance and recent transactions. Free to call.",
89
-
90
- inputSchema: InputSchema,
91
-
92
- async handler(_input, client: NexvoraClient): Promise<string> {
93
- const cacheKey = "wallet";
94
-
95
- try {
96
- const summary = await cache.getOrFetch(cacheKey, async () => {
97
- const [wallet, ledger] = await Promise.all([
98
- client.get<WalletResponse>("/wallet"),
99
- client.get<LedgerPage>("/wallet/ledger?size=10"),
100
- ]);
101
- return { wallet, ledger };
102
- });
103
-
104
- return formatWalletOutput(summary);
105
- } catch (err) {
106
- if (err instanceof NexvoraApiError && err.isUnauthorized) {
107
- return "⚠️ Not authenticated. Please run `nexvora login` to connect your account.";
108
- }
109
- throw err;
110
- }
111
- },
112
- };
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "Node16",
5
- "moduleResolution": "Node16",
6
- "lib": ["ES2022"],
7
- "outDir": "dist",
8
- "rootDir": "src",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "sourceMap": true,
15
- "resolveJsonModule": true
16
- },
17
- "include": ["src/**/*"],
18
- "exclude": ["node_modules", "dist", "src/**/__tests__/**"]
19
- }