@nordsym/apiclaw 2.8.5 → 2.8.6
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/README.md +74 -156
- package/dist/cli/commands/auth.d.ts +0 -4
- package/dist/cli/commands/auth.d.ts.map +1 -1
- package/dist/cli/commands/auth.js +0 -18
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/demo.js +2 -2
- package/dist/cli/commands/demo.js.map +1 -1
- package/dist/cli/commands/setup.js +2 -2
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/index.js +5 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -135
- package/dist/index.js.map +1 -1
- package/dist/metered.d.ts.map +1 -1
- package/dist/metered.js +6 -1
- package/dist/metered.js.map +1 -1
- package/dist/registration-guard.d.ts.map +1 -1
- package/dist/registration-guard.js +0 -2
- package/dist/registration-guard.js.map +1 -1
- package/dist/stripe.d.ts.map +1 -1
- package/dist/stripe.js +4 -3
- package/dist/stripe.js.map +1 -1
- package/dist/test.d.ts +0 -4
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +24 -107
- package/dist/test.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
* Tools:
|
|
6
6
|
* - discover_apis: Search for APIs by capability
|
|
7
7
|
* - get_api_details: Get full info about an API
|
|
8
|
-
* - purchase_access: Buy API access with credits
|
|
9
8
|
* - check_balance: Check credits and active purchases
|
|
10
|
-
* - add_credits: Add credits to account (for testing)
|
|
11
9
|
*/
|
|
12
10
|
import { spawn } from 'node:child_process';
|
|
13
11
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
@@ -15,8 +13,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
15
13
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
16
14
|
import { discoverAPIs, getAPIDetails, getCategories, getAllAPIs } from './discovery.js';
|
|
17
15
|
import { trackStartup, trackSearch } from './telemetry.js';
|
|
18
|
-
import {
|
|
19
|
-
import { hasRealCredentials } from './credentials.js';
|
|
16
|
+
import { getBalanceSummary } from './credits.js';
|
|
20
17
|
import { getConnectedProviders } from './execute.js';
|
|
21
18
|
import { executeMetered } from './metered.js';
|
|
22
19
|
import { logAPICall } from './mcp-analytics.js';
|
|
@@ -758,7 +755,7 @@ const tools = [
|
|
|
758
755
|
},
|
|
759
756
|
callable_only: {
|
|
760
757
|
type: 'boolean',
|
|
761
|
-
description: 'Default true: only return APIs APIClaw can execute right now (
|
|
758
|
+
description: 'Default true: only return APIs APIClaw can execute right now (2,906+ callable APIs). Set false to also see the full 26,701+ discoverable registry. Signup is required, discovery is free.',
|
|
762
759
|
default: true,
|
|
763
760
|
},
|
|
764
761
|
max_results: {
|
|
@@ -801,28 +798,6 @@ const tools = [
|
|
|
801
798
|
required: ['api_id']
|
|
802
799
|
}
|
|
803
800
|
},
|
|
804
|
-
{
|
|
805
|
-
name: 'purchase_access',
|
|
806
|
-
description: 'Purchase access to an API using your credit balance. Returns API credentials on success.',
|
|
807
|
-
inputSchema: {
|
|
808
|
-
type: 'object',
|
|
809
|
-
properties: {
|
|
810
|
-
api_id: {
|
|
811
|
-
type: 'string',
|
|
812
|
-
description: 'The API provider ID to purchase access to'
|
|
813
|
-
},
|
|
814
|
-
amount_usd: {
|
|
815
|
-
type: 'number',
|
|
816
|
-
description: 'Amount in USD to spend on this API'
|
|
817
|
-
},
|
|
818
|
-
agent_id: {
|
|
819
|
-
type: 'string',
|
|
820
|
-
description: 'Your agent identifier (optional, uses default if not provided)'
|
|
821
|
-
}
|
|
822
|
-
},
|
|
823
|
-
required: ['api_id', 'amount_usd']
|
|
824
|
-
}
|
|
825
|
-
},
|
|
826
801
|
{
|
|
827
802
|
name: 'check_balance',
|
|
828
803
|
description: 'Check your credit balance and list active API purchases.',
|
|
@@ -836,24 +811,6 @@ const tools = [
|
|
|
836
811
|
}
|
|
837
812
|
}
|
|
838
813
|
},
|
|
839
|
-
{
|
|
840
|
-
name: 'add_credits',
|
|
841
|
-
description: 'Add credits to your workspace. (For testing/demo purposes)',
|
|
842
|
-
inputSchema: {
|
|
843
|
-
type: 'object',
|
|
844
|
-
properties: {
|
|
845
|
-
amount_usd: {
|
|
846
|
-
type: 'number',
|
|
847
|
-
description: 'Amount in USD to add to your balance'
|
|
848
|
-
},
|
|
849
|
-
agent_id: {
|
|
850
|
-
type: 'string',
|
|
851
|
-
description: 'Your agent identifier (optional, uses default if not provided)'
|
|
852
|
-
}
|
|
853
|
-
},
|
|
854
|
-
required: ['amount_usd']
|
|
855
|
-
}
|
|
856
|
-
},
|
|
857
814
|
{
|
|
858
815
|
name: 'list_categories',
|
|
859
816
|
description: 'List API categories with total + callable counts. Lightweight by design — does NOT dump every API ID. Use discover_apis(query, category) to drill into a category.',
|
|
@@ -1293,11 +1250,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1293
1250
|
${!isAuthenticated ? `
|
|
1294
1251
|
GET STARTED (free):
|
|
1295
1252
|
1. register_owner({ email: "you@example.com" }) — sends 6-digit code
|
|
1296
|
-
2. verify_code({ email: "you@example.com", code: "123456" })
|
|
1253
|
+
2. verify_code({ email: "you@example.com", code: "123456" }) - activates workspace
|
|
1297
1254
|
` : `
|
|
1298
1255
|
STATUS: Authenticated as ${workspaceContext.email} (${workspaceContext.tier} tier)
|
|
1299
1256
|
`}
|
|
1300
|
-
DISCOVER APIs (
|
|
1257
|
+
DISCOVER APIs (signup required, free):
|
|
1301
1258
|
discover_apis({ query: "send SMS to Sweden" })
|
|
1302
1259
|
discover_apis({ query: "text to speech", category: "ai" })
|
|
1303
1260
|
|
|
@@ -1305,13 +1262,7 @@ CALL APIs (requires free registration):
|
|
|
1305
1262
|
call_api({ provider: "brave_search", action: "search", params: { q: "AI agents" } })
|
|
1306
1263
|
call_api({ provider: "elevenlabs", action: "tts", params: { text: "Hello" } })
|
|
1307
1264
|
|
|
1308
|
-
|
|
1309
|
-
OpenAI, Anthropic, xAI/Grok, Groq, Mistral, OpenRouter, Together AI,
|
|
1310
|
-
Replicate, ElevenLabs, Deepgram, AssemblyAI, Brave Search, Firecrawl,
|
|
1311
|
-
Serper, E2B, Stability AI, Cohere, Voyage AI, GitHub,
|
|
1312
|
-
APILayer (22 callable sub-APIs)
|
|
1313
|
-
|
|
1314
|
-
${CANON_STATS.discoverable.toLocaleString()} DISCOVERABLE | ${CANON_STATS.callable.toLocaleString()} CALLABLE (empirically verified, ${CANON_STATS.managed_directcallconfigs} managed) | Free tier: 25 calls / month, email signup required
|
|
1265
|
+
${CANON_STATS.discoverable.toLocaleString()}+ DISCOVERABLE | ${CANON_STATS.callable.toLocaleString()}+ CALLABLE | Discovery is free after signup | Free tier: 25 calls / month
|
|
1315
1266
|
|
|
1316
1267
|
Docs: https://apiclaw.cloud
|
|
1317
1268
|
`;
|
|
@@ -1332,8 +1283,8 @@ Docs: https://apiclaw.cloud
|
|
|
1332
1283
|
const subagentId = args?.subagent_id;
|
|
1333
1284
|
const aiBackend = args?.ai_backend;
|
|
1334
1285
|
const startTime = Date.now();
|
|
1335
|
-
//
|
|
1336
|
-
//
|
|
1286
|
+
// Delegate to HTTP gateway /v1/discover so every door sees the same
|
|
1287
|
+
// canon (26,701+ discoverable / 2,906+ callable). Local registry
|
|
1337
1288
|
// was stripped from the tarball in 2.8.3 (saved 150MB); hardcoded
|
|
1338
1289
|
// curated set + Convex managed cache only ships ~53 entries standalone.
|
|
1339
1290
|
// Gateway-fetch makes lokal MCP tool match HTTP + Remote MCP results.
|
|
@@ -1356,19 +1307,6 @@ Docs: https://apiclaw.cloud
|
|
|
1356
1307
|
});
|
|
1357
1308
|
if (discoverResp.ok) {
|
|
1358
1309
|
const data = await discoverResp.json();
|
|
1359
|
-
const managed = (data.managedProviders || []).map((p) => ({
|
|
1360
|
-
provider: {
|
|
1361
|
-
id: p.providerId,
|
|
1362
|
-
name: p.name,
|
|
1363
|
-
description: p.description,
|
|
1364
|
-
category: p.category,
|
|
1365
|
-
callable: true,
|
|
1366
|
-
managed: true,
|
|
1367
|
-
},
|
|
1368
|
-
matchScore: 1.0,
|
|
1369
|
-
matchedKeywords: [],
|
|
1370
|
-
actions: [],
|
|
1371
|
-
}));
|
|
1372
1310
|
const open = (data.apis || []).map((a) => ({
|
|
1373
1311
|
provider: {
|
|
1374
1312
|
id: String(a.name || '').toLowerCase().replace(/\s+/g, '_'),
|
|
@@ -1382,7 +1320,7 @@ Docs: https://apiclaw.cloud
|
|
|
1382
1320
|
matchedKeywords: [],
|
|
1383
1321
|
actions: [],
|
|
1384
1322
|
}));
|
|
1385
|
-
results =
|
|
1323
|
+
results = open.slice(0, requestedMax);
|
|
1386
1324
|
}
|
|
1387
1325
|
else {
|
|
1388
1326
|
// Gateway 5xx — local sparse fallback so we don't return nothing.
|
|
@@ -1597,51 +1535,6 @@ Docs: https://apiclaw.cloud
|
|
|
1597
1535
|
]
|
|
1598
1536
|
};
|
|
1599
1537
|
}
|
|
1600
|
-
case 'purchase_access': {
|
|
1601
|
-
const apiId = args?.api_id;
|
|
1602
|
-
const amountUsd = args?.amount_usd;
|
|
1603
|
-
const agentId = args?.agent_id || DEFAULT_AGENT_ID;
|
|
1604
|
-
const result = purchaseAPIAccess(agentId, apiId, amountUsd);
|
|
1605
|
-
if (!result.success) {
|
|
1606
|
-
return {
|
|
1607
|
-
content: [
|
|
1608
|
-
{
|
|
1609
|
-
type: 'text',
|
|
1610
|
-
text: JSON.stringify({
|
|
1611
|
-
status: 'error',
|
|
1612
|
-
message: result.error
|
|
1613
|
-
}, null, 2)
|
|
1614
|
-
}
|
|
1615
|
-
]
|
|
1616
|
-
};
|
|
1617
|
-
}
|
|
1618
|
-
const api = getAPIDetails(apiId);
|
|
1619
|
-
return {
|
|
1620
|
-
content: [
|
|
1621
|
-
{
|
|
1622
|
-
type: 'text',
|
|
1623
|
-
text: JSON.stringify({
|
|
1624
|
-
status: 'success',
|
|
1625
|
-
message: `Successfully purchased access to ${apiId}`,
|
|
1626
|
-
purchase: {
|
|
1627
|
-
id: result.purchase.id,
|
|
1628
|
-
provider: apiId,
|
|
1629
|
-
amount_paid_usd: amountUsd,
|
|
1630
|
-
credits_received: result.purchase.credits_purchased,
|
|
1631
|
-
status: result.purchase.status,
|
|
1632
|
-
real_credentials: hasRealCredentials(apiId)
|
|
1633
|
-
},
|
|
1634
|
-
credentials: result.purchase.credentials,
|
|
1635
|
-
access: {
|
|
1636
|
-
base_url: api?.base_url,
|
|
1637
|
-
docs_url: api?.docs_url,
|
|
1638
|
-
auth_type: api?.auth_type
|
|
1639
|
-
}
|
|
1640
|
-
}, null, 2)
|
|
1641
|
-
}
|
|
1642
|
-
]
|
|
1643
|
-
};
|
|
1644
|
-
}
|
|
1645
1538
|
case 'check_balance': {
|
|
1646
1539
|
const agentId = args?.agent_id || DEFAULT_AGENT_ID;
|
|
1647
1540
|
const summary = getBalanceSummary(agentId);
|
|
@@ -1655,36 +1548,17 @@ Docs: https://apiclaw.cloud
|
|
|
1655
1548
|
balance_usd: summary.credits.balance_usd,
|
|
1656
1549
|
currency: summary.credits.currency,
|
|
1657
1550
|
total_spent_usd: summary.total_spent_usd,
|
|
1658
|
-
real_credential_providers: summary.real_credentials_available,
|
|
1659
1551
|
active_purchases: summary.active_purchases.map(p => ({
|
|
1660
1552
|
id: p.id,
|
|
1661
1553
|
provider: p.provider_id,
|
|
1662
1554
|
credits_remaining: p.credits_purchased,
|
|
1663
|
-
status: p.status
|
|
1664
|
-
real_credentials: hasRealCredentials(p.provider_id)
|
|
1555
|
+
status: p.status
|
|
1665
1556
|
}))
|
|
1666
1557
|
}, null, 2)
|
|
1667
1558
|
}
|
|
1668
1559
|
]
|
|
1669
1560
|
};
|
|
1670
1561
|
}
|
|
1671
|
-
case 'add_credits': {
|
|
1672
|
-
const amountUsd = args?.amount_usd;
|
|
1673
|
-
const agentId = args?.agent_id || DEFAULT_AGENT_ID;
|
|
1674
|
-
const credits = addCredits(agentId, amountUsd);
|
|
1675
|
-
return {
|
|
1676
|
-
content: [
|
|
1677
|
-
{
|
|
1678
|
-
type: 'text',
|
|
1679
|
-
text: JSON.stringify({
|
|
1680
|
-
status: 'success',
|
|
1681
|
-
message: `Added $${amountUsd.toFixed(2)} to your workspace`,
|
|
1682
|
-
new_balance_usd: credits.balance_usd
|
|
1683
|
-
}, null, 2)
|
|
1684
|
-
}
|
|
1685
|
-
]
|
|
1686
|
-
};
|
|
1687
|
-
}
|
|
1688
1562
|
case 'list_categories': {
|
|
1689
1563
|
const withApiIds = args?.with_api_ids === true;
|
|
1690
1564
|
const categories = getCategories();
|