eve-online-mcp 0.3.2 → 0.5.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.
Files changed (50) hide show
  1. package/README.md +84 -3
  2. package/dist/auth.d.ts +31 -9
  3. package/dist/auth.js +142 -28
  4. package/dist/auth.js.map +1 -1
  5. package/dist/character-authentication.d.ts +38 -0
  6. package/dist/character-authentication.js +35 -0
  7. package/dist/character-authentication.js.map +1 -0
  8. package/dist/character-context.js +1 -1
  9. package/dist/character-context.js.map +1 -1
  10. package/dist/cli.js +10 -6
  11. package/dist/cli.js.map +1 -1
  12. package/dist/credential-store.d.ts +48 -9
  13. package/dist/credential-store.js +160 -37
  14. package/dist/credential-store.js.map +1 -1
  15. package/dist/esi-client.d.ts +2 -2
  16. package/dist/esi-client.js +65 -16
  17. package/dist/esi-client.js.map +1 -1
  18. package/dist/index.js +18 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/package-metadata.d.ts +1 -0
  21. package/dist/package-metadata.js +1 -0
  22. package/dist/package-metadata.js.map +1 -1
  23. package/dist/server.d.ts +3 -1
  24. package/dist/server.js +196 -17
  25. package/dist/server.js.map +1 -1
  26. package/dist/skill-data.d.ts +143 -0
  27. package/dist/skill-data.js +183 -0
  28. package/dist/skill-data.js.map +1 -0
  29. package/dist/skill-graph.d.ts +21 -0
  30. package/dist/skill-graph.js +97 -0
  31. package/dist/skill-graph.js.map +1 -0
  32. package/dist/skill-plan-guidance.d.ts +18 -0
  33. package/dist/skill-plan-guidance.js +43 -0
  34. package/dist/skill-plan-guidance.js.map +1 -0
  35. package/dist/skill-plan.d.ts +395 -0
  36. package/dist/skill-plan.js +207 -0
  37. package/dist/skill-plan.js.map +1 -0
  38. package/dist/sso.d.ts +5 -0
  39. package/dist/sso.js +20 -5
  40. package/dist/sso.js.map +1 -1
  41. package/dist/static-data-archive.d.ts +4 -0
  42. package/dist/static-data-archive.js +139 -0
  43. package/dist/static-data-archive.js.map +1 -0
  44. package/dist/static-data.d.ts +43 -0
  45. package/dist/static-data.js +253 -0
  46. package/dist/static-data.js.map +1 -0
  47. package/dist/token-identity.d.ts +9 -0
  48. package/dist/token-identity.js +65 -0
  49. package/dist/token-identity.js.map +1 -0
  50. package/package.json +7 -3
package/README.md CHANGED
@@ -6,14 +6,21 @@ The server is generated at runtime from a pinned copy of CCP's OpenAPI 3.1 docum
6
6
 
7
7
  ## What the MCP server exposes
8
8
 
9
+ - `list_eve_characters` lists saved character IDs, names, and granted scopes without exposing credentials.
10
+ - `authorize_eve_character` opens browser consent for a specific character, verifies the selected identity, and stores that character's refresh credential. `select_eve_character` chooses a saved character for protected operations that do not name one. These tools manage local authentication only; they never change game state.
9
11
  - `search_esi_operations` ranks endpoints using deterministic lexical and curated intent matching, supports hard tag/authentication filters and offsets, and explains every match.
10
12
  - `get_esi_operation` returns exact parameters, request-body schema, required caller inputs, defaults, pagination guidance, OAuth scopes, cache hints, safe examples where available, and rate-limit metadata.
11
13
  - `call_esi` invokes one page of one catalogued read operation. It rejects undeclared parameters, validates values, fixes the origin to ESI, supplies compatibility headers, and never accepts an Authorization header from a tool call.
12
14
  - `resolve_eve_entities` performs one exact-only public batch lookup from names to every matching ID/category, or from IDs to names/categories. Ambiguous and unresolved values remain explicit.
13
15
  - `get_character_context` retrieves only the requested `profile`, `location`, `ship`, `skills`, `skillQueue`, and/or `wallet` sections for an explicit character ID, with per-section data, freshness, and errors.
14
16
  - `get_market_snapshot` collects bounded pages of public regional orders for one type, optionally filters one exact location, and returns observed aggregates with honest completeness warnings.
17
+ - `initialize_static_data` downloads and validates CCP's official static data into a local cache, reports its build/freshness, and checks for updates on request. Startup also initializes in the background.
18
+ - `resolve_skill_plan_targets` resolves exact skill/ship names or type IDs against the cache, including explicit skill levels and unique singular skill names. Ambiguous or unresolved inputs return candidates.
19
+ - `get_skill_dependencies` returns a public prerequisite graph with skill-level nodes and prerequisite-to-dependent edges, without login.
20
+ - `generate_skill_plan` computes a personalized, dependency-checked plan from cached requirements and scoped character skills/queue, removes completed levels, and returns training text and estimated remaining SP.
15
21
  - `eve-esi://catalog` describes pinned API coverage, excluded operation count, and guidance for the generic and focused workflows.
16
22
  - `plan_eve_adventure` is a prompt for evidence-based recommendations with costs, preparation, risk, travel, and a concrete first action. Its optional activity playbooks cover exploration, factional warfare, mining, industry, trading, hauling, agent missions, PvE, and PvP.
23
+ - `plan_eve_skills` interprets activity/class goals, resolves material choices, and calls the deterministic planning tools. It explains practical support, optional upgrades and eligibility limits.
17
24
 
18
25
  ESI cache headers are respected in memory, protected cache entries are isolated by credential context, and every response reports fetch/serve/expiry timestamps plus defensive page metadata. Errors include stable codes, retryability, Retry-After guidance, and a suggested action. Individual responses and bounded composite workflows use 5 MB safety ceilings. A descriptive User-Agent is sent as [recommended by ESI](https://developers.eveonline.com/docs/services/esi/best-practices/); it is derived from the installed package version and has the form `eve-online-mcp/<version> (adam@hammo.dev; +https://github.com/HammoTime/eve-online-mcp)`.
19
26
 
@@ -54,16 +61,41 @@ Once published, configure your MCP host to run the npm package directly:
54
61
 
55
62
  For a local checkout, build in the devcontainer and use `node /absolute/path/to/eve-online-mcp/dist/index.js` instead.
56
63
 
64
+ During MCP initialization, the server reports the version from its installed `package.json`, so MCP host diagnostics identify the running package release.
65
+
66
+ ### Discovery in Codex and other MCP hosts
67
+
68
+ Installing the npm package makes the executable available; the MCP host must also be configured to launch it. For [Codex](https://learn.chatgpt.com/docs/extend/mcp?surface=cli), register the stdio server with:
69
+
70
+ ```sh
71
+ codex mcp add eve-online -- npx -y eve-online-mcp
72
+ codex mcp list
73
+ ```
74
+
75
+ The server advertises EVE Online use cases in every tool's title and description, and returns workflow guidance in the MCP initialization `instructions` field. This lets hosts recognize character sheets, skills, skill queues, markets and other ESI data requests before a prompt or catalog resource is opened. Codex reads these instructions; other hosts may handle them differently. Tool selection remains the host's decision.
76
+
77
+ For a named character's training plan, use `resolve_eve_entities` to select the character-category ID, `resolve_skill_plan_targets` to verify goals, then `generate_skill_plan` with that explicit character ID. The planner retrieves skills and queue itself. `get_character_context` remains available for character inspection, and other ESI questions use `search_esi_operations`, `get_esi_operation`, then `call_esi`. Public discovery needs no login; protected data uses EVE SSO. ESI does not expose Omega subscription status or saved in-game skill plans, and skill injector recommendations require current game rules and explicit assumptions in addition to character data.
78
+
79
+ To check discovery after updating the configured server, reconnect it or start a fresh host session and confirm that its tool list contains EVE Online tool titles. Try a request such as: "Use EVE Online data to review the character sheet, skills and skill queue for <exact character name>, and suggest a hauling training plan." The host should discover the EVE tools and resolve the name before retrieving the needed sections. Inspect the tool-call trace to verify that it uses MCP for ESI-covered data before inspecting the game client. This is a manual host check; the automated tests verify initialization metadata and tool listings, not model selection behavior.
80
+
81
+ If the host still overlooks the server, capture the exact prompt, host/model version, configured server command and arguments, initialization instructions, tool listing and relevant tool-call sequence. Exclude credentials, tokens and private character responses from a shared report. This distinguishes a connection or stale-metadata problem from a host tool-selection problem.
82
+
57
83
  ### EVE SSO
58
84
 
59
- Public ESI routes need no credentials and never trigger login. On the first operation that needs character or corporation data, the server automatically opens EVE SSO in the browser. After consent it stores only the refresh credential in the user's OS configuration directory, rotates it when EVE returns a replacement, and manages short-lived access tokens in memory. No client secret or manual token handling is required.
85
+ Public ESI routes need no credentials and never trigger login. Ask Codex for a character's protected data: when that character has no saved authorization, the server automatically opens EVE SSO in the browser. Select the requested character and approve access; the server verifies the identity, saves its separate refresh credential, and continues the request. Repeat for another character on the same or a different EVE account. Previously authorized characters remain available. No commands, client secret, or manual token handling are required.
86
+
87
+ Credentials are stored per character, not per EVE account. Both `call_esi` and `get_character_context` select the credential matching the requested `character_id`/`characterId`. A wrong-character browser selection saves nothing and reports the requested and selected IDs. Tokens with a different or unreadable character subject are rejected before making a protected character request. A remaining upstream 403 identifies the character and required scopes; ownership or corporation roles can still deny access even with the correct character.
88
+
89
+ Codex can inspect saved authorizations using `list_eve_characters` and renew consent using `authorize_eve_character` when scopes are missing or a grant has expired or been revoked. For corporation, fleet, or structure operations without a character path parameter, a sole saved character is used automatically. With multiple saved characters and no default, the server asks Codex to use `select_eve_character` for the intended character. This default never overrides a character-specific request. Login dialogs are serialized, and simultaneous requests for the same missing character share a successful login.
90
+
91
+ The versioned credential file lives in the user's OS configuration directory. Each entry stores a character ID/name, client ID, granted scopes, creation time, and refresh token. Access tokens stay in memory. Login and refresh validate EVE's signature, issuer, audiences, expiration, and character claims. Refresh-token rotation updates only the matching character; writes use a restricted-permission temporary file, atomic replacement, and locks to coordinate concurrent processes. Running servers reread the store to notice new consent or removal. Old single-credential files migrate on their next protected use after the character identity is verified; adding a new character before migration preserves the legacy credential.
60
92
 
61
93
  The package ships with this public PKCE client configuration:
62
94
 
63
95
  - Client ID: `6a65f1e650d240659dafbad29fb55e05`
64
96
  - Callback URL: `http://localhost:52765/callback`
65
97
 
66
- The callback must match the EVE application registration exactly. PKCE is intended for local applications that cannot keep a client secret, so never distribute or commit the client secret. The login can also be started or managed explicitly:
98
+ The callback must match the EVE application registration exactly. PKCE is intended for local applications that cannot keep a client secret, so never distribute or commit the client secret. Optional maintenance commands are available, but are not needed for the Codex workflow. `auth logout` removes all local character credentials:
67
99
 
68
100
  ```sh
69
101
  npx eve-online-mcp auth login
@@ -136,7 +168,7 @@ esi-wallet.read_corporation_wallets.v1
136
168
 
137
169
  </details>
138
170
 
139
- `EVE_ACCESS_TOKEN`, `EVE_REFRESH_TOKEN`, `EVE_CLIENT_ID`, and `EVE_CLIENT_SECRET` remain supported as non-default overrides for automation or existing credentials. The server reports missing JWT scopes before spending an ESI request.
171
+ `EVE_ACCESS_TOKEN`, `EVE_REFRESH_TOKEN`, `EVE_CLIENT_ID`, and `EVE_CLIENT_SECRET` remain supported as non-default overrides for automation or existing credentials. An environment token override represents one character and takes precedence over the local store; browser authorization tools are unavailable in that mode. Character requests still check the token subject and required scopes before spending an ESI request. Remove the token override to use automatic multi-character login.
140
172
 
141
173
  Optional settings:
142
174
 
@@ -148,11 +180,60 @@ Optional settings:
148
180
  | `EVE_CREDENTIALS_PATH` | Overrides the OS credential file location |
149
181
  | `EVE_DISABLE_AUTO_SSO` | Set to `1` to prevent browser login on protected calls |
150
182
  | `EVE_SSO_REDIRECT_URI` | Overrides the localhost callback for a custom application |
183
+ | `EVE_SDE_CACHE_DIR` | Overrides the local CCP static-data cache directory |
151
184
 
152
185
  Do not commit tokens or client secrets. Tool responses never include the token, and callers cannot override the ESI origin or inject arbitrary headers.
153
186
 
154
187
  ## Suggested usage
155
188
 
189
+ ### Character skill training plans
190
+
191
+ The executable planner supports published skills and ship hulls from CCP's [official JSONL SDE](https://developers.eveonline.com/docs/services/static-data/). On first startup it downloads the archive in the background; planning waits for initialization. The archive is roughly 95 MB at the verified build and can change in size. The cache retains the ZIP and a compact, validated skill/ship index. No character snapshots or credentials are written to this cache.
192
+
193
+ Defaults are `%LOCALAPPDATA%\eve-online-mcp\sde` on Windows, `~/Library/Caches/eve-online-mcp/sde` on macOS, and `$XDG_CACHE_HOME/eve-online-mcp/sde` or `~/.cache/eve-online-mcp/sde` on Linux. Set `EVE_SDE_CACHE_DIR` in the MCP server environment for a different location. In a container this is a container path: mount a persistent volume there to retain data between runs.
194
+
195
+ Each initialization checks CCP's latest-build manifest when the last successful check is at least five minutes old; `initialize_static_data` with `{"refresh":true}` checks immediately. Conditional ETag requests avoid unchanged downloads. Cache publication is atomic and the index has a SHA-256 integrity check. A failed refresh returns the last validated build with a stale warning. A missing/corrupt cache plus download failure prevents planning rather than supplying empty requirements. Downloads use fixed CCP URLs, bounded streaming and selected ZIP entries, without extracting archive paths.
196
+
197
+ Example MCP tool arguments (replace `42` with the intended, verified character ID):
198
+
199
+ ```text
200
+ initialize_static_data {}
201
+ resolve_skill_plan_targets {"target":"exhumer"}
202
+ get_skill_dependencies {"target":"Hulk"}
203
+ generate_skill_plan {"characterId":42,"target":"Mining II"}
204
+ generate_skill_plan {"characterId":42,"target":"exhumer"}
205
+ generate_skill_plan {"characterId":42,"targets":[{"typeId":3386,"level":2},"Hulk"],"queuePolicy":"reorder"}
206
+ ```
207
+
208
+ `target` and `targets` are mutually exclusive; at most 50 targets are accepted. Names match case-insensitively, with surrounding whitespace removed. Skills accept Roman or numeric levels I–V / 1–5. A bare skill defaults to I, so `exhumer` resolves to **Exhumers I**, not a guessed Hulk fit. Exact ship names produce minimum hull requirements; training the class skill alone does not establish that every hull can be flown. Partial names return suggestions without selecting one. Modules, rigs and complete fitting plans are outside the engine's scope.
209
+
210
+ The graph uses `(skillId, level)` nodes, all six dogma prerequisite slots, and preceding-level edges. An iterative dependency traversal deduplicates shared nodes, then Kahn's topological sort orders them in **O(V + E)** time and memory for the expanded graph. A separate replay checks every step against the source requirements. Cycles and missing prerequisite metadata fail closed. Already satisfied permanent levels prune completed branches; requesting another level checks current requirements.
211
+
212
+ `generate_skill_plan` requires both `esi-skills.read_skills.v1` and `esi-skills.read_skillqueue.v1` for the chosen character, checked together before either ESI request. It validates complete skills and queue snapshots, credits partial SP once, and distinguishes trained levels from active restrictions. `queuePolicy=preserve` (default) keeps the observed queue and returns **additions after that queue**, using a conditional projected baseline. `reorder` returns a proposed replacement that includes unrelated queued commitments. Future queue rows never become observed completion; contradictory past completion requires refreshed evidence. Neither policy edits the live queue.
213
+
214
+ Results contain resolved targets, SDE build/freshness, character source timestamps, retained queue, ordered `plan`, graph edges, estimated missing SP, acquisition checks, and copyable `trainingText`. An empty plan means no additional levels under its declared baseline. Estimates do not establish Alpha/Omega eligibility, fit validity, budget, training duration, or optimal milestone timing. Formula rounding may differ by one SP; source caveats are returned with the result. Review the in-game import preview and available queue slots before applying text.
215
+
216
+ #### Natural-language goals
217
+
218
+ Select the `plan_eve_skills` MCP prompt in your host. It requires `character` (an exact character name or ID, as a string) and `goal` (a role, hull/fit, doctrine, or target skill list). Optional `constraints` captures the time horizon, Alpha/Omega state, budget, and preferences. Optional `queuePolicy` is `preserve` by default, or `reorder` to request a proposed new order while retaining unrelated commitments.
219
+
220
+ Example prompt arguments:
221
+
222
+ ```json
223
+ {
224
+ "character": "Exact Character Name",
225
+ "goal": "Build a practical hauling training plan with an early usable milestone",
226
+ "constraints": "Omega; prioritize the first two weeks; no remap or paid skill points",
227
+ "queuePolicy": "preserve"
228
+ }
229
+ ```
230
+
231
+ The prompt handles requests such as "I want to fly Jump Freighters" by distinguishing the class skill from a specific racial hull and asking for a material choice when needed. It verifies selected targets and calls `generate_skill_plan` for dependencies, progress subtraction, ordering and SP estimates. It separates mandatory hull unlocks, practical support and discretionary upgrades, labels eligibility and timing gaps, and preserves the tool's training text unchanged. The model does not reconstruct the dependency graph or perform a second calculation.
232
+
233
+ Fetching the prompt does not fetch private data or trigger SSO. The host model subsequently uses the read-only tools. The prompt cannot change a queue, save an in-game plan, purchase/inject skills, or allocate SP. Goal interpretation and discretionary recommendations still depend on the host model; dependency expansion and personalized plan computation execute in tested code. See the [research, algorithm rationale and review scenarios](docs/skill-plan-research.md) for provenance and limits.
234
+
235
+ ### Adventure planning
236
+
156
237
  Select the `plan_eve_adventure` prompt in your MCP host, or ask something like:
157
238
 
158
239
  > Using my current location, skills, wallet, assets, and the nearby market, give me three two-hour exploration plans. Explain risk and startup cost, then recommend the best first step.
package/dist/auth.d.ts CHANGED
@@ -1,8 +1,22 @@
1
1
  import { CredentialStore } from "./credential-store.js";
2
2
  import { type SsoLoginOptions } from "./sso.js";
3
+ import { type TokenVerifier } from "./token-identity.js";
3
4
  export declare const DEFAULT_EVE_CLIENT_ID = "6a65f1e650d240659dafbad29fb55e05";
4
5
  export interface TokenProvider {
5
- getAccessToken(requiredScopes?: string[]): Promise<string | undefined>;
6
+ getAccessToken(requiredScopes?: string[], characterId?: number): Promise<string | undefined>;
7
+ }
8
+ export declare class AuthenticationError extends Error {
9
+ readonly code: "CHARACTER_MISMATCH" | "CHARACTER_SELECTION_REQUIRED" | "MISSING_SCOPES";
10
+ readonly details: {
11
+ characterId?: number;
12
+ authenticatedCharacterId?: number;
13
+ missingScopes?: string[];
14
+ };
15
+ constructor(message: string, code: "CHARACTER_MISMATCH" | "CHARACTER_SELECTION_REQUIRED" | "MISSING_SCOPES", details?: {
16
+ characterId?: number;
17
+ authenticatedCharacterId?: number;
18
+ missingScopes?: string[];
19
+ });
6
20
  }
7
21
  export declare class StaticTokenProvider implements TokenProvider {
8
22
  private readonly token;
@@ -14,27 +28,35 @@ export declare class RefreshTokenProvider implements TokenProvider {
14
28
  private readonly clientSecret;
15
29
  private readonly fetchImplementation;
16
30
  private readonly onRefreshToken?;
31
+ private readonly verifyAccessToken?;
17
32
  private cached?;
18
33
  private currentRefreshToken;
19
- constructor(clientId: string, refreshToken: string, clientSecret: string | undefined, fetchImplementation?: typeof fetch, onRefreshToken?: ((refreshToken: string) => Promise<void>) | undefined);
34
+ private pending;
35
+ constructor(clientId: string, refreshToken: string, clientSecret: string | undefined, fetchImplementation?: typeof fetch, onRefreshToken?: ((refreshToken: string) => Promise<void> | void) | undefined, verifyAccessToken?: ((token: string) => Promise<void>) | undefined);
20
36
  getAccessToken(): Promise<string>;
37
+ private refresh;
21
38
  }
22
39
  export declare class StoredCredentialTokenProvider implements TokenProvider {
23
40
  private readonly store;
24
41
  private readonly fetchImplementation;
25
- private provider?;
26
- constructor(store: CredentialStore, fetchImplementation?: typeof fetch);
27
- getAccessToken(): Promise<string | undefined>;
42
+ private readonly verify;
43
+ private readonly providers;
44
+ constructor(store: CredentialStore, fetchImplementation?: typeof fetch, verify?: TokenVerifier);
45
+ getAccessToken(requiredScopes?: string[], characterId?: number): Promise<string | undefined>;
28
46
  }
29
47
  export declare class InteractiveSsoTokenProvider implements TokenProvider {
30
- private readonly store;
48
+ readonly store: CredentialStore;
31
49
  private readonly clientId;
32
50
  private readonly scopes;
33
51
  private readonly loginImplementation;
52
+ private readonly redirectUri?;
34
53
  private readonly storedProvider;
35
- private loginPromise?;
36
- constructor(store: CredentialStore, clientId: string, scopes: string[], fetchImplementation?: typeof fetch, loginImplementation?: (options: SsoLoginOptions) => Promise<unknown>);
37
- getAccessToken(): Promise<string>;
54
+ private loginTail;
55
+ constructor(store: CredentialStore, clientId: string, scopes: string[], fetchImplementation?: typeof fetch, loginImplementation?: (options: SsoLoginOptions) => Promise<unknown>, verify?: TokenVerifier, redirectUri?: string | undefined);
56
+ getAccessToken(requiredScopes?: string[], characterId?: number): Promise<string>;
57
+ authorizeCharacter(characterId: number): Promise<void>;
58
+ private login;
59
+ private enqueueLogin;
38
60
  }
39
61
  export declare function tokenProviderFromEnvironment(environment?: NodeJS.ProcessEnv, fetchImplementation?: typeof fetch, options?: {
40
62
  clientId?: string;
package/dist/auth.js CHANGED
@@ -1,6 +1,16 @@
1
1
  import { CredentialStore, defaultCredentialPath, } from "./credential-store.js";
2
2
  import { loginWithEveSso } from "./sso.js";
3
+ import { createTokenVerifier, } from "./token-identity.js";
3
4
  export const DEFAULT_EVE_CLIENT_ID = "6a65f1e650d240659dafbad29fb55e05";
5
+ export class AuthenticationError extends Error {
6
+ code;
7
+ details;
8
+ constructor(message, code, details = {}) {
9
+ super(message);
10
+ this.code = code;
11
+ this.details = details;
12
+ }
13
+ }
4
14
  export class StaticTokenProvider {
5
15
  token;
6
16
  constructor(token) {
@@ -15,18 +25,27 @@ export class RefreshTokenProvider {
15
25
  clientSecret;
16
26
  fetchImplementation;
17
27
  onRefreshToken;
28
+ verifyAccessToken;
18
29
  cached;
19
30
  currentRefreshToken;
20
- constructor(clientId, refreshToken, clientSecret, fetchImplementation = fetch, onRefreshToken) {
31
+ pending;
32
+ constructor(clientId, refreshToken, clientSecret, fetchImplementation = fetch, onRefreshToken, verifyAccessToken) {
21
33
  this.clientId = clientId;
22
34
  this.clientSecret = clientSecret;
23
35
  this.fetchImplementation = fetchImplementation;
24
36
  this.onRefreshToken = onRefreshToken;
37
+ this.verifyAccessToken = verifyAccessToken;
25
38
  this.currentRefreshToken = refreshToken;
26
39
  }
27
40
  async getAccessToken() {
28
41
  if (this.cached && this.cached.expiresAt > Date.now() + 60_000)
29
42
  return this.cached.token;
43
+ this.pending ??= this.refresh().finally(() => {
44
+ this.pending = undefined;
45
+ });
46
+ return this.pending;
47
+ }
48
+ async refresh() {
30
49
  const body = new URLSearchParams({
31
50
  grant_type: "refresh_token",
32
51
  refresh_token: this.currentRefreshToken,
@@ -48,12 +67,18 @@ export class RefreshTokenProvider {
48
67
  if (!response.ok)
49
68
  throw new Error(`EVE SSO token refresh failed with HTTP ${response.status}`);
50
69
  const value = (await response.json());
51
- if (!value.access_token || !Number.isFinite(value.expires_in))
70
+ if (typeof value.access_token !== "string" ||
71
+ !value.access_token ||
72
+ !Number.isFinite(value.expires_in) ||
73
+ value.expires_in <= 0 ||
74
+ (value.refresh_token !== undefined &&
75
+ (typeof value.refresh_token !== "string" || !value.refresh_token)))
52
76
  throw new Error("EVE SSO returned an invalid token response");
77
+ await this.verifyAccessToken?.(value.access_token);
53
78
  if (value.refresh_token &&
54
79
  value.refresh_token !== this.currentRefreshToken) {
55
- this.currentRefreshToken = value.refresh_token;
56
80
  await this.onRefreshToken?.(value.refresh_token);
81
+ this.currentRefreshToken = value.refresh_token;
57
82
  }
58
83
  this.cached = {
59
84
  token: value.access_token,
@@ -65,22 +90,83 @@ export class RefreshTokenProvider {
65
90
  export class StoredCredentialTokenProvider {
66
91
  store;
67
92
  fetchImplementation;
68
- provider;
69
- constructor(store, fetchImplementation = fetch) {
93
+ verify;
94
+ providers = new Map();
95
+ constructor(store, fetchImplementation = fetch, verify = createTokenVerifier(fetchImplementation)) {
70
96
  this.store = store;
71
97
  this.fetchImplementation = fetchImplementation;
98
+ this.verify = verify;
72
99
  }
73
- async getAccessToken() {
74
- if (!this.provider) {
75
- const credential = await this.store.read();
76
- if (!credential)
77
- return undefined;
78
- this.provider = new RefreshTokenProvider(credential.clientId, credential.refreshToken, undefined, this.fetchImplementation, async (refreshToken) => {
79
- const updated = { ...credential, refreshToken };
80
- await this.store.write(updated);
100
+ async getAccessToken(requiredScopes = [], characterId) {
101
+ let file = await this.store.read();
102
+ if (file.legacyCredential &&
103
+ (characterId === undefined ||
104
+ !file.characters.some((entry) => entry.characterId === characterId))) {
105
+ await this.store.withRefreshLock("legacy", async () => {
106
+ const legacy = (await this.store.read()).legacyCredential;
107
+ if (!legacy)
108
+ return;
109
+ let identity;
110
+ let refreshToken = legacy.refreshToken;
111
+ const provider = new RefreshTokenProvider(legacy.clientId, refreshToken, undefined, this.fetchImplementation, (replacement) => {
112
+ refreshToken = replacement;
113
+ }, async (token) => {
114
+ identity = await this.verify(token, legacy.clientId);
115
+ });
116
+ await provider.getAccessToken();
117
+ if (!identity)
118
+ throw new Error("EVE SSO did not return a verified character identity.");
119
+ await this.store.migrateLegacy(legacy, {
120
+ ...legacy,
121
+ ...identity,
122
+ refreshToken,
123
+ });
81
124
  });
125
+ file = await this.store.read();
126
+ }
127
+ const characters = file.characters;
128
+ const selected = characterId ??
129
+ file.defaultCharacterId ??
130
+ (characters.length === 1 ? characters[0]?.characterId : undefined);
131
+ if (selected === undefined) {
132
+ if (characters.length > 1)
133
+ throw new AuthenticationError("Choose an authorized character for this protected operation using select_eve_character.", "CHARACTER_SELECTION_REQUIRED");
134
+ return undefined;
82
135
  }
83
- return this.provider.getAccessToken();
136
+ return this.store.withRefreshLock(selected, async () => {
137
+ const credential = (await this.store.read()).characters.find((entry) => entry.characterId === selected);
138
+ if (!credential) {
139
+ this.providers.delete(selected);
140
+ return undefined;
141
+ }
142
+ const missingScopes = requiredScopes.filter((scope) => !credential.scopes.includes(scope));
143
+ if (missingScopes.length)
144
+ throw new AuthenticationError(`Character ${selected} lacks required scopes; use authorize_eve_character to grant access.`, "MISSING_SCOPES", { characterId: selected, missingScopes });
145
+ let cached = this.providers.get(selected);
146
+ if (cached?.credential.refreshToken !== credential.refreshToken ||
147
+ cached.credential.clientId !== credential.clientId ||
148
+ cached.credential.createdAt !== credential.createdAt ||
149
+ JSON.stringify(cached.credential.scopes) !==
150
+ JSON.stringify(credential.scopes)) {
151
+ const entry = {
152
+ credential,
153
+ provider: new RefreshTokenProvider(credential.clientId, credential.refreshToken, undefined, this.fetchImplementation, async (refreshToken) => {
154
+ await this.store.rotate(entry.credential, refreshToken);
155
+ entry.credential = { ...entry.credential, refreshToken };
156
+ }, async (token) => {
157
+ const identity = await this.verify(token, credential.clientId);
158
+ if (identity.characterId !== selected)
159
+ throw new AuthenticationError(`The saved credential for character ${selected} authenticated character ${identity.characterId}; authorize the requested character again.`, "CHARACTER_MISMATCH", {
160
+ characterId: selected,
161
+ authenticatedCharacterId: identity.characterId,
162
+ });
163
+ }),
164
+ };
165
+ cached = entry;
166
+ this.providers.set(selected, cached);
167
+ }
168
+ return cached.provider.getAccessToken();
169
+ });
84
170
  }
85
171
  }
86
172
  export class InteractiveSsoTokenProvider {
@@ -88,40 +174,68 @@ export class InteractiveSsoTokenProvider {
88
174
  clientId;
89
175
  scopes;
90
176
  loginImplementation;
177
+ redirectUri;
91
178
  storedProvider;
92
- loginPromise;
93
- constructor(store, clientId, scopes, fetchImplementation = fetch, loginImplementation = loginWithEveSso) {
179
+ loginTail = Promise.resolve();
180
+ constructor(store, clientId, scopes, fetchImplementation = fetch, loginImplementation = loginWithEveSso, verify = createTokenVerifier(fetchImplementation), redirectUri) {
94
181
  this.store = store;
95
182
  this.clientId = clientId;
96
183
  this.scopes = scopes;
97
184
  this.loginImplementation = loginImplementation;
98
- this.storedProvider = new StoredCredentialTokenProvider(store, fetchImplementation);
185
+ this.redirectUri = redirectUri;
186
+ this.storedProvider = new StoredCredentialTokenProvider(store, fetchImplementation, verify);
99
187
  }
100
- async getAccessToken() {
101
- const existing = await this.storedProvider.getAccessToken();
188
+ async getAccessToken(requiredScopes = [], characterId) {
189
+ const existing = await this.storedProvider.getAccessToken(requiredScopes, characterId);
102
190
  if (existing)
103
191
  return existing;
104
- this.loginPromise ??= this.loginImplementation({
105
- clientId: this.clientId,
106
- scopes: this.scopes,
107
- store: this.store,
108
- }).then(() => undefined);
109
- await this.loginPromise;
110
- const token = await this.storedProvider.getAccessToken();
192
+ await this.enqueueLogin(async () => {
193
+ if (await this.storedProvider.getAccessToken(requiredScopes, characterId))
194
+ return;
195
+ await this.login(characterId);
196
+ });
197
+ const token = await this.storedProvider.getAccessToken(requiredScopes, characterId);
111
198
  if (!token)
112
199
  throw new Error("EVE SSO completed without storing a credential");
113
200
  return token;
114
201
  }
202
+ async authorizeCharacter(characterId) {
203
+ await this.enqueueLogin(async () => {
204
+ await this.login(characterId);
205
+ });
206
+ }
207
+ async login(characterId) {
208
+ await this.loginImplementation({
209
+ clientId: this.clientId,
210
+ scopes: this.scopes,
211
+ store: this.store,
212
+ ...(characterId === undefined
213
+ ? {}
214
+ : { expectedCharacterId: characterId }),
215
+ ...(this.redirectUri === undefined
216
+ ? {}
217
+ : { redirectUri: this.redirectUri }),
218
+ });
219
+ }
220
+ async enqueueLogin(action) {
221
+ const pending = this.loginTail.then(action);
222
+ this.loginTail = pending.catch(() => undefined);
223
+ await pending;
224
+ }
115
225
  }
116
226
  export function tokenProviderFromEnvironment(environment = process.env, fetchImplementation = fetch, options = {}) {
117
227
  if (environment.EVE_ACCESS_TOKEN)
118
228
  return new StaticTokenProvider(environment.EVE_ACCESS_TOKEN);
119
229
  if (environment.EVE_CLIENT_ID && environment.EVE_REFRESH_TOKEN) {
120
- return new RefreshTokenProvider(environment.EVE_CLIENT_ID, environment.EVE_REFRESH_TOKEN, environment.EVE_CLIENT_SECRET, fetchImplementation);
230
+ const clientId = environment.EVE_CLIENT_ID;
231
+ const verify = createTokenVerifier(fetchImplementation);
232
+ return new RefreshTokenProvider(environment.EVE_CLIENT_ID, environment.EVE_REFRESH_TOKEN, environment.EVE_CLIENT_SECRET, fetchImplementation, undefined, async (token) => {
233
+ await verify(token, clientId);
234
+ });
121
235
  }
122
236
  const store = new CredentialStore(defaultCredentialPath(environment));
123
237
  if (options.interactive !== false && options.scopes?.length) {
124
- return new InteractiveSsoTokenProvider(store, environment.EVE_CLIENT_ID ?? options.clientId ?? DEFAULT_EVE_CLIENT_ID, options.scopes, fetchImplementation);
238
+ return new InteractiveSsoTokenProvider(store, environment.EVE_CLIENT_ID ?? options.clientId ?? DEFAULT_EVE_CLIENT_ID, options.scopes, fetchImplementation, loginWithEveSso, createTokenVerifier(fetchImplementation), environment.EVE_SSO_REDIRECT_URI);
125
239
  }
126
240
  return new StoredCredentialTokenProvider(store, fetchImplementation);
127
241
  }
package/dist/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAwB,MAAM,UAAU,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,kCAAkC,CAAC;AAMxE,MAAM,OAAO,mBAAmB;IACD;IAA7B,YAA6B,KAAyB;QAAzB,UAAK,GAAL,KAAK,CAAoB;IAAG,CAAC;IAE1D,cAAc;QACZ,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AAQD,MAAM,OAAO,oBAAoB;IAKZ;IAEA;IACA;IACA;IARX,MAAM,CAAwC;IAC9C,mBAAmB,CAAS;IAEpC,YACmB,QAAgB,EACjC,YAAoB,EACH,YAAgC,EAChC,sBAAoC,KAAK,EACzC,cAAwD;QAJxD,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,iBAAY,GAAZ,YAAY,CAAoB;QAChC,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,mBAAc,GAAd,cAAc,CAA0C;QAEzE,IAAI,CAAC,mBAAmB,GAAG,YAAY,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM;YAC5D,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAE3B,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC;YAC/B,UAAU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AC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAClE,CAAC;QACF,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { InteractiveSsoTokenProvider } from "./auth.js";
2
+ import type { CredentialStore } from "./credential-store.js";
3
+ /** Only non-secret character metadata crosses the MCP boundary. */
4
+ export declare class CharacterAuthentication {
5
+ private readonly store;
6
+ private readonly interactive?;
7
+ constructor(store: CredentialStore, interactive?: InteractiveSsoTokenProvider | undefined);
8
+ list(): Promise<{
9
+ characters: {
10
+ characterId: number;
11
+ characterName: string;
12
+ scopes: string[];
13
+ }[];
14
+ defaultCharacterId: number | null;
15
+ legacyCredentialPendingMigration: boolean;
16
+ browserAuthorizationAvailable: boolean;
17
+ }>;
18
+ authorize(characterId: number): Promise<{
19
+ characters: {
20
+ characterId: number;
21
+ characterName: string;
22
+ scopes: string[];
23
+ }[];
24
+ defaultCharacterId: number | null;
25
+ legacyCredentialPendingMigration: boolean;
26
+ browserAuthorizationAvailable: boolean;
27
+ }>;
28
+ select(characterId: number): Promise<{
29
+ characters: {
30
+ characterId: number;
31
+ characterName: string;
32
+ scopes: string[];
33
+ }[];
34
+ defaultCharacterId: number | null;
35
+ legacyCredentialPendingMigration: boolean;
36
+ browserAuthorizationAvailable: boolean;
37
+ }>;
38
+ }
@@ -0,0 +1,35 @@
1
+ /** Only non-secret character metadata crosses the MCP boundary. */
2
+ export class CharacterAuthentication {
3
+ store;
4
+ interactive;
5
+ constructor(store, interactive) {
6
+ this.store = store;
7
+ this.interactive = interactive;
8
+ }
9
+ async list() {
10
+ const file = await this.store.read();
11
+ return {
12
+ characters: file.characters.map(({ characterId, characterName, scopes }) => ({
13
+ characterId,
14
+ characterName,
15
+ scopes,
16
+ })),
17
+ defaultCharacterId: file.defaultCharacterId ?? null,
18
+ legacyCredentialPendingMigration: !!file.legacyCredential,
19
+ browserAuthorizationAvailable: !!this.interactive,
20
+ };
21
+ }
22
+ async authorize(characterId) {
23
+ if (!this.interactive)
24
+ throw new Error("Browser authorization is unavailable while environment token overrides are configured.");
25
+ await this.interactive.authorizeCharacter(characterId);
26
+ return this.list();
27
+ }
28
+ async select(characterId) {
29
+ if (!this.interactive)
30
+ throw new Error("Character selection is unavailable while environment token overrides are configured.");
31
+ await this.store.select(characterId);
32
+ return this.list();
33
+ }
34
+ }
35
+ //# sourceMappingURL=character-authentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"character-authentication.js","sourceRoot":"","sources":["../src/character-authentication.ts"],"names":[],"mappings":"AAGA,mEAAmE;AACnE,MAAM,OAAO,uBAAuB;IAEf;IACA;IAFnB,YACmB,KAAsB,EACtB,WAAyC;QADzC,UAAK,GAAL,KAAK,CAAiB;QACtB,gBAAW,GAAX,WAAW,CAA8B;IACzD,CAAC;IAEJ,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACrC,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAC7B,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC3C,WAAW;gBACX,aAAa;gBACb,MAAM;aACP,CAAC,CACH;YACD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,IAAI,IAAI;YACnD,gCAAgC,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;YACzD,6BAA6B,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW;SAClD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,WAAmB;QACjC,IAAI,CAAC,IAAI,CAAC,WAAW;YACnB,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;QACJ,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,WAAmB;QAC9B,IAAI,CAAC,IAAI,CAAC,WAAW;YACnB,MAAM,IAAI,KAAK,CACb,sFAAsF,CACvF,CAAC;QACJ,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;CACF"}
@@ -36,7 +36,7 @@ export async function getCharacterContext(client, catalog, input, options = {})
36
36
  let authorizationError;
37
37
  if (requiredScopes.length > 0) {
38
38
  try {
39
- authorization = await client.authorize(requiredScopes);
39
+ authorization = await client.authorize(requiredScopes, input.characterId);
40
40
  }
41
41
  catch (error) {
42
42
  authorizationError = error;
@@ -1 +1 @@
1
- {"version":3,"file":"character-context.js","sourceRoot":"","sources":["../src/character-context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,GAGf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,0BAA0B;IACnC,QAAQ,EAAE,kCAAkC;IAC5C,IAAI,EAAE,8BAA8B;IACpC,MAAM,EAAE,gCAAgC;IACxC,UAAU,EAAE,oCAAoC;IAChD,MAAM,EAAE,gCAAgC;CAChC,CAAC;AAIX,MAAM,aAAa,GACjB,4JAA4J,CAAC;AAE/J,SAAS,kBAAkB,CAAC,KAAa;IACvC,OAAO,IAAI,eAAe,CACxB,yCAAyC,KAAK,8BAA8B,EAC5E,SAAS,EACT,SAAS,EACT,EAAE,IAAI,EAAE,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