@mcpjam/sdk 0.8.1 → 0.8.3
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/index.d.mts +4 -13
- package/dist/index.d.ts +4 -13
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -496,6 +496,7 @@ declare class MCPClientManager {
|
|
|
496
496
|
*/
|
|
497
497
|
getToolsForAiSdk(serverIds?: string[] | string, options?: {
|
|
498
498
|
schemas?: ToolSchemaOverrides | "automatic";
|
|
499
|
+
needsApproval?: boolean;
|
|
499
500
|
}): Promise<AiSdkTool>;
|
|
500
501
|
/**
|
|
501
502
|
* Executes a tool on a server.
|
|
@@ -531,15 +532,9 @@ declare class MCPClientManager {
|
|
|
531
532
|
type: "audio";
|
|
532
533
|
data: string;
|
|
533
534
|
mimeType: string;
|
|
534
|
-
annotations
|
|
535
|
-
/**
|
|
536
|
-
* Lists prompts available from a server.
|
|
537
|
-
*/
|
|
538
|
-
?: {
|
|
535
|
+
annotations?: {
|
|
539
536
|
audience?: ("user" | "assistant")[] | undefined;
|
|
540
|
-
priority
|
|
541
|
-
* Lists prompts available from a server.
|
|
542
|
-
*/: number | undefined;
|
|
537
|
+
priority?: number | undefined;
|
|
543
538
|
lastModified?: string | undefined;
|
|
544
539
|
} | undefined;
|
|
545
540
|
_meta?: Record<string, unknown> | undefined;
|
|
@@ -666,11 +661,7 @@ declare class MCPClientManager {
|
|
|
666
661
|
uri: string;
|
|
667
662
|
blob: string;
|
|
668
663
|
mimeType?: string | undefined;
|
|
669
|
-
_meta
|
|
670
|
-
/**
|
|
671
|
-
* Lists resources available from a server.
|
|
672
|
-
*/
|
|
673
|
-
?: Record<string, unknown> | undefined;
|
|
664
|
+
_meta?: Record<string, unknown> | undefined;
|
|
674
665
|
})[];
|
|
675
666
|
_meta?: {
|
|
676
667
|
[x: string]: unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -496,6 +496,7 @@ declare class MCPClientManager {
|
|
|
496
496
|
*/
|
|
497
497
|
getToolsForAiSdk(serverIds?: string[] | string, options?: {
|
|
498
498
|
schemas?: ToolSchemaOverrides | "automatic";
|
|
499
|
+
needsApproval?: boolean;
|
|
499
500
|
}): Promise<AiSdkTool>;
|
|
500
501
|
/**
|
|
501
502
|
* Executes a tool on a server.
|
|
@@ -531,15 +532,9 @@ declare class MCPClientManager {
|
|
|
531
532
|
type: "audio";
|
|
532
533
|
data: string;
|
|
533
534
|
mimeType: string;
|
|
534
|
-
annotations
|
|
535
|
-
/**
|
|
536
|
-
* Lists prompts available from a server.
|
|
537
|
-
*/
|
|
538
|
-
?: {
|
|
535
|
+
annotations?: {
|
|
539
536
|
audience?: ("user" | "assistant")[] | undefined;
|
|
540
|
-
priority
|
|
541
|
-
* Lists prompts available from a server.
|
|
542
|
-
*/: number | undefined;
|
|
537
|
+
priority?: number | undefined;
|
|
543
538
|
lastModified?: string | undefined;
|
|
544
539
|
} | undefined;
|
|
545
540
|
_meta?: Record<string, unknown> | undefined;
|
|
@@ -666,11 +661,7 @@ declare class MCPClientManager {
|
|
|
666
661
|
uri: string;
|
|
667
662
|
blob: string;
|
|
668
663
|
mimeType?: string | undefined;
|
|
669
|
-
_meta
|
|
670
|
-
/**
|
|
671
|
-
* Lists resources available from a server.
|
|
672
|
-
*/
|
|
673
|
-
?: Record<string, unknown> | undefined;
|
|
664
|
+
_meta?: Record<string, unknown> | undefined;
|
|
674
665
|
})[];
|
|
675
666
|
_meta?: {
|
|
676
667
|
[x: string]: unknown;
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var openai = require('@ai-sdk/openai');
|
|
|
17
17
|
var xai = require('@ai-sdk/xai');
|
|
18
18
|
var aiSdkProvider = require('@openrouter/ai-sdk-provider');
|
|
19
19
|
var ollamaAiProviderV2 = require('ollama-ai-provider-v2');
|
|
20
|
+
var posthogNode = require('posthog-node');
|
|
20
21
|
|
|
21
22
|
// src/mcp-client-manager/MCPClientManager.ts
|
|
22
23
|
var DEFAULT_CLIENT_VERSION = "1.0.0";
|
|
@@ -584,7 +585,8 @@ function scrubMetaAndStructuredContentFromToolResult(result) {
|
|
|
584
585
|
}
|
|
585
586
|
async function convertMCPToolsToVercelTools(listToolsResult, {
|
|
586
587
|
schemas = "automatic",
|
|
587
|
-
callTool
|
|
588
|
+
callTool,
|
|
589
|
+
needsApproval
|
|
588
590
|
}) {
|
|
589
591
|
const tools = {};
|
|
590
592
|
for (const toolDescription of listToolsResult.tools) {
|
|
@@ -595,17 +597,17 @@ async function convertMCPToolsToVercelTools(listToolsResult, {
|
|
|
595
597
|
const result = await callTool({ name, args, options });
|
|
596
598
|
return types_js.CallToolResultSchema.parse(result);
|
|
597
599
|
};
|
|
598
|
-
const toModelOutput = isMcpAppTool(toolMeta) ? (
|
|
600
|
+
const toModelOutput = isMcpAppTool(toolMeta) ? (opts) => {
|
|
599
601
|
const scrubbed = scrubMetaAndStructuredContentFromToolResult(
|
|
600
602
|
opts.output
|
|
601
603
|
);
|
|
602
604
|
return { type: "json", value: scrubbed };
|
|
603
|
-
}
|
|
605
|
+
} : isChatGPTAppTool(toolMeta) ? (opts) => {
|
|
604
606
|
const scrubbed = scrubStructuredContentFromToolResult(
|
|
605
607
|
opts.output
|
|
606
608
|
);
|
|
607
609
|
return { type: "json", value: scrubbed };
|
|
608
|
-
}
|
|
610
|
+
} : void 0;
|
|
609
611
|
let vercelTool;
|
|
610
612
|
if (schemas === "automatic") {
|
|
611
613
|
const normalizedInputSchema = ensureJsonSchemaObject(inputSchema);
|
|
@@ -613,7 +615,8 @@ async function convertMCPToolsToVercelTools(listToolsResult, {
|
|
|
613
615
|
description,
|
|
614
616
|
inputSchema: ai.jsonSchema(normalizedInputSchema),
|
|
615
617
|
execute,
|
|
616
|
-
...toModelOutput ? { toModelOutput } : {}
|
|
618
|
+
...toModelOutput ? { toModelOutput } : {},
|
|
619
|
+
...needsApproval != null ? { needsApproval } : {}
|
|
617
620
|
});
|
|
618
621
|
} else {
|
|
619
622
|
const overrides = schemas;
|
|
@@ -624,7 +627,8 @@ async function convertMCPToolsToVercelTools(listToolsResult, {
|
|
|
624
627
|
description,
|
|
625
628
|
inputSchema: overrides[name].inputSchema,
|
|
626
629
|
execute,
|
|
627
|
-
...toModelOutput ? { toModelOutput } : {}
|
|
630
|
+
...toModelOutput ? { toModelOutput } : {},
|
|
631
|
+
...needsApproval != null ? { needsApproval } : {}
|
|
628
632
|
});
|
|
629
633
|
}
|
|
630
634
|
tools[name] = vercelTool;
|
|
@@ -899,6 +903,7 @@ var MCPClientManager = class {
|
|
|
899
903
|
const listToolsResult = await this.listTools(id);
|
|
900
904
|
const tools = await convertMCPToolsToVercelTools(listToolsResult, {
|
|
901
905
|
schemas: options.schemas,
|
|
906
|
+
needsApproval: options.needsApproval,
|
|
902
907
|
callTool: async ({ name, args, options: callOptions }) => {
|
|
903
908
|
const requestOptions = callOptions?.abortSignal ? { signal: callOptions.abortSignal } : void 0;
|
|
904
909
|
const result = await this.executeTool(
|
|
@@ -2375,6 +2380,12 @@ function calculateLatencyStats(values) {
|
|
|
2375
2380
|
count: values.length
|
|
2376
2381
|
};
|
|
2377
2382
|
}
|
|
2383
|
+
var posthog = new posthogNode.PostHog(
|
|
2384
|
+
"phc_dTOPniyUNU2kD8Jx8yHMXSqiZHM8I91uWopTMX6EBE9",
|
|
2385
|
+
{
|
|
2386
|
+
host: "https://us.i.posthog.com"
|
|
2387
|
+
}
|
|
2388
|
+
);
|
|
2378
2389
|
|
|
2379
2390
|
// src/EvalTest.ts
|
|
2380
2391
|
var Semaphore = class {
|
|
@@ -2429,6 +2440,13 @@ var EvalTest = class {
|
|
|
2429
2440
|
* Run this test with the given agent and options
|
|
2430
2441
|
*/
|
|
2431
2442
|
async run(agent, options) {
|
|
2443
|
+
posthog.capture({
|
|
2444
|
+
event: "eval_test_run_triggered",
|
|
2445
|
+
properties: {
|
|
2446
|
+
iterations: options.iterations,
|
|
2447
|
+
concurrency: options.concurrency ?? 5
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2432
2450
|
const concurrency = options.concurrency ?? 5;
|
|
2433
2451
|
const retries = options.retries ?? 0;
|
|
2434
2452
|
const timeoutMs = options.timeoutMs ?? 3e4;
|