@chrischall/warapp-mcp 0.3.0 → 0.3.1
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/bundle.js +77 -28
- package/dist/direct/egress.js +75 -0
- package/dist/direct/sign-in.js +16 -4
- package/dist/direct/transport.js +35 -15
- package/dist/push/websocket.js +9 -2
- package/dist/tools/index.js +1 -1
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "MCP server for war.app (Warzone) — your games, players, settings, map bonuses and chokepoints, board analysis and route planning through war.app's per-player GameFeed API, plus the live board, territory picks, cards, turn planning and submission, turn notifications and game chat through your signed-in war.app tab (joining, leaving or surrendering a game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications and linking a session are confirm-gated).",
|
|
10
|
-
"version": "0.3.
|
|
10
|
+
"version": "0.3.1"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "war.app (Warzone)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
|
|
18
|
-
"version": "0.3.
|
|
18
|
+
"version": "0.3.1",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "warapp-mcp",
|
|
3
3
|
"displayName": "war.app (Warzone)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "war.app (Warzone) game advisor for Claude — games, maps, bonuses, routes, live board, picks, turns, cards and chat",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Hall",
|
package/dist/bundle.js
CHANGED
|
@@ -37974,7 +37974,7 @@ var require_proxy_agent = __commonJS({
|
|
|
37974
37974
|
return this.#client.destroy(err);
|
|
37975
37975
|
}
|
|
37976
37976
|
};
|
|
37977
|
-
var
|
|
37977
|
+
var ProxyAgent2 = class extends DispatcherBase {
|
|
37978
37978
|
constructor(opts) {
|
|
37979
37979
|
if (!opts || typeof opts === "object" && !(opts instanceof URL) && !opts.uri) {
|
|
37980
37980
|
throw new InvalidArgumentError("Proxy uri is mandatory");
|
|
@@ -38148,7 +38148,7 @@ var require_proxy_agent = __commonJS({
|
|
|
38148
38148
|
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
|
|
38149
38149
|
}
|
|
38150
38150
|
}
|
|
38151
|
-
module.exports =
|
|
38151
|
+
module.exports = ProxyAgent2;
|
|
38152
38152
|
}
|
|
38153
38153
|
});
|
|
38154
38154
|
|
|
@@ -38158,7 +38158,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
38158
38158
|
"use strict";
|
|
38159
38159
|
var DispatcherBase = require_dispatcher_base();
|
|
38160
38160
|
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
|
|
38161
|
-
var
|
|
38161
|
+
var ProxyAgent2 = require_proxy_agent();
|
|
38162
38162
|
var Agent2 = require_agent();
|
|
38163
38163
|
var DEFAULT_PORTS = {
|
|
38164
38164
|
"http:": 80,
|
|
@@ -38175,13 +38175,13 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
38175
38175
|
this[kNoProxyAgent] = new Agent2(agentOpts);
|
|
38176
38176
|
const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
|
|
38177
38177
|
if (HTTP_PROXY) {
|
|
38178
|
-
this[kHttpProxyAgent] = new
|
|
38178
|
+
this[kHttpProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTP_PROXY });
|
|
38179
38179
|
} else {
|
|
38180
38180
|
this[kHttpProxyAgent] = this[kNoProxyAgent];
|
|
38181
38181
|
}
|
|
38182
38182
|
const HTTPS_PROXY = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY;
|
|
38183
38183
|
if (HTTPS_PROXY) {
|
|
38184
|
-
this[kHttpsProxyAgent] = new
|
|
38184
|
+
this[kHttpsProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTPS_PROXY });
|
|
38185
38185
|
} else {
|
|
38186
38186
|
this[kHttpsProxyAgent] = this[kHttpProxyAgent];
|
|
38187
38187
|
}
|
|
@@ -53716,7 +53716,7 @@ var require_undici = __commonJS({
|
|
|
53716
53716
|
var BalancedPool = require_balanced_pool();
|
|
53717
53717
|
var RoundRobinPool = require_round_robin_pool();
|
|
53718
53718
|
var Agent2 = require_agent();
|
|
53719
|
-
var
|
|
53719
|
+
var ProxyAgent2 = require_proxy_agent();
|
|
53720
53720
|
var Socks5ProxyAgent = require_socks5_proxy_agent();
|
|
53721
53721
|
var EnvHttpProxyAgent = require_env_http_proxy_agent();
|
|
53722
53722
|
var RetryAgent = require_retry_agent();
|
|
@@ -53743,7 +53743,7 @@ var require_undici = __commonJS({
|
|
|
53743
53743
|
module.exports.BalancedPool = BalancedPool;
|
|
53744
53744
|
module.exports.RoundRobinPool = RoundRobinPool;
|
|
53745
53745
|
module.exports.Agent = Agent2;
|
|
53746
|
-
module.exports.ProxyAgent =
|
|
53746
|
+
module.exports.ProxyAgent = ProxyAgent2;
|
|
53747
53747
|
module.exports.Socks5ProxyAgent = Socks5ProxyAgent;
|
|
53748
53748
|
module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent;
|
|
53749
53749
|
module.exports.RetryAgent = RetryAgent;
|
|
@@ -124776,7 +124776,7 @@ async function captureBearerHeader(opts) {
|
|
|
124776
124776
|
}
|
|
124777
124777
|
|
|
124778
124778
|
// src/version.ts
|
|
124779
|
-
var VERSION2 = "0.3.
|
|
124779
|
+
var VERSION2 = "0.3.1";
|
|
124780
124780
|
|
|
124781
124781
|
// src/transport-bridge.ts
|
|
124782
124782
|
var SERVER_NAME = "warapp-mcp";
|
|
@@ -125344,6 +125344,43 @@ async function fetchPublic(url4, opts = {}) {
|
|
|
125344
125344
|
}
|
|
125345
125345
|
}
|
|
125346
125346
|
|
|
125347
|
+
// src/direct/egress.ts
|
|
125348
|
+
var import_undici2 = __toESM(require_undici(), 1);
|
|
125349
|
+
var EGRESS_PROXY_ENV = ["HTTPS_PROXY", "https_proxy"];
|
|
125350
|
+
var EGRESS_PROXY_INVALID = "HTTPS_PROXY is set but is not a usable http(s) proxy URL";
|
|
125351
|
+
var defaultProxyAgent = (url4) => new import_undici2.ProxyAgent(url4.href);
|
|
125352
|
+
var rawProxy = (env) => {
|
|
125353
|
+
for (const key of EGRESS_PROXY_ENV) {
|
|
125354
|
+
const v = readEnvVar(key, { env });
|
|
125355
|
+
if (v !== void 0) return v;
|
|
125356
|
+
}
|
|
125357
|
+
return void 0;
|
|
125358
|
+
};
|
|
125359
|
+
function egressProxyConfigured(env = process.env) {
|
|
125360
|
+
return rawProxy(env) !== void 0;
|
|
125361
|
+
}
|
|
125362
|
+
function egressProxyUrl(env = process.env) {
|
|
125363
|
+
const raw = rawProxy(env);
|
|
125364
|
+
if (raw === void 0) return void 0;
|
|
125365
|
+
let url4;
|
|
125366
|
+
try {
|
|
125367
|
+
url4 = new URL(raw);
|
|
125368
|
+
} catch {
|
|
125369
|
+
url4 = void 0;
|
|
125370
|
+
}
|
|
125371
|
+
if (!url4 || url4.protocol !== "http:" && url4.protocol !== "https:" || !url4.hostname) {
|
|
125372
|
+
throw new McpToolError(`${EGRESS_PROXY_INVALID}, so nothing was sent to war.app.`, {
|
|
125373
|
+
kind: "unknown",
|
|
125374
|
+
hint: "Set HTTPS_PROXY to a proxy URL such as http://127.0.0.1:8080, or unset it to connect directly."
|
|
125375
|
+
});
|
|
125376
|
+
}
|
|
125377
|
+
return url4;
|
|
125378
|
+
}
|
|
125379
|
+
function egressDispatcher(env = process.env, make = defaultProxyAgent) {
|
|
125380
|
+
const url4 = egressProxyUrl(env);
|
|
125381
|
+
return url4 ? make(url4) : void 0;
|
|
125382
|
+
}
|
|
125383
|
+
|
|
125347
125384
|
// src/direct/transport.ts
|
|
125348
125385
|
var TRANSPORT_ENV = "WARAPP_TRANSPORT";
|
|
125349
125386
|
var MAX_DIRECT_BODY_BYTES = 16 * 1024 * 1024;
|
|
@@ -125410,18 +125447,28 @@ function toDirectResult(res) {
|
|
|
125410
125447
|
}
|
|
125411
125448
|
return out;
|
|
125412
125449
|
}
|
|
125413
|
-
|
|
125414
|
-
|
|
125415
|
-
|
|
125416
|
-
|
|
125417
|
-
|
|
125418
|
-
|
|
125419
|
-
|
|
125420
|
-
|
|
125421
|
-
|
|
125422
|
-
|
|
125423
|
-
|
|
125424
|
-
}
|
|
125450
|
+
function createDirectFetch(opts = {}) {
|
|
125451
|
+
return async (url4, init) => {
|
|
125452
|
+
const proxy = egressDispatcher(opts.env ?? process.env, opts.proxyAgent);
|
|
125453
|
+
try {
|
|
125454
|
+
const res = await fetchPublic(url4, {
|
|
125455
|
+
...directFetchOptions(init.method),
|
|
125456
|
+
method: init.method,
|
|
125457
|
+
headers: init.headers,
|
|
125458
|
+
maxBytes: MAX_DIRECT_BODY_BYTES,
|
|
125459
|
+
timeoutMs: DIRECT_TIMEOUT_MS,
|
|
125460
|
+
...init.body !== void 0 ? { body: init.body } : {},
|
|
125461
|
+
...init.signal ? { signal: init.signal } : {},
|
|
125462
|
+
...proxy ? { dispatcher: proxy } : {}
|
|
125463
|
+
});
|
|
125464
|
+
return toDirectResult(res);
|
|
125465
|
+
} finally {
|
|
125466
|
+
await proxy?.close().catch(() => {
|
|
125467
|
+
});
|
|
125468
|
+
}
|
|
125469
|
+
};
|
|
125470
|
+
}
|
|
125471
|
+
var fetchViaPublic = createDirectFetch();
|
|
125425
125472
|
function warappUrl(path) {
|
|
125426
125473
|
const raw = /^https?:\/\//i.test(path) ? path : `https://${SESSION_HOST}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
125427
125474
|
let u;
|
|
@@ -125531,7 +125578,7 @@ function createDirectFirstBridge(opts) {
|
|
|
125531
125578
|
const mode = pinned ? "fetchproxy" : opts.mode ?? readTransportMode(TRANSPORT_ENV, opts.env ? { env: opts.env } : {});
|
|
125532
125579
|
const store = hosted ? { read: async () => hostSession } : opts.store;
|
|
125533
125580
|
const hostSignIn = hostSession !== null;
|
|
125534
|
-
const direct = new DirectBridge(store, opts.directFetch, hostSignIn);
|
|
125581
|
+
const direct = new DirectBridge(store, opts.directFetch ?? createDirectFetch({ env }), hostSignIn);
|
|
125535
125582
|
const log = opts.log ?? ((m) => console.error(m));
|
|
125536
125583
|
const now = opts.now ?? Date.now;
|
|
125537
125584
|
let wall = null;
|
|
@@ -145856,9 +145903,9 @@ function websocketUrl(sid) {
|
|
|
145856
145903
|
if (!/^[A-Za-z0-9_-]+$/.test(sid)) throw new Error("war.app returned an unusable push-socket session id.");
|
|
145857
145904
|
return `wss://${WS_HOST}/socket.io/1/websocket/${sid}`;
|
|
145858
145905
|
}
|
|
145859
|
-
function pushWebSocketLeg(bridge2, readSession2, seams = {}) {
|
|
145906
|
+
function pushWebSocketLeg(bridge2, readSession2, seams = {}, env = process.env) {
|
|
145860
145907
|
return {
|
|
145861
|
-
select: () => bridge2.status().transport === "direct",
|
|
145908
|
+
select: () => bridge2.status().transport === "direct" && !egressProxyConfigured(env),
|
|
145862
145909
|
session: readSession2,
|
|
145863
145910
|
...seams
|
|
145864
145911
|
};
|
|
@@ -146584,7 +146631,7 @@ function pushListenerFor(key, opts) {
|
|
|
146584
146631
|
}
|
|
146585
146632
|
|
|
146586
146633
|
// src/direct/sign-in.ts
|
|
146587
|
-
var
|
|
146634
|
+
var import_undici3 = __toESM(require_undici(), 1);
|
|
146588
146635
|
var ORIGIN = `https://${SESSION_HOST}`;
|
|
146589
146636
|
var SIGN_IN_URL = `${ORIGIN}/LogIn`;
|
|
146590
146637
|
var AUTH_COOKIE2 = "AuthToken";
|
|
@@ -146594,10 +146641,12 @@ var SIGN_IN_TIMEOUT_MS = 3e4;
|
|
|
146594
146641
|
var SIGN_IN_MAX_BODY_BYTES = 2 * 1024 * 1024;
|
|
146595
146642
|
function createSignInFetch(opts = {}) {
|
|
146596
146643
|
const maxBytes = opts.maxBytes ?? SIGN_IN_MAX_BODY_BYTES;
|
|
146644
|
+
const proxy = opts.dispatcher ? void 0 : egressProxyUrl(opts.env ?? process.env);
|
|
146645
|
+
const makeProxy = opts.proxyAgent ?? defaultProxyAgent;
|
|
146597
146646
|
return async (url4, init) => {
|
|
146598
|
-
const owned = opts.dispatcher ? void 0 : createPublicOnlyDispatcher();
|
|
146647
|
+
const owned = opts.dispatcher ? void 0 : proxy ? makeProxy(proxy) : createPublicOnlyDispatcher();
|
|
146599
146648
|
try {
|
|
146600
|
-
const res = await (0,
|
|
146649
|
+
const res = await (0, import_undici3.fetch)(url4, {
|
|
146601
146650
|
method: init.method,
|
|
146602
146651
|
headers: init.headers,
|
|
146603
146652
|
...init.body !== void 0 ? { body: init.body } : {},
|
|
@@ -146693,7 +146742,7 @@ async function exchange(creds, jar, opts) {
|
|
|
146693
146742
|
if (!creds.email.trim() || !creds.password) {
|
|
146694
146743
|
throw refusal2("no_credential", "Signing in to war.app needs both the email and the password; nothing was sent.");
|
|
146695
146744
|
}
|
|
146696
|
-
const fetchHop = opts.fetch ?? createSignInFetch();
|
|
146745
|
+
const fetchHop = opts.fetch ?? createSignInFetch(opts.env ? { env: opts.env } : {});
|
|
146697
146746
|
const timeoutMs = opts.timeoutMs ?? SIGN_IN_TIMEOUT_MS;
|
|
146698
146747
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
146699
146748
|
const signal = opts.signal ? AbortSignal.any([opts.signal, timeout]) : timeout;
|
|
@@ -146887,7 +146936,7 @@ function registerAllTools(server, deps = {}) {
|
|
|
146887
146936
|
registerDiplomacyTool(server, live, deps.env ? { env: deps.env } : {});
|
|
146888
146937
|
const push = deps.push ?? pushListenerFor(fetchproxy, {
|
|
146889
146938
|
transport: () => bridge2.ready(),
|
|
146890
|
-
webSocket: pushWebSocketLeg(bridge2, () => readSession(deps.env)),
|
|
146939
|
+
webSocket: pushWebSocketLeg(bridge2, () => readSession(deps.env), {}, deps.env ?? process.env),
|
|
146891
146940
|
extras: () => live.rpc.extras
|
|
146892
146941
|
});
|
|
146893
146942
|
registerSessionTools(server, {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// mcp-host's egress proxy, for the requests that bring their own dispatcher.
|
|
2
|
+
//
|
|
3
|
+
// On mcp-host a child reaches the internet ONLY through the egress proxy that
|
|
4
|
+
// `HTTPS_PROXY` + `NODE_USE_ENV_PROXY=1` point Node's built-in fetch at: a
|
|
5
|
+
// direct socket is silently dropped and reads as a timeout. Global fetch
|
|
6
|
+
// honours the variable; a custom undici dispatcher does not. The war.app
|
|
7
|
+
// sign-in (src/direct/sign-in.ts) and the direct leg (src/direct/transport.ts)
|
|
8
|
+
// each send through their own dispatcher — mcp-utils netguard's public-only
|
|
9
|
+
// one — so hosted, neither could reach war.app at all ("Could not reach
|
|
10
|
+
// war.app to sign in"). GameFeed (`createApiClient`) and the bundle download
|
|
11
|
+
// use global fetch and need nothing here.
|
|
12
|
+
//
|
|
13
|
+
// With a proxy configured, those two send through an undici `ProxyAgent` for
|
|
14
|
+
// it instead (a CONNECT tunnel; TLS to war.app still checks war.app's
|
|
15
|
+
// certificate). The host check stays in our code — the exact origin
|
|
16
|
+
// https://war.app — and the proxy enforces the child's allowlist and its own
|
|
17
|
+
// address table, so netguard's public-only pin is not needed there. Without a
|
|
18
|
+
// proxy (local) nothing changes: the public-only dispatcher, as before.
|
|
19
|
+
//
|
|
20
|
+
// A proxy that is set but unusable is a configuration error, refused clearly:
|
|
21
|
+
// never a fallback to a direct connection. NO_PROXY is not read: war.app is
|
|
22
|
+
// never meant to bypass the proxy. The proxy URL is never echoed (it may carry
|
|
23
|
+
// a password).
|
|
24
|
+
import { McpToolError, readEnvVar } from '@chrischall/mcp-utils';
|
|
25
|
+
import { ProxyAgent } from 'undici';
|
|
26
|
+
/** The variables naming the proxy, in the order read (curl's and undici's spellings). */
|
|
27
|
+
export const EGRESS_PROXY_ENV = ['HTTPS_PROXY', 'https_proxy'];
|
|
28
|
+
/** The start of the refusal for a proxy that is set but unusable. */
|
|
29
|
+
export const EGRESS_PROXY_INVALID = 'HTTPS_PROXY is set but is not a usable http(s) proxy URL';
|
|
30
|
+
export const defaultProxyAgent = (url) => new ProxyAgent(url.href);
|
|
31
|
+
const rawProxy = (env) => {
|
|
32
|
+
for (const key of EGRESS_PROXY_ENV) {
|
|
33
|
+
const v = readEnvVar(key, { env });
|
|
34
|
+
if (v !== undefined)
|
|
35
|
+
return v;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
/** Whether a proxy is configured at all (usable or not): then nothing may connect directly. */
|
|
40
|
+
export function egressProxyConfigured(env = process.env) {
|
|
41
|
+
return rawProxy(env) !== undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The egress proxy's URL when `HTTPS_PROXY` (or `https_proxy`) is set, else
|
|
45
|
+
* `undefined`. Throws a clear error, before anything is sent, when the variable
|
|
46
|
+
* is set but not an http(s) URL with a host (never echoing it).
|
|
47
|
+
*/
|
|
48
|
+
export function egressProxyUrl(env = process.env) {
|
|
49
|
+
const raw = rawProxy(env);
|
|
50
|
+
if (raw === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
let url;
|
|
53
|
+
try {
|
|
54
|
+
url = new URL(raw);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
url = undefined;
|
|
58
|
+
}
|
|
59
|
+
if (!url || (url.protocol !== 'http:' && url.protocol !== 'https:') || !url.hostname) {
|
|
60
|
+
throw new McpToolError(`${EGRESS_PROXY_INVALID}, so nothing was sent to war.app.`, {
|
|
61
|
+
kind: 'unknown',
|
|
62
|
+
hint: 'Set HTTPS_PROXY to a proxy URL such as http://127.0.0.1:8080, or unset it to connect directly.',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return url;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The dispatcher to send war.app traffic through: a proxy agent for
|
|
69
|
+
* {@link egressProxyUrl}, else `undefined` (the caller keeps its public-only
|
|
70
|
+
* dispatcher). Throws as {@link egressProxyUrl} does. The caller closes the agent.
|
|
71
|
+
*/
|
|
72
|
+
export function egressDispatcher(env = process.env, make = defaultProxyAgent) {
|
|
73
|
+
const url = egressProxyUrl(env);
|
|
74
|
+
return url ? make(url) : undefined;
|
|
75
|
+
}
|
package/dist/direct/sign-in.js
CHANGED
|
@@ -29,10 +29,14 @@
|
|
|
29
29
|
// value: each is scrubbed BY VALUE, and the cause chain is dropped.
|
|
30
30
|
// - The single-hop fetch goes through mcp-utils netguard's public-only
|
|
31
31
|
// dispatcher (a name that resolves or rebinds inward is refused), with one
|
|
32
|
-
// deadline over the whole exchange and a byte cap on each body.
|
|
32
|
+
// deadline over the whole exchange and a byte cap on each body. With an
|
|
33
|
+
// egress proxy configured (HTTPS_PROXY: mcp-host's only way out) it goes
|
|
34
|
+
// through a proxy agent instead (src/direct/egress.ts); a proxy that is set
|
|
35
|
+
// but unusable is refused before anything is sent.
|
|
33
36
|
import { detectEdgeBlock, McpToolError } from '@chrischall/mcp-utils';
|
|
34
37
|
import { createPublicOnlyDispatcher } from '@chrischall/mcp-utils/netguard';
|
|
35
38
|
import { fetch as undiciFetch } from 'undici';
|
|
39
|
+
import { defaultProxyAgent, egressProxyUrl } from './egress.js';
|
|
36
40
|
import { scrubSecrets } from '../redact.js';
|
|
37
41
|
import { isPlausibleAuthToken, SESSION_HOST } from './session.js';
|
|
38
42
|
import { hasPasswordInput } from './transport.js';
|
|
@@ -50,11 +54,19 @@ const MIN_SCRUBBED_COOKIE = 6;
|
|
|
50
54
|
export const SIGN_IN_TIMEOUT_MS = 30_000;
|
|
51
55
|
/** Byte cap on each response body (the sign-in page is a few tens of KB). */
|
|
52
56
|
export const SIGN_IN_MAX_BODY_BYTES = 2 * 1024 * 1024;
|
|
53
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* The default single-hop fetch: undici, redirects never followed, through the
|
|
59
|
+
* egress proxy when one is configured (src/direct/egress.ts), else through a
|
|
60
|
+
* public-only dispatcher. A proxy that is set but unusable throws here, before
|
|
61
|
+
* any request.
|
|
62
|
+
*/
|
|
54
63
|
export function createSignInFetch(opts = {}) {
|
|
55
64
|
const maxBytes = opts.maxBytes ?? SIGN_IN_MAX_BODY_BYTES;
|
|
65
|
+
// Read (and a bad proxy refused) now, before any request; an agent is built per hop and closed.
|
|
66
|
+
const proxy = opts.dispatcher ? undefined : egressProxyUrl(opts.env ?? process.env);
|
|
67
|
+
const makeProxy = opts.proxyAgent ?? defaultProxyAgent;
|
|
56
68
|
return async (url, init) => {
|
|
57
|
-
const owned = opts.dispatcher ? undefined : createPublicOnlyDispatcher();
|
|
69
|
+
const owned = opts.dispatcher ? undefined : proxy ? makeProxy(proxy) : createPublicOnlyDispatcher();
|
|
58
70
|
try {
|
|
59
71
|
const res = await undiciFetch(url, {
|
|
60
72
|
method: init.method,
|
|
@@ -181,7 +193,7 @@ async function exchange(creds, jar, opts) {
|
|
|
181
193
|
if (!creds.email.trim() || !creds.password) {
|
|
182
194
|
throw refusal('no_credential', 'Signing in to war.app needs both the email and the password; nothing was sent.');
|
|
183
195
|
}
|
|
184
|
-
const fetchHop = opts.fetch ?? createSignInFetch();
|
|
196
|
+
const fetchHop = opts.fetch ?? createSignInFetch(opts.env ? { env: opts.env } : {});
|
|
185
197
|
const timeoutMs = opts.timeoutMs ?? SIGN_IN_TIMEOUT_MS;
|
|
186
198
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
187
199
|
const signal = opts.signal ? AbortSignal.any([opts.signal, timeout]) : timeout;
|
package/dist/direct/transport.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
// {@link DirectBridge} is that direct leg: it reads the AuthToken from the
|
|
11
11
|
// session store (src/direct/session.ts) per call and issues an HTTPS request
|
|
12
12
|
// through mcp-utils netguard `fetchPublic` (pinned to public addresses, so a
|
|
13
|
-
// name that resolves or rebinds inward is refused)
|
|
13
|
+
// name that resolves or rebinds inward is refused) — or, with an egress proxy
|
|
14
|
+
// configured (HTTPS_PROXY, mcp-host's only way out), through a proxy agent for
|
|
15
|
+
// it (src/direct/egress.ts), the proxy holding the address table. Every hop must be the exact
|
|
14
16
|
// origin https://war.app; a non-GET follows no redirect at all, so its body (the
|
|
15
17
|
// account email, the orders) is never re-sent anywhere
|
|
16
18
|
// ({@link directFetchOptions}). It maps the reply into the same
|
|
@@ -40,6 +42,7 @@
|
|
|
40
42
|
import { detectEdgeBlock, EdgeBlockedError, McpToolError } from '@chrischall/mcp-utils';
|
|
41
43
|
import { createDirectFirstTransport, readTransportMode, } from '@chrischall/mcp-utils/fetchproxy';
|
|
42
44
|
import { fetchPublic } from '@chrischall/mcp-utils/netguard';
|
|
45
|
+
import { egressDispatcher } from './egress.js';
|
|
43
46
|
import { isHosted } from '../hosted.js';
|
|
44
47
|
import { hostedSession, SESSION_HOST, scrubError } from './session.js';
|
|
45
48
|
/** The env var pinning the transport: `direct` | `fetchproxy` | `auto` (default). */
|
|
@@ -150,19 +153,36 @@ export function toDirectResult(res) {
|
|
|
150
153
|
}
|
|
151
154
|
return out;
|
|
152
155
|
}
|
|
153
|
-
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
/**
|
|
157
|
+
* The default direct leg: a real HTTPS request through netguard `fetchPublic`
|
|
158
|
+
* (war.app-only by `allowHosts` and `stopBefore`). With an egress proxy
|
|
159
|
+
* configured (HTTPS_PROXY: mcp-host's only way out, src/direct/egress.ts) it
|
|
160
|
+
* goes through a proxy agent, built per request and closed after; else netguard
|
|
161
|
+
* builds its public-only dispatcher, as before. A proxy that is set but unusable
|
|
162
|
+
* throws before anything is sent: never a direct connection instead.
|
|
163
|
+
*/
|
|
164
|
+
export function createDirectFetch(opts = {}) {
|
|
165
|
+
return async (url, init) => {
|
|
166
|
+
const proxy = egressDispatcher(opts.env ?? process.env, opts.proxyAgent);
|
|
167
|
+
try {
|
|
168
|
+
const res = await fetchPublic(url, {
|
|
169
|
+
...directFetchOptions(init.method),
|
|
170
|
+
method: init.method,
|
|
171
|
+
headers: init.headers,
|
|
172
|
+
maxBytes: MAX_DIRECT_BODY_BYTES,
|
|
173
|
+
timeoutMs: DIRECT_TIMEOUT_MS,
|
|
174
|
+
...(init.body !== undefined ? { body: init.body } : {}),
|
|
175
|
+
...(init.signal ? { signal: init.signal } : {}),
|
|
176
|
+
...(proxy ? { dispatcher: proxy } : {}),
|
|
177
|
+
});
|
|
178
|
+
return toDirectResult(res);
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
await proxy?.close().catch(() => { });
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const fetchViaPublic = createDirectFetch();
|
|
166
186
|
/**
|
|
167
187
|
* Resolve a bridge path to an absolute https URL on the exact host war.app,
|
|
168
188
|
* refusing any other host (a subdomain or look-alike included), userinfo and a
|
|
@@ -351,7 +371,7 @@ export function createDirectFirstBridge(opts) {
|
|
|
351
371
|
: (opts.mode ?? readTransportMode(TRANSPORT_ENV, opts.env ? { env: opts.env } : {}));
|
|
352
372
|
const store = hosted ? { read: async () => hostSession } : opts.store;
|
|
353
373
|
const hostSignIn = hostSession !== null;
|
|
354
|
-
const direct = new DirectBridge(store, opts.directFetch, hostSignIn);
|
|
374
|
+
const direct = new DirectBridge(store, opts.directFetch ?? createDirectFetch({ env }), hostSignIn);
|
|
355
375
|
const log = opts.log ?? ((m) => console.error(m));
|
|
356
376
|
const now = opts.now ?? Date.now;
|
|
357
377
|
let wall = null;
|
package/dist/push/websocket.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { egressProxyConfigured } from '../direct/egress.js';
|
|
1
2
|
import { scrubToken } from '../direct/session.js';
|
|
2
3
|
import { DirectBridge } from '../direct/transport.js';
|
|
3
4
|
import { parseHandshake, parsePacket, SOCKET_URL } from './packets.js';
|
|
@@ -37,10 +38,16 @@ export function websocketUrl(sid) {
|
|
|
37
38
|
* The leg for the process's direct-first bridge: the WebSocket is selected
|
|
38
39
|
* only while the active transport is `direct` (pinned `direct`, or `auto`
|
|
39
40
|
* still on the direct leg); otherwise the push stays on xhr-polling.
|
|
41
|
+
*
|
|
42
|
+
* Never with an egress proxy configured (HTTPS_PROXY: mcp-host's only way out,
|
|
43
|
+
* src/direct/egress.ts). Node's built-in WebSocket opens its own socket, which
|
|
44
|
+
* the proxy would not carry (a direct socket is silently dropped there), so the
|
|
45
|
+
* push stays on xhr-polling over the direct-first router, whose direct leg goes
|
|
46
|
+
* through the proxy. Read on each attempt.
|
|
40
47
|
*/
|
|
41
|
-
export function pushWebSocketLeg(bridge, readSession, seams = {}) {
|
|
48
|
+
export function pushWebSocketLeg(bridge, readSession, seams = {}, env = process.env) {
|
|
42
49
|
return {
|
|
43
|
-
select: () => bridge.status().transport === 'direct',
|
|
50
|
+
select: () => bridge.status().transport === 'direct' && !egressProxyConfigured(env),
|
|
44
51
|
session: readSession,
|
|
45
52
|
...seams,
|
|
46
53
|
};
|
package/dist/tools/index.js
CHANGED
|
@@ -135,7 +135,7 @@ export function registerAllTools(server, deps = {}) {
|
|
|
135
135
|
const push = deps.push ??
|
|
136
136
|
pushListenerFor(fetchproxy, {
|
|
137
137
|
transport: () => bridge.ready(),
|
|
138
|
-
webSocket: pushWebSocketLeg(bridge, () => readSession(deps.env)),
|
|
138
|
+
webSocket: pushWebSocketLeg(bridge, () => readSession(deps.env), {}, deps.env ?? process.env),
|
|
139
139
|
extras: () => live.rpc.extras,
|
|
140
140
|
});
|
|
141
141
|
registerSessionTools(server, {
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Single source of truth for the server version. release-please bumps the
|
|
2
2
|
// literal on the marked line (registered in release-please-config.json
|
|
3
3
|
// extra-files); every other module imports VERSION from here.
|
|
4
|
-
export const VERSION = '0.3.
|
|
4
|
+
export const VERSION = '0.3.1'; // x-release-please-version
|
package/manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest_version": "0.3",
|
|
4
4
|
"name": "warapp-mcp",
|
|
5
5
|
"display_name": "war.app (Warzone)",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.1",
|
|
7
7
|
"description": "war.app (Warzone) game advisor for Claude — your games, maps, bonuses, board analysis and routes via the GameFeed API, plus your games list (waiting on you first), opponent scouting with your head-to-head, the live board, territory picks, cards, turn planning and submission, turn notifications, and chat through your signed-in war.app tab (ContextMint Bridge). Joining, leaving or surrendering a game, accepting another player's surrender, Begin on a speed first turn, picks, turn orders, withdrawing them, chat sends, marking notifications and chat read, deleting notifications and linking a session (local only) are confirm-gated.",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrischall/warapp-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"mcpName": "io.github.chrischall/warapp-mcp",
|
|
5
5
|
"description": "war.app (Warzone) game advisor MCP server for Claude — games, maps, bonuses and board analysis via the GameFeed API, plus your games list, opponent scouting, the live board, territory picks, cards, turn planning and submission, turn notifications and chat through your signed-in war.app tab. Developed and maintained by AI (Claude Code).",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/chrischall/warapp-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.1",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@chrischall/warapp-mcp",
|
|
14
|
-
"version": "0.3.
|
|
14
|
+
"version": "0.3.1",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|