@ctxprotocol/sdk 0.13.1 → 0.15.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.
package/README.md CHANGED
@@ -1,32 +1,32 @@
1
1
  # @ctxprotocol/sdk
2
2
 
3
- **The Universal Adapter for AI Agents.**
3
+ **Grounded context for your AI agents — on demand.**
4
4
 
5
- Connect your AI to the real world without managing API keys, hosting servers, or reading documentation.
5
+ Give your agent the live facts it's missing. Context is a pay-per-response data marketplace: your agent discovers tools at runtime, buys the data its question needs, and drops it straight into its context window — no API keys, no servers, no per-source integration work.
6
6
 
7
- Context Protocol is **npm for AI capabilities**. Just as you install packages to add functionality to your code, use the Context SDK to give your Agent instant access to thousands of live data sources and actions—from DeFi and Gas Oracles to Weather and Search.
7
+ Context Protocol is **npm for AI capabilities**. Just as you install packages to add functionality to your code, use the Context SDK to give your Agent instant access to premium data feeds and live tools: the market intelligence usually locked behind steep monthly or annual subscriptions, unbundled into pay-per-response, from crypto and on-chain analytics to gas oracles, weather, and search.
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/@ctxprotocol/sdk.svg)](https://www.npmjs.com/package/@ctxprotocol/sdk)
10
10
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
11
 
12
12
  ---
13
13
 
14
- ### 💰 $10,000 Developer Grant Program
14
+ ### Contributors
15
15
 
16
- We're funding the initial supply of MCP Tools for the Context Marketplace. **Become a Data Broker.**
16
+ List MCP tools on the permissionless Context marketplace and keep **90% of usage fees** in USDC.
17
17
 
18
- - **🛠️ Build:** Create an MCP Server using this SDK (Solana data, Trading tools, Scrapers, etc.)
19
- - **📦 List:** Publish it to the Context Registry
20
- - **💵 Earn:** Get a **$250–$1,000 Grant** + earn USDC every time an agent queries your tool
18
+ - **Build:** Create an MCP server with this SDK
19
+ - **List:** Register at [ctxprotocol.com/contribute](https://ctxprotocol.com/contribute)
20
+ - **Earn:** Revenue share on every Query response and eligible Execute call
21
21
 
22
- 👉 [**View Open Bounties & Apply Here**](https://docs.ctxprotocol.com/grants)
22
+ Grant batches open periodically see [Developer Grants](https://docs.ctxprotocol.com/grants) for current batch status and contributor guidance.
23
23
 
24
24
  ---
25
25
 
26
26
  ## Why use Context?
27
27
 
28
28
  - **🔌 One Interface, Everything:** Stop integrating APIs one by one. Use a single SDK to access any tool in the marketplace.
29
- - **🧠 Zero-Ops:** We're a gateway to the best MCP tools. Just send the JSON and get the result.
29
+ - **🧠 Zero-Ops:** We're the gateway to premium data feeds usually locked behind steep subscriptions. We host the connections; you just send the JSON and get the result.
30
30
  - **⚡️ Agentic Discovery:** Your Agent can search the marketplace at runtime to find tools it didn't know it needed.
31
31
  - **💸 Dual-Surface Economics:** Use Query for pay-per-response intelligence or Execute for session-budgeted method calls.
32
32
 
@@ -96,7 +96,7 @@ const result = await client.tools.execute({
96
96
  console.log(result.session); // methodPrice, spent, remaining, maxSpend, ...
97
97
  ```
98
98
 
99
- **Query mode** gives you a managed librarian contract — the server runs the live pipeline (`discover -> select -> metadata scout -> clarify if needed -> iterative execute -> synthesize -> settle`) with model-aware context budgeting and can return plain answers or structured evidence packages for one flat fee:
99
+ **Query mode** gives you a managed librarian contract — the server runs the live pipeline (`discover -> select -> metadata scout -> iterative execute -> synthesize -> settle`) with model-aware context budgeting and can return plain answers or structured evidence packages for one flat fee:
100
100
  ```typescript
101
101
  const answer = await client.query.run({
102
102
  query: "What are the top whale movements on Base?",
@@ -417,7 +417,7 @@ const closed = await client.tools.closeSession("sess_123");
417
417
 
418
418
  #### `client.query.run(options)`
419
419
 
420
- Run an agentic query. The server applies the live librarian pipeline (`discover -> select -> metadata scout -> clarify if needed -> iterative execute -> synthesize -> settle`) with up to 100 MCP calls per response turn, then returns the selected Query response contract (`answer`, `answer_with_evidence`, or `evidence_only`).
420
+ Run an agentic query. The server applies the live librarian pipeline (`discover -> select -> metadata scout -> iterative execute -> synthesize -> settle`) with up to 100 MCP calls per response turn, then returns the selected Query response contract (`answer`, `answer_with_evidence`, or `evidence_only`).
421
421
 
422
422
  The query runtime now exposes a single managed executor surface.
423
423
  The server decides internal budgets, ambiguity handling, and exploration policy
@@ -53,9 +53,9 @@ var Developer = class {
53
53
  if (!toolId) {
54
54
  throw new ContextError("toolId is required");
55
55
  }
56
- if (updates.name === void 0 && updates.description === void 0 && updates.category === void 0) {
56
+ if (updates.name === void 0 && updates.description === void 0 && updates.suggestedPrompts === void 0 && updates.category === void 0) {
57
57
  throw new ContextError(
58
- "At least one field required: name, description, or category"
58
+ "At least one field required: name, description, suggestedPrompts, or category"
59
59
  );
60
60
  }
61
61
  if (updates.category !== void 0 && updates.category !== null && !ALLOWED_TOOL_CATEGORIES.includes(updates.category)) {
@@ -304,9 +304,6 @@ var Query = class {
304
304
  }
305
305
  normalizeResult(result) {
306
306
  const candidate = result;
307
- if (candidate.outcomeType === "clarification_required" && "clarification" in candidate && candidate.clarification) {
308
- return candidate;
309
- }
310
307
  if (candidate.outcomeType === "capability_miss" && "capabilityMiss" in candidate && candidate.capabilityMiss) {
311
308
  return candidate;
312
309
  }
@@ -315,34 +312,6 @@ var Query = class {
315
312
  outcomeType: "answer"
316
313
  };
317
314
  }
318
- buildPolicyErrorEvent(params) {
319
- if (params.clarificationPolicy !== "error") {
320
- return;
321
- }
322
- if (params.result.outcomeType === "clarification_required") {
323
- return {
324
- type: "error",
325
- error: params.result.response,
326
- code: "clarification_required",
327
- reasonCode: "clarification_required",
328
- outcomeType: "clarification_required",
329
- clarification: params.result.clarification,
330
- querySession: params.result.querySession
331
- };
332
- }
333
- if (params.result.outcomeType === "capability_miss") {
334
- return {
335
- type: "error",
336
- error: params.result.response,
337
- code: "capability_miss",
338
- reasonCode: "capability_miss",
339
- outcomeType: "capability_miss",
340
- capabilityMiss: params.result.capabilityMiss,
341
- querySession: params.result.querySession
342
- };
343
- }
344
- return void 0;
345
- }
346
315
  buildSyntheticTraceFromRunResult(params) {
347
316
  const timeline = params.toolsUsed.map((tool, index) => ({
348
317
  stepType: "tool-call",
@@ -556,7 +525,6 @@ var Query = class {
556
525
  tools: opts.tools,
557
526
  resumeFrom: opts.resumeFrom,
558
527
  forkFrom: opts.forkFrom,
559
- clarificationPolicy: opts.clarificationPolicy,
560
528
  answerModelId: opts.answerModelId,
561
529
  responseShape: opts.responseShape,
562
530
  favoritesOnly: opts.favoritesOnly,
@@ -614,13 +582,6 @@ var Query = class {
614
582
  normalizedResult.developerTrace = mergedTrace;
615
583
  }
616
584
  event.result = normalizedResult;
617
- const policyErrorEvent = this.buildPolicyErrorEvent({
618
- result: normalizedResult,
619
- clarificationPolicy: opts.clarificationPolicy
620
- });
621
- if (policyErrorEvent) {
622
- return policyErrorEvent;
623
- }
624
585
  }
625
586
  return event;
626
587
  };
@@ -691,7 +652,7 @@ var ContextClient = class {
691
652
  *
692
653
  * Unlike `tools.execute()` which calls a single tool once, `query` sends
693
654
  * a natural-language question and lets the server handle discovery,
694
- * metadata scout, clarification, iterative execution, and AI synthesis —
655
+ * metadata scout, iterative execution, and AI synthesis —
695
656
  * one flat fee.
696
657
  */
697
658
  query;