|
13 | 13 | * This is the primary method used when integrating with OpenAI, Anthropic, or AI SDK. |
14 | 14 | * The internal flow is: |
15 | 15 | * |
16 | | - * 1. Fetch tools from linked accounts via MCP to discover available connectors |
| 16 | + * 1. Fetch tools from linked accounts via MCP (provides connectors and tool schemas) |
17 | 17 | * 2. Search EACH connector in parallel via the semantic search API (/actions/search) |
18 | | - * 3. The search API returns results with full `inputSchema` for each action |
19 | | - * 4. Build executable tools directly from search results (no match-back needed) |
20 | | - * 5. Deduplicate by actionId, sort by relevance score, apply topK |
21 | | - * 6. Return Tools sorted by relevance score |
| 18 | + * 3. Match search results to MCP tool definitions |
| 19 | + * 4. Deduplicate, sort by relevance score, apply topK |
| 20 | + * 5. Return Tools sorted by relevance score |
22 | 21 | * |
23 | 22 | * Key point: only the user's own connectors are searched — no wasted results |
24 | | - * from connectors the user doesn't have. The search API returns `inputSchema` |
25 | | - * with each result, so tools can be built directly without a separate fetch. |
| 23 | + * from connectors the user doesn't have. Tool schemas come from MCP (source |
| 24 | + * of truth), while the search API provides relevance ranking. |
26 | 25 | * |
27 | 26 | * If the semantic API is unavailable, the SDK falls back to a local |
28 | 27 | * BM25 + TF-IDF hybrid search over the fetched tools (unless |
|
32 | 31 | * 2. `searchActionNames(query)` — Lightweight discovery |
33 | 32 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
34 | 33 | * |
35 | | - * Queries the semantic API directly and returns action metadata |
36 | | - * (actionId, connector, score, description, inputSchema) **without** |
37 | | - * building full tool objects. Useful for previewing results before |
38 | | - * committing to a full fetch. |
| 34 | + * Queries the semantic API directly and returns action IDs with |
| 35 | + * similarity scores, **without** building full tool objects. Useful |
| 36 | + * for previewing results before committing to a full fetch. |
39 | 37 | * |
40 | 38 | * When `accountIds` are provided, each connector is searched in |
41 | 39 | * parallel (same as `searchTools`). Without `accountIds`, results |
@@ -103,7 +101,7 @@ export interface SemanticSearchOptions { |
103 | 101 | * const client = new SemanticSearchClient({ apiKey: 'sk-xxx' }); |
104 | 102 | * const response = await client.search('create employee', { connector: 'bamboohr', topK: 5 }); |
105 | 103 | * for (const result of response.results) { |
106 | | - * console.log(`${result.actionId}: ${result.similarityScore.toFixed(2)}`); |
| 104 | + * console.log(`${result.id}: ${result.similarityScore.toFixed(2)}`); |
107 | 105 | * } |
108 | 106 | * ``` |
109 | 107 | */ |
@@ -146,7 +144,7 @@ export class SemanticSearchClient { |
146 | 144 | * ```typescript |
147 | 145 | * const response = await client.search('onboard a new team member', { topK: 5 }); |
148 | 146 | * for (const result of response.results) { |
149 | | - * console.log(`${result.actionId}: ${result.similarityScore.toFixed(2)}`); |
| 147 | + * console.log(`${result.id}: ${result.similarityScore.toFixed(2)}`); |
150 | 148 | * } |
151 | 149 | * ``` |
152 | 150 | */ |
|
0 commit comments