@cursor/july 0.1.9 → 0.1.11
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/AGENTS.md +1 -0
- package/dist/bin/agent-serve.js +26 -3
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +2 -1
- package/dist/channels/github/types.d.ts +4 -0
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.js +1 -1
- package/dist/channels/slack/dispatch.d.ts +13 -0
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +36 -11
- package/dist/channels/slack/eval-directive.d.ts +63 -0
- package/dist/channels/slack/eval-directive.d.ts.map +1 -0
- package/dist/channels/slack/eval-directive.js +283 -0
- package/dist/channels/slack/index.d.ts +1 -0
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +1 -0
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +4 -2
- package/dist/channels/slack/types.d.ts +7 -0
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/connections.d.ts +10 -5
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +10 -5
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.Ciosf24M.js → app.BcXUGca7.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BIbvK8M1.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BcRDly7n.js → VPLocalSearchBox.CWur6XGZ.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CMpbjdfx.js → theme.BnvulOX2.js} +2 -2
- package/dist/docs/assets/{deployment.md.DC5-ImcM.js → deployment.md.TecHo0_2.js} +3 -3
- package/dist/docs/assets/{deployment.md.DC5-ImcM.lean.js → deployment.md.TecHo0_2.lean.js} +1 -1
- package/dist/docs/assets/guides_mcp-oauth.md.DqmEOQY1.js +29 -0
- package/dist/docs/assets/guides_mcp-oauth.md.DqmEOQY1.lean.js +1 -0
- package/dist/docs/assets/{index.md.COiu-1jL.js → index.md.t0TM2Qzz.js} +3 -3
- package/dist/docs/assets/{index.md.COiu-1jL.lean.js → index.md.t0TM2Qzz.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.D189RBCH.js → reference_cli.md.B74NrVzb.js} +5 -4
- package/dist/docs/assets/{reference_cli.md.D189RBCH.lean.js → reference_cli.md.B74NrVzb.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.zaEYCLHT.js → reference_connections.md.CsSr3rDz.js} +9 -4
- package/dist/docs/assets/{reference_connections.md.zaEYCLHT.lean.js → reference_connections.md.CsSr3rDz.lean.js} +1 -1
- package/dist/docs/assets/reference_prompt.md.BaiweQxE.js +1 -0
- package/dist/docs/assets/reference_prompt.md.BaiweQxE.lean.js +1 -0
- package/dist/docs/assets/{reference_tools.md.CqgJroI0.js → reference_tools.md.BRSDnTbN.js} +16 -3
- package/dist/docs/assets/{reference_tools.md.CqgJroI0.lean.js → reference_tools.md.BRSDnTbN.lean.js} +1 -1
- package/dist/docs/assets/{troubleshooting.md.DkovjS7h.js → troubleshooting.md.CmQkmnzC.js} +1 -1
- package/dist/docs/assets/{troubleshooting.md.DkovjS7h.lean.js → troubleshooting.md.CmQkmnzC.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +7 -7
- package/dist/docs/evals.html +4 -4
- package/dist/docs/example-agents/approval-buddy.html +4 -4
- package/dist/docs/example-agents/benny.html +4 -4
- package/dist/docs/example-agents/bugbot.html +4 -4
- package/dist/docs/example-agents/codebase-wiki.html +4 -4
- package/dist/docs/example-agents/codeowners-review.html +4 -4
- package/dist/docs/example-agents/concierge.html +4 -4
- package/dist/docs/example-agents/fsd.html +4 -4
- package/dist/docs/example-agents/index.html +4 -4
- package/dist/docs/example-agents/knowledge-base.html +4 -4
- package/dist/docs/example-agents/oncall.html +4 -4
- package/dist/docs/example-agents/security-reviewer.html +4 -4
- package/dist/docs/example-agents/slack-agent.html +4 -4
- package/dist/docs/example-agents/weather-agent.html +4 -4
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-runtime.html +4 -4
- package/dist/docs/guides/github.html +4 -4
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/mcp-oauth.html +53 -0
- package/dist/docs/guides/slack.html +4 -4
- package/dist/docs/guides/webhooks.html +4 -4
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +4 -4
- package/dist/docs/index.html +6 -6
- package/dist/docs/quickstart.html +4 -4
- package/dist/docs/reference/agent-config.html +4 -4
- package/dist/docs/reference/channels.html +4 -4
- package/dist/docs/reference/cli.html +8 -7
- package/dist/docs/reference/connections.html +13 -8
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +4 -4
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/prompt.html +33 -0
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +4 -4
- package/dist/docs/reference/skills.html +5 -5
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +20 -7
- package/dist/docs/scaffolding-agents.html +4 -4
- package/dist/docs/storage.html +4 -4
- package/dist/docs/troubleshooting.html +5 -5
- package/dist/evals.d.ts +39 -0
- package/dist/evals.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +7 -4
- package/dist/internal/cli-mcp-oauth.d.ts +16 -0
- package/dist/internal/cli-mcp-oauth.d.ts.map +1 -0
- package/dist/internal/cli-mcp-oauth.js +194 -0
- package/dist/internal/cli-mcp.d.ts +4 -1
- package/dist/internal/cli-mcp.d.ts.map +1 -1
- package/dist/internal/cli-mcp.js +19 -1
- package/dist/internal/corp-ca.d.ts +9 -0
- package/dist/internal/corp-ca.d.ts.map +1 -0
- package/dist/internal/corp-ca.js +44 -0
- package/dist/internal/cursor/account-mcp.d.ts +17 -4
- package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
- package/dist/internal/cursor/account-mcp.js +105 -17
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +64 -10
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +1 -0
- package/dist/internal/logs-client.js +1 -1
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +49 -26
- package/dist/internal/mcp-oauth.d.ts +88 -0
- package/dist/internal/mcp-oauth.d.ts.map +1 -0
- package/dist/internal/mcp-oauth.js +385 -0
- package/dist/internal/resolved-connections.d.ts +6 -0
- package/dist/internal/resolved-connections.d.ts.map +1 -1
- package/dist/internal/resolved-connections.js +10 -3
- package/dist/internal/sdk-runner.d.ts +9 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +28 -2
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +24 -6
- package/dist/internal/session-engine.d.ts +30 -10
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +166 -74
- package/dist/internal/sessions-client.d.ts +16 -2
- package/dist/internal/sessions-client.d.ts.map +1 -1
- package/dist/internal/sessions-client.js +30 -13
- package/dist/internal/storage-coordinator.d.ts +11 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +30 -0
- package/dist/internal/stream-progress.d.ts.map +1 -1
- package/dist/internal/stream-progress.js +8 -4
- package/dist/internal/turn-governor.d.ts +54 -0
- package/dist/internal/turn-governor.d.ts.map +1 -0
- package/dist/internal/turn-governor.js +111 -0
- package/dist/playground/assets/{index-C0-QEG4O.js → index-BIGLubwK.js} +46 -46
- package/dist/playground/assets/{index-z3JY9O2x.css → index-C17ZQKDG.css} +1 -1
- package/dist/playground/index.html +2 -2
- package/dist/prompt.d.ts +39 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +70 -0
- package/dist/storage-backends/cursor-hosted.d.ts +10 -0
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +14 -0
- package/dist/types.d.ts +93 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -0
- package/docs/README.md +4 -0
- package/docs/deployment.md +6 -1
- package/docs/guides/mcp-oauth.md +157 -0
- package/docs/reference/cli.md +30 -0
- package/docs/reference/connections.md +32 -2
- package/docs/reference/prompt.md +47 -0
- package/docs/reference/tools.md +21 -0
- package/docs/troubleshooting.md +11 -0
- package/package.json +9 -2
- package/skills/create-agent/SKILL.md +7 -3
- package/skills/framework-map/SKILL.md +1 -0
- package/skills/mcp-auth/SKILL.md +138 -0
- package/src/bin/agent-serve.ts +30 -3
- package/src/channels/github/github-channel.ts +2 -0
- package/src/channels/github/types.ts +4 -0
- package/src/channels/slack/cursor-account.ts +2 -0
- package/src/channels/slack/dispatch.ts +49 -0
- package/src/channels/slack/eval-directive.ts +348 -0
- package/src/channels/slack/index.ts +1 -0
- package/src/channels/slack/slack-channel.ts +3 -0
- package/src/channels/slack/types.ts +7 -0
- package/src/connections.ts +10 -5
- package/src/evals.ts +43 -0
- package/src/index.ts +3 -0
- package/src/internal/cli-ax.ts +10 -4
- package/src/internal/cli-mcp-oauth.ts +254 -0
- package/src/internal/cli-mcp.ts +25 -2
- package/src/internal/cursor/account-mcp.ts +153 -41
- package/src/internal/discovery.ts +70 -8
- package/src/internal/distribution.ts +1 -0
- package/src/internal/logs-client.ts +1 -1
- package/src/internal/mcp-host.ts +33 -9
- package/src/internal/mcp-oauth.ts +496 -0
- package/src/internal/resolved-connections.ts +20 -5
- package/src/internal/sdk-runner.ts +37 -1
- package/src/internal/server.ts +28 -6
- package/src/internal/session-engine.ts +192 -76
- package/src/internal/sessions-client.ts +51 -15
- package/src/internal/storage-coordinator.ts +36 -0
- package/src/internal/stream-progress.ts +8 -0
- package/src/internal/turn-governor.ts +145 -0
- package/src/prompt.ts +83 -0
- package/src/storage-backends/cursor-hosted.ts +21 -0
- package/src/types.ts +92 -6
- package/dist/docs/assets/chunks/@localSearchIndexroot.D154Detj.js +0 -1
|
@@ -21,6 +21,7 @@ import { type ABConfigFile, resolveABMaxPlaygroundSessions } from "../ab.js";
|
|
|
21
21
|
import { httpChannel } from "../channels.js";
|
|
22
22
|
import type { StorageDefinition } from "../storage.js";
|
|
23
23
|
import {
|
|
24
|
+
type AgentConcurrencyOptions,
|
|
24
25
|
type AgentConfigDefinition,
|
|
25
26
|
type AgentHostingOptions,
|
|
26
27
|
type AgentProject,
|
|
@@ -40,6 +41,7 @@ import {
|
|
|
40
41
|
type HookDefinition,
|
|
41
42
|
type HttpChannelDefinition,
|
|
42
43
|
type InstructionsDefinition,
|
|
44
|
+
MAX_RUNNING_TURNS_LIMIT,
|
|
43
45
|
type ModelSetting,
|
|
44
46
|
type ResolvedAgent,
|
|
45
47
|
type ScheduleDefinition,
|
|
@@ -50,6 +52,7 @@ import {
|
|
|
50
52
|
toPublicCloudInfo,
|
|
51
53
|
} from "../types.js";
|
|
52
54
|
import { registerAuthoredModuleLoaders } from "./authored-loaders.js";
|
|
55
|
+
import { normalizePositiveInt } from "./bounded-int.js";
|
|
53
56
|
import { getDefinitionKind } from "./brand.js";
|
|
54
57
|
import { isValidCron } from "./cron.js";
|
|
55
58
|
import { parseFrontmatter } from "./frontmatter.js";
|
|
@@ -372,6 +375,7 @@ async function loadAgent(
|
|
|
372
375
|
cwd: localCwd,
|
|
373
376
|
};
|
|
374
377
|
const hosting = resolveHosting(ctx, agentDir, config?.hosting);
|
|
378
|
+
const concurrency = resolveConcurrency(ctx, agentDir, config?.concurrency);
|
|
375
379
|
|
|
376
380
|
if (runtime === "cloud") {
|
|
377
381
|
warnCloudRuntimeLimitations(ctx, agentDir, {
|
|
@@ -393,6 +397,7 @@ async function loadAgent(
|
|
|
393
397
|
cloud,
|
|
394
398
|
local,
|
|
395
399
|
hosting,
|
|
400
|
+
concurrency,
|
|
396
401
|
tools,
|
|
397
402
|
skills,
|
|
398
403
|
connections,
|
|
@@ -469,6 +474,37 @@ function resolveHosting(
|
|
|
469
474
|
};
|
|
470
475
|
}
|
|
471
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Validate the authored `concurrency` block. Invalid values are **error**
|
|
479
|
+
* diagnostics (serve refuses to start): silently dropping a turn ceiling
|
|
480
|
+
* would fail open to unlimited parallelism, the opposite of what the
|
|
481
|
+
* author asked for.
|
|
482
|
+
*/
|
|
483
|
+
function resolveConcurrency(
|
|
484
|
+
ctx: DiscoveryContext,
|
|
485
|
+
agentDir: string,
|
|
486
|
+
concurrency: AgentConcurrencyOptions | undefined
|
|
487
|
+
): AgentConcurrencyOptions | undefined {
|
|
488
|
+
if (concurrency === undefined || concurrency.maxRunningTurns === undefined) {
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
return {
|
|
493
|
+
maxRunningTurns: normalizePositiveInt(concurrency.maxRunningTurns, {
|
|
494
|
+
label: "concurrency.maxRunningTurns",
|
|
495
|
+
max: MAX_RUNNING_TURNS_LIMIT,
|
|
496
|
+
}),
|
|
497
|
+
};
|
|
498
|
+
} catch (error) {
|
|
499
|
+
ctx.diagnostics.push({
|
|
500
|
+
severity: "error",
|
|
501
|
+
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
502
|
+
message: error instanceof Error ? error.message : String(error),
|
|
503
|
+
});
|
|
504
|
+
return undefined;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
472
508
|
async function loadAgentConfig(
|
|
473
509
|
ctx: DiscoveryContext,
|
|
474
510
|
agentDir: string,
|
|
@@ -831,11 +867,24 @@ function connectionTransportLabel(transport: ConnectionTransport): string {
|
|
|
831
867
|
return `agent:${transport.agent}`;
|
|
832
868
|
}
|
|
833
869
|
if ("url" in transport) {
|
|
834
|
-
return transport.
|
|
870
|
+
return transport.oauth === true
|
|
871
|
+
? `${transport.url} (oauth)`
|
|
872
|
+
: transport.url;
|
|
835
873
|
}
|
|
836
874
|
return transport.command;
|
|
837
875
|
}
|
|
838
876
|
|
|
877
|
+
function hasAuthorizationHeader(
|
|
878
|
+
headers: Record<string, string> | undefined
|
|
879
|
+
): boolean {
|
|
880
|
+
if (headers === undefined) {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
return Object.keys(headers).some(
|
|
884
|
+
(key) => key.toLowerCase() === "authorization"
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
|
|
839
888
|
function connectionTransport(
|
|
840
889
|
connection: ConnectionDefinition
|
|
841
890
|
): ConnectionTransport | undefined {
|
|
@@ -852,11 +901,10 @@ function connectionTransport(
|
|
|
852
901
|
}
|
|
853
902
|
if ("url" in connection && !isBlank(connection.url)) {
|
|
854
903
|
return {
|
|
855
|
-
|
|
904
|
+
type: connection.type,
|
|
856
905
|
url: connection.url,
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
: { headers: connection.headers }),
|
|
906
|
+
headers: connection.headers,
|
|
907
|
+
oauth: connection.oauth === true ? true : undefined,
|
|
860
908
|
};
|
|
861
909
|
}
|
|
862
910
|
if ("command" in connection && !isBlank(connection.command)) {
|
|
@@ -974,6 +1022,19 @@ async function loadConnections(
|
|
|
974
1022
|
continue;
|
|
975
1023
|
}
|
|
976
1024
|
const connection = definition as ConnectionDefinition;
|
|
1025
|
+
if (
|
|
1026
|
+
"url" in connection &&
|
|
1027
|
+
connection.oauth === true &&
|
|
1028
|
+
hasAuthorizationHeader(connection.headers)
|
|
1029
|
+
) {
|
|
1030
|
+
ctx.diagnostics.push({
|
|
1031
|
+
severity: "error",
|
|
1032
|
+
path: displayPath(ctx, entryPath),
|
|
1033
|
+
message:
|
|
1034
|
+
"MCP connection `oauth: true` cannot set an Authorization header. Drop the header or remove `oauth`.",
|
|
1035
|
+
});
|
|
1036
|
+
continue;
|
|
1037
|
+
}
|
|
977
1038
|
const transport = connectionTransport(connection);
|
|
978
1039
|
if (transport === undefined) {
|
|
979
1040
|
ctx.diagnostics.push({
|
|
@@ -1009,9 +1070,8 @@ async function loadConnections(
|
|
|
1009
1070
|
connections.push({
|
|
1010
1071
|
name,
|
|
1011
1072
|
transport,
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
: { description: connection.description }),
|
|
1073
|
+
description: connection.description,
|
|
1074
|
+
hostOnly: connection.hostOnly,
|
|
1015
1075
|
});
|
|
1016
1076
|
}
|
|
1017
1077
|
return connections;
|
|
@@ -1529,6 +1589,7 @@ export function projectInfo(project: AgentProject): AgentProjectInfo {
|
|
|
1529
1589
|
agent.cloud === undefined ? undefined : toPublicCloudInfo(agent.cloud),
|
|
1530
1590
|
local: agent.local,
|
|
1531
1591
|
hosting: agent.hosting,
|
|
1592
|
+
concurrency: agent.concurrency,
|
|
1532
1593
|
mcp: { path: MCP_ENDPOINT_PATH, tools: mcpEndpointToolNames(project) },
|
|
1533
1594
|
instructions:
|
|
1534
1595
|
agent.instructions === undefined
|
|
@@ -1554,6 +1615,7 @@ export function projectInfo(project: AgentProject): AgentProjectInfo {
|
|
|
1554
1615
|
connections: agent.connections.map((connection) => ({
|
|
1555
1616
|
name: connection.name,
|
|
1556
1617
|
transport: connectionTransportLabel(connection.transport),
|
|
1618
|
+
hostOnly: connection.hostOnly,
|
|
1557
1619
|
})),
|
|
1558
1620
|
subagents: agent.subagents.map((subagent) => ({
|
|
1559
1621
|
name: subagent.name,
|
|
@@ -100,6 +100,7 @@ export const AUTHORING_ENTRY_FILES: ReadonlyArray<
|
|
|
100
100
|
["reminders", "reminders.js"],
|
|
101
101
|
["connections", "connections.js"],
|
|
102
102
|
["hooks", "hooks.js"],
|
|
103
|
+
["prompt", "prompt.js"],
|
|
103
104
|
["evals", "evals.js"],
|
|
104
105
|
["ab", "ab.js"],
|
|
105
106
|
["storage", "storage.js"],
|
|
@@ -49,7 +49,7 @@ const PROGRESS_MESSAGES: Readonly<Record<LogsProgress, string>> = {
|
|
|
49
49
|
queued: "Waiting to start…",
|
|
50
50
|
preparing: "Preparing runtime…",
|
|
51
51
|
creating: "Creating runtime…",
|
|
52
|
-
building: "Checking out source
|
|
52
|
+
building: "Checking out source…",
|
|
53
53
|
starting: "Starting agent and waiting for health…",
|
|
54
54
|
finalizing: "Finishing deployment…",
|
|
55
55
|
running: "Deployment running",
|
package/src/internal/mcp-host.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* {@link HostMcpRegistry} on {@link ChannelHandlerArgs.host}.mcp
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
12
13
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
13
14
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
14
15
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
@@ -20,6 +21,8 @@ import type {
|
|
|
20
21
|
HostMcpToolInfo,
|
|
21
22
|
JsonObject,
|
|
22
23
|
} from "../types.js";
|
|
24
|
+
import { CLI_COMMAND_NAME as CLI } from "./distribution.js";
|
|
25
|
+
import { createHostMcpOAuthProvider } from "./mcp-oauth.js";
|
|
23
26
|
|
|
24
27
|
interface OpenedConnection {
|
|
25
28
|
client: Client;
|
|
@@ -118,8 +121,21 @@ async function openConnection(
|
|
|
118
121
|
name: "agent-serve",
|
|
119
122
|
version: "0.1.0",
|
|
120
123
|
});
|
|
121
|
-
const transport = createTransport(connection);
|
|
122
|
-
|
|
124
|
+
const transport = await createTransport(connection);
|
|
125
|
+
try {
|
|
126
|
+
await client.connect(transport);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (
|
|
129
|
+
error instanceof UnauthorizedError &&
|
|
130
|
+
isOauthHttpTransport(connection.transport)
|
|
131
|
+
) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
`MCP connection "${connection.name}" needs authorization. Run \`${CLI} mcp oauth ${connection.name}\`.`,
|
|
134
|
+
{ cause: error }
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
123
139
|
|
|
124
140
|
return {
|
|
125
141
|
client,
|
|
@@ -138,7 +154,7 @@ async function openConnection(
|
|
|
138
154
|
};
|
|
139
155
|
}
|
|
140
156
|
|
|
141
|
-
function createTransport(connection: DiscoveredConnection) {
|
|
157
|
+
async function createTransport(connection: DiscoveredConnection) {
|
|
142
158
|
const transport = connection.transport;
|
|
143
159
|
if ("agent" in transport) {
|
|
144
160
|
// Peers are resolved to concrete URLs by the serve host before any call
|
|
@@ -176,16 +192,24 @@ function createTransport(connection: DiscoveredConnection) {
|
|
|
176
192
|
transport.headers === undefined
|
|
177
193
|
? undefined
|
|
178
194
|
: { headers: transport.headers };
|
|
195
|
+
const authProvider =
|
|
196
|
+
transport.oauth === true
|
|
197
|
+
? await createHostMcpOAuthProvider({
|
|
198
|
+
identifier: connection.name,
|
|
199
|
+
resourceUrl: transport.url,
|
|
200
|
+
})
|
|
201
|
+
: undefined;
|
|
179
202
|
|
|
180
203
|
if (transport.type === "sse") {
|
|
181
|
-
return new SSEClientTransport(url, {
|
|
182
|
-
...(requestInit === undefined ? {} : { requestInit }),
|
|
183
|
-
});
|
|
204
|
+
return new SSEClientTransport(url, { requestInit, authProvider });
|
|
184
205
|
}
|
|
206
|
+
return new StreamableHTTPClientTransport(url, { requestInit, authProvider });
|
|
207
|
+
}
|
|
185
208
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
209
|
+
function isOauthHttpTransport(
|
|
210
|
+
transport: DiscoveredConnection["transport"]
|
|
211
|
+
): boolean {
|
|
212
|
+
return "url" in transport && transport.oauth === true;
|
|
189
213
|
}
|
|
190
214
|
|
|
191
215
|
function normalizeCallResult(result: unknown): HostMcpCallResult {
|