@pgnio/helios-mcp 0.2.0 → 0.2.2
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/chunk-EIAUO3XE.mjs +2955 -0
- package/dist/chunk-NCF7ASJB.mjs +2986 -0
- package/dist/chunk-XE6HRID3.mjs +2992 -0
- package/dist/cli.js +40 -13
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +44 -15
- package/dist/index.mjs +5 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -920,11 +920,15 @@ var HeliosAgentMcpAuthService = class {
|
|
|
920
920
|
requestedConstraints
|
|
921
921
|
});
|
|
922
922
|
if (pendingLogin) {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
923
|
+
const polled = await this.pollLogin(pendingLogin.deviceCode).catch(() => null);
|
|
924
|
+
if (polled?.status === "connected") return polled;
|
|
925
|
+
if (polled?.status !== "rejected" && polled?.status !== "expired") {
|
|
926
|
+
return {
|
|
927
|
+
...pendingLogin,
|
|
928
|
+
connected: false,
|
|
929
|
+
message: formatHeliosLoginPrompt(pendingLogin)
|
|
930
|
+
};
|
|
931
|
+
}
|
|
928
932
|
}
|
|
929
933
|
const started = await this.startLogin({
|
|
930
934
|
clientName: options.clientName ?? "Helios MCP",
|
|
@@ -937,7 +941,24 @@ var HeliosAgentMcpAuthService = class {
|
|
|
937
941
|
message: formatHeliosLoginPrompt(started)
|
|
938
942
|
};
|
|
939
943
|
}
|
|
944
|
+
/** Polls the given login, or the stored pending one when no device code is given. */
|
|
940
945
|
async pollLogin(deviceCode) {
|
|
946
|
+
if (!deviceCode) {
|
|
947
|
+
const pending = await this.sessionStore.getPendingLogin();
|
|
948
|
+
if (!pending) {
|
|
949
|
+
const session = await this.getValidSession();
|
|
950
|
+
if (session) return { ...sanitizeAgentSession(session), connected: true, status: "connected" };
|
|
951
|
+
return {
|
|
952
|
+
status: "failed",
|
|
953
|
+
connected: false,
|
|
954
|
+
message: "No Helios login is in progress. Call helios_auth_ensure_login to start one."
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
deviceCode = pending.deviceCode;
|
|
958
|
+
} else {
|
|
959
|
+
const pending = await this.sessionStore.getPendingLogin();
|
|
960
|
+
if (pending && pending.userCode.toUpperCase() === deviceCode.trim().toUpperCase()) deviceCode = pending.deviceCode;
|
|
961
|
+
}
|
|
941
962
|
try {
|
|
942
963
|
const response = await this.client.exchangeDeviceCode(deviceCode);
|
|
943
964
|
const session = createStoredAgentSession(response, this.now());
|
|
@@ -1072,7 +1093,7 @@ User code: ${result.userCode}
|
|
|
1072
1093
|
|
|
1073
1094
|
Requested scopes: ${result.requestedScope.join(", ")}
|
|
1074
1095
|
|
|
1075
|
-
After approving access,
|
|
1096
|
+
After approving access, call helios_auth_ensure_login (or helios_auth_poll_login) again to finish connecting.`;
|
|
1076
1097
|
}
|
|
1077
1098
|
function isPendingLoginCompatible(pendingLogin, requestedScope, requestedConstraints) {
|
|
1078
1099
|
const pendingScope = new Set(pendingLogin.requestedScope);
|
|
@@ -2016,7 +2037,8 @@ function asPending2(login) {
|
|
|
2016
2037
|
// src/tools.ts
|
|
2017
2038
|
var import_zod5 = require("zod");
|
|
2018
2039
|
var pollLoginInputSchema = import_zod5.z.object({
|
|
2019
|
-
|
|
2040
|
+
/** Optional: defaults to the login started by helios_auth_ensure_login / helios_auth_start_login. */
|
|
2041
|
+
deviceCode: import_zod5.z.string().min(1).optional()
|
|
2020
2042
|
});
|
|
2021
2043
|
var startLoginOutputSchema = import_zod5.z.object({
|
|
2022
2044
|
status: import_zod5.z.literal("pending"),
|
|
@@ -2325,7 +2347,7 @@ function createHeliosAuthToolDefinitions(service) {
|
|
|
2325
2347
|
{
|
|
2326
2348
|
name: "helios_auth_ensure_login",
|
|
2327
2349
|
title: "Ensure Helios Login",
|
|
2328
|
-
description: "Ensures a delegated Helios session exists, or starts a login flow and returns a ready-to-display approval prompt.",
|
|
2350
|
+
description: "Ensures a delegated Helios session exists, or starts a login flow and returns a ready-to-display approval prompt. Call it again after the person approves: it finishes connecting.",
|
|
2329
2351
|
inputSchema: ensureLoginInputSchema,
|
|
2330
2352
|
async execute(input) {
|
|
2331
2353
|
const result = ensureLoginOutputSchema.parse(await service.ensureLogin(input));
|
|
@@ -2347,7 +2369,7 @@ function createHeliosAuthToolDefinitions(service) {
|
|
|
2347
2369
|
{
|
|
2348
2370
|
name: "helios_auth_poll_login",
|
|
2349
2371
|
title: "Poll Helios Login",
|
|
2350
|
-
description: "
|
|
2372
|
+
description: "Checks whether the Helios login was approved and finishes connecting. The device code is optional; without it, the login in progress is checked.",
|
|
2351
2373
|
inputSchema: pollLoginInputSchema,
|
|
2352
2374
|
async execute(input) {
|
|
2353
2375
|
const result = pollLoginOutputSchema.parse(await service.pollLogin(input.deviceCode));
|
|
@@ -2786,7 +2808,7 @@ function withManualLoginFields(result) {
|
|
|
2786
2808
|
return {
|
|
2787
2809
|
actionRequired: true,
|
|
2788
2810
|
loginUrl: result.verificationUriComplete,
|
|
2789
|
-
nextStep: "Open the login URL in your browser, approve Helios access, then
|
|
2811
|
+
nextStep: "Open the login URL in your browser, approve Helios access, then call helios_auth_ensure_login again to finish connecting."
|
|
2790
2812
|
};
|
|
2791
2813
|
}
|
|
2792
2814
|
function buildPortfolioText(result) {
|
|
@@ -2799,7 +2821,7 @@ ${result.verificationUriComplete}
|
|
|
2799
2821
|
|
|
2800
2822
|
User code: ${result.userCode}
|
|
2801
2823
|
|
|
2802
|
-
After approving access,
|
|
2824
|
+
After approving access, call helios_auth_ensure_login (or helios_auth_poll_login) again to finish connecting.`;
|
|
2803
2825
|
}
|
|
2804
2826
|
|
|
2805
2827
|
// src/server.ts
|
|
@@ -2813,7 +2835,7 @@ async function createHeliosAgentMcpServer(options) {
|
|
|
2813
2835
|
const { McpServer } = await import("@modelcontextprotocol/sdk/server/mcp.js");
|
|
2814
2836
|
const server = new McpServer({
|
|
2815
2837
|
name: "helios",
|
|
2816
|
-
version: "0.
|
|
2838
|
+
version: "0.2.2"
|
|
2817
2839
|
});
|
|
2818
2840
|
const sessionStore = options.sessionStore ?? new FileAgentSessionStore(options.sessionPath ?? getDefaultHeliosAgentMcpSessionPath());
|
|
2819
2841
|
const client = new HeliosAgentAuthClient({
|
|
@@ -2906,6 +2928,11 @@ function toolAnnotations(name) {
|
|
|
2906
2928
|
if (CHANGES_SESSION.test(name)) return { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
|
|
2907
2929
|
return { readOnlyHint: true, destructiveHint: false, openWorldHint: true };
|
|
2908
2930
|
}
|
|
2931
|
+
var TEXT_IS_RESULT = /* @__PURE__ */ new Set(["helios_docs_get_document"]);
|
|
2932
|
+
function withDataText(name, content, structuredContent) {
|
|
2933
|
+
if (TEXT_IS_RESULT.has(name)) return content;
|
|
2934
|
+
return [...content, { type: "text", text: JSON.stringify(structuredContent) }];
|
|
2935
|
+
}
|
|
2909
2936
|
function registerTool(server, tool) {
|
|
2910
2937
|
server.registerTool(
|
|
2911
2938
|
tool.name,
|
|
@@ -2918,7 +2945,7 @@ function registerTool(server, tool) {
|
|
|
2918
2945
|
async (input) => {
|
|
2919
2946
|
const result = await tool.execute(tool.inputSchema.parse(input));
|
|
2920
2947
|
return {
|
|
2921
|
-
|
|
2948
|
+
content: withDataText(tool.name, result.content, result.structuredContent),
|
|
2922
2949
|
structuredContent: result.structuredContent
|
|
2923
2950
|
};
|
|
2924
2951
|
}
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -795,7 +795,8 @@ declare class HeliosAgentMcpAuthService {
|
|
|
795
795
|
invalidateIfUnauthorized(error: unknown, options?: EnsureLoginOptions): Promise<PendingLoginResult | null>;
|
|
796
796
|
refreshSessionAfterUnauthorized(error: unknown): Promise<StoredAgentSession | null>;
|
|
797
797
|
ensureLogin(options?: EnsureLoginOptions): Promise<EnsureLoginResult>;
|
|
798
|
-
|
|
798
|
+
/** Polls the given login, or the stored pending one when no device code is given. */
|
|
799
|
+
pollLogin(deviceCode?: string): Promise<PollLoginResult>;
|
|
799
800
|
whoami(): Promise<AgentSessionView>;
|
|
800
801
|
getAccessToken(): Promise<string | null>;
|
|
801
802
|
requireSession(): Promise<StoredAgentSession>;
|
|
@@ -1041,6 +1042,18 @@ declare function toolAnnotations(name: string): {
|
|
|
1041
1042
|
destructiveHint: boolean;
|
|
1042
1043
|
openWorldHint: boolean;
|
|
1043
1044
|
};
|
|
1045
|
+
/**
|
|
1046
|
+
* The tool's text plus its data as JSON. Many AI apps (Qwen Code, Cursor, older clients) only hand the model the text
|
|
1047
|
+
* content and drop structuredContent, so without this the agent sees the one-line summary and none of the data. The
|
|
1048
|
+
* MCP spec asks servers to send the JSON as text alongside structured results for exactly this reason.
|
|
1049
|
+
*/
|
|
1050
|
+
declare function withDataText(name: string, content: Array<{
|
|
1051
|
+
type: 'text';
|
|
1052
|
+
text: string;
|
|
1053
|
+
}>, structuredContent: object): Array<{
|
|
1054
|
+
type: 'text';
|
|
1055
|
+
text: string;
|
|
1056
|
+
}>;
|
|
1044
1057
|
|
|
1045
1058
|
interface HeliosMcpToolResult<TStructuredContent extends object> {
|
|
1046
1059
|
content: Array<{
|
|
@@ -1176,10 +1189,10 @@ declare function createHeliosAuthToolDefinitions(service: HeliosAgentMcpAuthServ
|
|
|
1176
1189
|
title: string;
|
|
1177
1190
|
description: string;
|
|
1178
1191
|
inputSchema: z.ZodObject<{
|
|
1179
|
-
deviceCode: z.ZodString
|
|
1192
|
+
deviceCode: z.ZodOptional<z.ZodString>;
|
|
1180
1193
|
}, z.core.$strip>;
|
|
1181
1194
|
execute(input: {
|
|
1182
|
-
deviceCode
|
|
1195
|
+
deviceCode?: string | undefined;
|
|
1183
1196
|
}): Promise<{
|
|
1184
1197
|
content: {
|
|
1185
1198
|
type: "text";
|
|
@@ -2134,4 +2147,4 @@ declare function createHeliosTradingToolDefinitions(service: HeliosAgentMcpTradi
|
|
|
2134
2147
|
}>;
|
|
2135
2148
|
}];
|
|
2136
2149
|
|
|
2137
|
-
export { type ActiveProviderView, type AgentMcpSessionStore, type CancelOrderToolResult, type ClosePositionToolResult, type CreateHeliosAgentMcpServerOptions, type DeleteTpSlToolResult, type EnsureLoginOptions, type EnsureLoginResult, FileAgentSessionStore, type GetHeliosAgentMcpDocumentInput, HOSTED_RECONNECT_MESSAGE, HeliosAgentMcpAccountService, type HeliosAgentMcpAccountServiceOptions, HeliosAgentMcpAuthService, type HeliosAgentMcpAuthServiceOptions, type HeliosAgentMcpDocsIndex, type HeliosAgentMcpDocsIndexEntry, HeliosAgentMcpDocsService, type HeliosAgentMcpDocsServiceOptions, type HeliosAgentMcpDocument, HeliosAgentMcpLedgerService, type HeliosAgentMcpLedgerServiceOptions, HeliosAgentMcpMarketService, type HeliosAgentMcpMarketServiceOptions, HeliosAgentMcpProviderService, type HeliosAgentMcpProviderServiceOptions, HeliosAgentMcpTradingService, type HeliosAgentMcpTradingServiceOptions, type HeliosMcpToolDefinition, type HeliosMcpToolResult, type LedgerFillsResult, type LedgerSummaryResult, type MarketSnapshotChunkResult, type MarketSnapshotResult, type MarketSymbolDetailResult, MemoryAgentMcpSessionStore, type OpenOrdersToolResult, type OpenPositionsResult, type PendingAgentLogin, type PendingLoginResult, type PollLoginResult, type PortfolioResult, type SetTpSlToolResult, type StartLoginResult, type TradeIntentAction, type TradeIntentActionInput, type TradeIntentActionResult, type WalletStateResult, createHeliosAccountToolDefinitions, createHeliosAgentMcpServer, createHeliosAuthToolDefinitions, createHeliosDocsToolDefinitions, createHeliosLedgerToolDefinitions, createHeliosMarketToolDefinitions, createHeliosProviderToolDefinitions, createHeliosTradingToolDefinitions, formatHeliosLoginPrompt, getDefaultHeliosAgentMcpDocsRoot, getDefaultHeliosAgentMcpSessionPath, pendingAgentLoginSchema, retryAfterUnauthorizedRefresh, toolAnnotations };
|
|
2150
|
+
export { type ActiveProviderView, type AgentMcpSessionStore, type CancelOrderToolResult, type ClosePositionToolResult, type CreateHeliosAgentMcpServerOptions, type DeleteTpSlToolResult, type EnsureLoginOptions, type EnsureLoginResult, FileAgentSessionStore, type GetHeliosAgentMcpDocumentInput, HOSTED_RECONNECT_MESSAGE, HeliosAgentMcpAccountService, type HeliosAgentMcpAccountServiceOptions, HeliosAgentMcpAuthService, type HeliosAgentMcpAuthServiceOptions, type HeliosAgentMcpDocsIndex, type HeliosAgentMcpDocsIndexEntry, HeliosAgentMcpDocsService, type HeliosAgentMcpDocsServiceOptions, type HeliosAgentMcpDocument, HeliosAgentMcpLedgerService, type HeliosAgentMcpLedgerServiceOptions, HeliosAgentMcpMarketService, type HeliosAgentMcpMarketServiceOptions, HeliosAgentMcpProviderService, type HeliosAgentMcpProviderServiceOptions, HeliosAgentMcpTradingService, type HeliosAgentMcpTradingServiceOptions, type HeliosMcpToolDefinition, type HeliosMcpToolResult, type LedgerFillsResult, type LedgerSummaryResult, type MarketSnapshotChunkResult, type MarketSnapshotResult, type MarketSymbolDetailResult, MemoryAgentMcpSessionStore, type OpenOrdersToolResult, type OpenPositionsResult, type PendingAgentLogin, type PendingLoginResult, type PollLoginResult, type PortfolioResult, type SetTpSlToolResult, type StartLoginResult, type TradeIntentAction, type TradeIntentActionInput, type TradeIntentActionResult, type WalletStateResult, createHeliosAccountToolDefinitions, createHeliosAgentMcpServer, createHeliosAuthToolDefinitions, createHeliosDocsToolDefinitions, createHeliosLedgerToolDefinitions, createHeliosMarketToolDefinitions, createHeliosProviderToolDefinitions, createHeliosTradingToolDefinitions, formatHeliosLoginPrompt, getDefaultHeliosAgentMcpDocsRoot, getDefaultHeliosAgentMcpSessionPath, pendingAgentLoginSchema, retryAfterUnauthorizedRefresh, toolAnnotations, withDataText };
|
package/dist/index.d.ts
CHANGED
|
@@ -795,7 +795,8 @@ declare class HeliosAgentMcpAuthService {
|
|
|
795
795
|
invalidateIfUnauthorized(error: unknown, options?: EnsureLoginOptions): Promise<PendingLoginResult | null>;
|
|
796
796
|
refreshSessionAfterUnauthorized(error: unknown): Promise<StoredAgentSession | null>;
|
|
797
797
|
ensureLogin(options?: EnsureLoginOptions): Promise<EnsureLoginResult>;
|
|
798
|
-
|
|
798
|
+
/** Polls the given login, or the stored pending one when no device code is given. */
|
|
799
|
+
pollLogin(deviceCode?: string): Promise<PollLoginResult>;
|
|
799
800
|
whoami(): Promise<AgentSessionView>;
|
|
800
801
|
getAccessToken(): Promise<string | null>;
|
|
801
802
|
requireSession(): Promise<StoredAgentSession>;
|
|
@@ -1041,6 +1042,18 @@ declare function toolAnnotations(name: string): {
|
|
|
1041
1042
|
destructiveHint: boolean;
|
|
1042
1043
|
openWorldHint: boolean;
|
|
1043
1044
|
};
|
|
1045
|
+
/**
|
|
1046
|
+
* The tool's text plus its data as JSON. Many AI apps (Qwen Code, Cursor, older clients) only hand the model the text
|
|
1047
|
+
* content and drop structuredContent, so without this the agent sees the one-line summary and none of the data. The
|
|
1048
|
+
* MCP spec asks servers to send the JSON as text alongside structured results for exactly this reason.
|
|
1049
|
+
*/
|
|
1050
|
+
declare function withDataText(name: string, content: Array<{
|
|
1051
|
+
type: 'text';
|
|
1052
|
+
text: string;
|
|
1053
|
+
}>, structuredContent: object): Array<{
|
|
1054
|
+
type: 'text';
|
|
1055
|
+
text: string;
|
|
1056
|
+
}>;
|
|
1044
1057
|
|
|
1045
1058
|
interface HeliosMcpToolResult<TStructuredContent extends object> {
|
|
1046
1059
|
content: Array<{
|
|
@@ -1176,10 +1189,10 @@ declare function createHeliosAuthToolDefinitions(service: HeliosAgentMcpAuthServ
|
|
|
1176
1189
|
title: string;
|
|
1177
1190
|
description: string;
|
|
1178
1191
|
inputSchema: z.ZodObject<{
|
|
1179
|
-
deviceCode: z.ZodString
|
|
1192
|
+
deviceCode: z.ZodOptional<z.ZodString>;
|
|
1180
1193
|
}, z.core.$strip>;
|
|
1181
1194
|
execute(input: {
|
|
1182
|
-
deviceCode
|
|
1195
|
+
deviceCode?: string | undefined;
|
|
1183
1196
|
}): Promise<{
|
|
1184
1197
|
content: {
|
|
1185
1198
|
type: "text";
|
|
@@ -2134,4 +2147,4 @@ declare function createHeliosTradingToolDefinitions(service: HeliosAgentMcpTradi
|
|
|
2134
2147
|
}>;
|
|
2135
2148
|
}];
|
|
2136
2149
|
|
|
2137
|
-
export { type ActiveProviderView, type AgentMcpSessionStore, type CancelOrderToolResult, type ClosePositionToolResult, type CreateHeliosAgentMcpServerOptions, type DeleteTpSlToolResult, type EnsureLoginOptions, type EnsureLoginResult, FileAgentSessionStore, type GetHeliosAgentMcpDocumentInput, HOSTED_RECONNECT_MESSAGE, HeliosAgentMcpAccountService, type HeliosAgentMcpAccountServiceOptions, HeliosAgentMcpAuthService, type HeliosAgentMcpAuthServiceOptions, type HeliosAgentMcpDocsIndex, type HeliosAgentMcpDocsIndexEntry, HeliosAgentMcpDocsService, type HeliosAgentMcpDocsServiceOptions, type HeliosAgentMcpDocument, HeliosAgentMcpLedgerService, type HeliosAgentMcpLedgerServiceOptions, HeliosAgentMcpMarketService, type HeliosAgentMcpMarketServiceOptions, HeliosAgentMcpProviderService, type HeliosAgentMcpProviderServiceOptions, HeliosAgentMcpTradingService, type HeliosAgentMcpTradingServiceOptions, type HeliosMcpToolDefinition, type HeliosMcpToolResult, type LedgerFillsResult, type LedgerSummaryResult, type MarketSnapshotChunkResult, type MarketSnapshotResult, type MarketSymbolDetailResult, MemoryAgentMcpSessionStore, type OpenOrdersToolResult, type OpenPositionsResult, type PendingAgentLogin, type PendingLoginResult, type PollLoginResult, type PortfolioResult, type SetTpSlToolResult, type StartLoginResult, type TradeIntentAction, type TradeIntentActionInput, type TradeIntentActionResult, type WalletStateResult, createHeliosAccountToolDefinitions, createHeliosAgentMcpServer, createHeliosAuthToolDefinitions, createHeliosDocsToolDefinitions, createHeliosLedgerToolDefinitions, createHeliosMarketToolDefinitions, createHeliosProviderToolDefinitions, createHeliosTradingToolDefinitions, formatHeliosLoginPrompt, getDefaultHeliosAgentMcpDocsRoot, getDefaultHeliosAgentMcpSessionPath, pendingAgentLoginSchema, retryAfterUnauthorizedRefresh, toolAnnotations };
|
|
2150
|
+
export { type ActiveProviderView, type AgentMcpSessionStore, type CancelOrderToolResult, type ClosePositionToolResult, type CreateHeliosAgentMcpServerOptions, type DeleteTpSlToolResult, type EnsureLoginOptions, type EnsureLoginResult, FileAgentSessionStore, type GetHeliosAgentMcpDocumentInput, HOSTED_RECONNECT_MESSAGE, HeliosAgentMcpAccountService, type HeliosAgentMcpAccountServiceOptions, HeliosAgentMcpAuthService, type HeliosAgentMcpAuthServiceOptions, type HeliosAgentMcpDocsIndex, type HeliosAgentMcpDocsIndexEntry, HeliosAgentMcpDocsService, type HeliosAgentMcpDocsServiceOptions, type HeliosAgentMcpDocument, HeliosAgentMcpLedgerService, type HeliosAgentMcpLedgerServiceOptions, HeliosAgentMcpMarketService, type HeliosAgentMcpMarketServiceOptions, HeliosAgentMcpProviderService, type HeliosAgentMcpProviderServiceOptions, HeliosAgentMcpTradingService, type HeliosAgentMcpTradingServiceOptions, type HeliosMcpToolDefinition, type HeliosMcpToolResult, type LedgerFillsResult, type LedgerSummaryResult, type MarketSnapshotChunkResult, type MarketSnapshotResult, type MarketSymbolDetailResult, MemoryAgentMcpSessionStore, type OpenOrdersToolResult, type OpenPositionsResult, type PendingAgentLogin, type PendingLoginResult, type PollLoginResult, type PortfolioResult, type SetTpSlToolResult, type StartLoginResult, type TradeIntentAction, type TradeIntentActionInput, type TradeIntentActionResult, type WalletStateResult, createHeliosAccountToolDefinitions, createHeliosAgentMcpServer, createHeliosAuthToolDefinitions, createHeliosDocsToolDefinitions, createHeliosLedgerToolDefinitions, createHeliosMarketToolDefinitions, createHeliosProviderToolDefinitions, createHeliosTradingToolDefinitions, formatHeliosLoginPrompt, getDefaultHeliosAgentMcpDocsRoot, getDefaultHeliosAgentMcpSessionPath, pendingAgentLoginSchema, retryAfterUnauthorizedRefresh, toolAnnotations, withDataText };
|
package/dist/index.js
CHANGED
|
@@ -55,7 +55,8 @@ __export(index_exports, {
|
|
|
55
55
|
getDefaultHeliosAgentMcpSessionPath: () => getDefaultHeliosAgentMcpSessionPath,
|
|
56
56
|
pendingAgentLoginSchema: () => pendingAgentLoginSchema,
|
|
57
57
|
retryAfterUnauthorizedRefresh: () => retryAfterUnauthorizedRefresh,
|
|
58
|
-
toolAnnotations: () => toolAnnotations
|
|
58
|
+
toolAnnotations: () => toolAnnotations,
|
|
59
|
+
withDataText: () => withDataText
|
|
59
60
|
});
|
|
60
61
|
module.exports = __toCommonJS(index_exports);
|
|
61
62
|
|
|
@@ -954,11 +955,15 @@ var HeliosAgentMcpAuthService = class {
|
|
|
954
955
|
requestedConstraints
|
|
955
956
|
});
|
|
956
957
|
if (pendingLogin) {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
958
|
+
const polled = await this.pollLogin(pendingLogin.deviceCode).catch(() => null);
|
|
959
|
+
if (polled?.status === "connected") return polled;
|
|
960
|
+
if (polled?.status !== "rejected" && polled?.status !== "expired") {
|
|
961
|
+
return {
|
|
962
|
+
...pendingLogin,
|
|
963
|
+
connected: false,
|
|
964
|
+
message: formatHeliosLoginPrompt(pendingLogin)
|
|
965
|
+
};
|
|
966
|
+
}
|
|
962
967
|
}
|
|
963
968
|
const started = await this.startLogin({
|
|
964
969
|
clientName: options.clientName ?? "Helios MCP",
|
|
@@ -971,7 +976,24 @@ var HeliosAgentMcpAuthService = class {
|
|
|
971
976
|
message: formatHeliosLoginPrompt(started)
|
|
972
977
|
};
|
|
973
978
|
}
|
|
979
|
+
/** Polls the given login, or the stored pending one when no device code is given. */
|
|
974
980
|
async pollLogin(deviceCode) {
|
|
981
|
+
if (!deviceCode) {
|
|
982
|
+
const pending = await this.sessionStore.getPendingLogin();
|
|
983
|
+
if (!pending) {
|
|
984
|
+
const session = await this.getValidSession();
|
|
985
|
+
if (session) return { ...sanitizeAgentSession(session), connected: true, status: "connected" };
|
|
986
|
+
return {
|
|
987
|
+
status: "failed",
|
|
988
|
+
connected: false,
|
|
989
|
+
message: "No Helios login is in progress. Call helios_auth_ensure_login to start one."
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
deviceCode = pending.deviceCode;
|
|
993
|
+
} else {
|
|
994
|
+
const pending = await this.sessionStore.getPendingLogin();
|
|
995
|
+
if (pending && pending.userCode.toUpperCase() === deviceCode.trim().toUpperCase()) deviceCode = pending.deviceCode;
|
|
996
|
+
}
|
|
975
997
|
try {
|
|
976
998
|
const response = await this.client.exchangeDeviceCode(deviceCode);
|
|
977
999
|
const session = createStoredAgentSession(response, this.now());
|
|
@@ -1106,7 +1128,7 @@ User code: ${result.userCode}
|
|
|
1106
1128
|
|
|
1107
1129
|
Requested scopes: ${result.requestedScope.join(", ")}
|
|
1108
1130
|
|
|
1109
|
-
After approving access,
|
|
1131
|
+
After approving access, call helios_auth_ensure_login (or helios_auth_poll_login) again to finish connecting.`;
|
|
1110
1132
|
}
|
|
1111
1133
|
function isPendingLoginCompatible(pendingLogin, requestedScope, requestedConstraints) {
|
|
1112
1134
|
const pendingScope = new Set(pendingLogin.requestedScope);
|
|
@@ -2084,7 +2106,8 @@ function asPending2(login) {
|
|
|
2084
2106
|
// src/tools.ts
|
|
2085
2107
|
var import_zod5 = require("zod");
|
|
2086
2108
|
var pollLoginInputSchema = import_zod5.z.object({
|
|
2087
|
-
|
|
2109
|
+
/** Optional: defaults to the login started by helios_auth_ensure_login / helios_auth_start_login. */
|
|
2110
|
+
deviceCode: import_zod5.z.string().min(1).optional()
|
|
2088
2111
|
});
|
|
2089
2112
|
var startLoginOutputSchema = import_zod5.z.object({
|
|
2090
2113
|
status: import_zod5.z.literal("pending"),
|
|
@@ -2393,7 +2416,7 @@ function createHeliosAuthToolDefinitions(service) {
|
|
|
2393
2416
|
{
|
|
2394
2417
|
name: "helios_auth_ensure_login",
|
|
2395
2418
|
title: "Ensure Helios Login",
|
|
2396
|
-
description: "Ensures a delegated Helios session exists, or starts a login flow and returns a ready-to-display approval prompt.",
|
|
2419
|
+
description: "Ensures a delegated Helios session exists, or starts a login flow and returns a ready-to-display approval prompt. Call it again after the person approves: it finishes connecting.",
|
|
2397
2420
|
inputSchema: ensureLoginInputSchema,
|
|
2398
2421
|
async execute(input) {
|
|
2399
2422
|
const result = ensureLoginOutputSchema.parse(await service.ensureLogin(input));
|
|
@@ -2415,7 +2438,7 @@ function createHeliosAuthToolDefinitions(service) {
|
|
|
2415
2438
|
{
|
|
2416
2439
|
name: "helios_auth_poll_login",
|
|
2417
2440
|
title: "Poll Helios Login",
|
|
2418
|
-
description: "
|
|
2441
|
+
description: "Checks whether the Helios login was approved and finishes connecting. The device code is optional; without it, the login in progress is checked.",
|
|
2419
2442
|
inputSchema: pollLoginInputSchema,
|
|
2420
2443
|
async execute(input) {
|
|
2421
2444
|
const result = pollLoginOutputSchema.parse(await service.pollLogin(input.deviceCode));
|
|
@@ -2854,7 +2877,7 @@ function withManualLoginFields(result) {
|
|
|
2854
2877
|
return {
|
|
2855
2878
|
actionRequired: true,
|
|
2856
2879
|
loginUrl: result.verificationUriComplete,
|
|
2857
|
-
nextStep: "Open the login URL in your browser, approve Helios access, then
|
|
2880
|
+
nextStep: "Open the login URL in your browser, approve Helios access, then call helios_auth_ensure_login again to finish connecting."
|
|
2858
2881
|
};
|
|
2859
2882
|
}
|
|
2860
2883
|
function buildPortfolioText(result) {
|
|
@@ -2867,7 +2890,7 @@ ${result.verificationUriComplete}
|
|
|
2867
2890
|
|
|
2868
2891
|
User code: ${result.userCode}
|
|
2869
2892
|
|
|
2870
|
-
After approving access,
|
|
2893
|
+
After approving access, call helios_auth_ensure_login (or helios_auth_poll_login) again to finish connecting.`;
|
|
2871
2894
|
}
|
|
2872
2895
|
|
|
2873
2896
|
// src/server.ts
|
|
@@ -2881,7 +2904,7 @@ async function createHeliosAgentMcpServer(options) {
|
|
|
2881
2904
|
const { McpServer } = await import("@modelcontextprotocol/sdk/server/mcp.js");
|
|
2882
2905
|
const server = new McpServer({
|
|
2883
2906
|
name: "helios",
|
|
2884
|
-
version: "0.
|
|
2907
|
+
version: "0.2.2"
|
|
2885
2908
|
});
|
|
2886
2909
|
const sessionStore = options.sessionStore ?? new FileAgentSessionStore(options.sessionPath ?? getDefaultHeliosAgentMcpSessionPath());
|
|
2887
2910
|
const client = new HeliosAgentAuthClient({
|
|
@@ -2974,6 +2997,11 @@ function toolAnnotations(name) {
|
|
|
2974
2997
|
if (CHANGES_SESSION.test(name)) return { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
|
|
2975
2998
|
return { readOnlyHint: true, destructiveHint: false, openWorldHint: true };
|
|
2976
2999
|
}
|
|
3000
|
+
var TEXT_IS_RESULT = /* @__PURE__ */ new Set(["helios_docs_get_document"]);
|
|
3001
|
+
function withDataText(name, content, structuredContent) {
|
|
3002
|
+
if (TEXT_IS_RESULT.has(name)) return content;
|
|
3003
|
+
return [...content, { type: "text", text: JSON.stringify(structuredContent) }];
|
|
3004
|
+
}
|
|
2977
3005
|
function registerTool(server, tool) {
|
|
2978
3006
|
server.registerTool(
|
|
2979
3007
|
tool.name,
|
|
@@ -2986,7 +3014,7 @@ function registerTool(server, tool) {
|
|
|
2986
3014
|
async (input) => {
|
|
2987
3015
|
const result = await tool.execute(tool.inputSchema.parse(input));
|
|
2988
3016
|
return {
|
|
2989
|
-
|
|
3017
|
+
content: withDataText(tool.name, result.content, result.structuredContent),
|
|
2990
3018
|
structuredContent: result.structuredContent
|
|
2991
3019
|
};
|
|
2992
3020
|
}
|
|
@@ -3017,5 +3045,6 @@ function registerTool(server, tool) {
|
|
|
3017
3045
|
getDefaultHeliosAgentMcpSessionPath,
|
|
3018
3046
|
pendingAgentLoginSchema,
|
|
3019
3047
|
retryAfterUnauthorizedRefresh,
|
|
3020
|
-
toolAnnotations
|
|
3048
|
+
toolAnnotations,
|
|
3049
|
+
withDataText
|
|
3021
3050
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -22,8 +22,9 @@ import {
|
|
|
22
22
|
getDefaultHeliosAgentMcpSessionPath,
|
|
23
23
|
pendingAgentLoginSchema,
|
|
24
24
|
retryAfterUnauthorizedRefresh,
|
|
25
|
-
toolAnnotations
|
|
26
|
-
|
|
25
|
+
toolAnnotations,
|
|
26
|
+
withDataText
|
|
27
|
+
} from "./chunk-XE6HRID3.mjs";
|
|
27
28
|
export {
|
|
28
29
|
FileAgentSessionStore,
|
|
29
30
|
HOSTED_RECONNECT_MESSAGE,
|
|
@@ -48,5 +49,6 @@ export {
|
|
|
48
49
|
getDefaultHeliosAgentMcpSessionPath,
|
|
49
50
|
pendingAgentLoginSchema,
|
|
50
51
|
retryAfterUnauthorizedRefresh,
|
|
51
|
-
toolAnnotations
|
|
52
|
+
toolAnnotations,
|
|
53
|
+
withDataText
|
|
52
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgnio/helios-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Helios MCP server: connect an AI agent to your Helios account to read markets and your portfolio and to trade on Hyperliquid. Most apps can use the hosted URL https://helios.pgn.io/mcp instead.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://helios.pgn.io/?connect=ai",
|