@edgegap/mcp 0.11.0 → 0.12.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.
- package/README.md +65 -3
- package/dist/auth.js +16 -6
- package/dist/callreport.js +157 -0
- package/dist/client.js +9 -0
- package/dist/hosted.js +4 -1
- package/dist/http.js +1 -1
- package/dist/skills.generated.js +64 -25
- package/dist/skills.js +12 -1
- package/dist/tools.js +511 -84
- package/dist/version.js +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -107,6 +107,53 @@ In Claude Desktop, open **Settings → Developer → Edit Config** and add the l
|
|
|
107
107
|
|
|
108
108
|
Leave the token out and you're asked for it on first use. claude.ai in the browser can't run a local server, so it can't use Edgegap MCP until the hosted endpoint supports OAuth.
|
|
109
109
|
|
|
110
|
+
#### Cursor
|
|
111
|
+
|
|
112
|
+
The **Cursor** button at the top of this page installs it; to do it by hand, add this to `~/.cursor/mcp.json` (or `.cursor/mcp.json` in a project):
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"edgegap": {
|
|
118
|
+
"url": "https://mcp.edgegap.dev/mcp",
|
|
119
|
+
"headers": { "Authorization": "token xxxxxxxx-e458-4592-b607-c2c28afd8b62" }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### VS Code (Copilot agent mode)
|
|
126
|
+
|
|
127
|
+
The **VS Code** button at the top of this page installs it; to do it by hand, add this to `.vscode/mcp.json` (VS Code uses `servers`, not `mcpServers`):
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"servers": {
|
|
132
|
+
"edgegap": {
|
|
133
|
+
"type": "http",
|
|
134
|
+
"url": "https://mcp.edgegap.dev/mcp",
|
|
135
|
+
"headers": { "Authorization": "token xxxxxxxx-e458-4592-b607-c2c28afd8b62" }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### Windsurf
|
|
142
|
+
|
|
143
|
+
In `~/.codeium/windsurf/mcp_config.json`, run the [Local Server](#local-server), which works in every client that starts MCP servers as commands:
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"mcpServers": {
|
|
148
|
+
"edgegap": {
|
|
149
|
+
"command": "npx",
|
|
150
|
+
"args": ["-y", "@edgegap/mcp"],
|
|
151
|
+
"env": { "EDGEGAP_API_TOKEN": "xxxxxxxx-e458-4592-b607-c2c28afd8b62" }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
110
157
|
#### mcp.json
|
|
111
158
|
|
|
112
159
|
Most agentic IDEs also support integration by pasting JSON configuration:
|
|
@@ -167,7 +214,7 @@ To keep your API token on your own machine, run the server locally instead. Leav
|
|
|
167
214
|
}
|
|
168
215
|
```
|
|
169
216
|
|
|
170
|
-
Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.
|
|
217
|
+
Needs Node 18+. Pin a version in production (`@edgegap/mcp@0.12.0`) rather than floating on latest. Registered in the official MCP registry as `dev.edgegap/mcp`.
|
|
171
218
|
|
|
172
219
|
The local server can also limit what an agent can do. These variables have no effect on the hosted endpoint at `mcp.edgegap.dev`:
|
|
173
220
|
|
|
@@ -193,6 +240,13 @@ The server includes the [Edgegap agent skills](https://github.com/edgegap/llm-ag
|
|
|
193
240
|
| `edgegap-fishnet` | Unity with FishNet end to end: headless server, Bayou/WebGL, matchmaker, end-to-end test. |
|
|
194
241
|
| `edgegap-purrnet` | Unity with PurrNet end to end: dedicated server, connect panel, matchmaker, end-to-end test. |
|
|
195
242
|
| `edgegap-fusion` | Unity with Photon Fusion 2 end to end: IL2CPP Linux server, server bound to 0.0.0.0, Edgegap deployment, BR200 kit. |
|
|
243
|
+
| `edgegap-fusion-simplefps` | Photon's Simple FPS sample on Edgegap dedicated servers. |
|
|
244
|
+
| `edgegap-godot` | Godot 4 with a Godot dedicated server: headless export, ENet or WebSocket, matchmaker. |
|
|
245
|
+
| `edgegap-colyseus` | Colyseus servers on Edgegap, direct or through the matchmaker. |
|
|
246
|
+
| `edgegap-nakama` | Nakama as the backend, starting Edgegap servers for its matches. |
|
|
247
|
+
| `edgegap-playfab` | PlayFab Matchmaking with Edgegap servers. |
|
|
248
|
+
| `edgegap-threejs` | Three.js and other browser games with their own Node.js server. |
|
|
249
|
+
| `edgegap-matchmaking` | Matchmaking design for any engine: who owns it, profiles, parties, region selection, backfill, third-party matchmakers. |
|
|
196
250
|
| `edgegap-manus` | Browser games built with Manus: backend matchmaking, Steam sign-in, signed join tokens, Node WebSocket server. |
|
|
197
251
|
| `edgegap-unreal` | Unreal Engine end to end: source engine, Linux server, matchmaker, end-to-end test. |
|
|
198
252
|
| `edgegap-eos-voice` | Voice chat for an Unreal game on Edgegap with EOS Voice: server-side room tokens, match and team rooms. |
|
|
@@ -206,7 +260,7 @@ The server includes the [Edgegap agent skills](https://github.com/edgegap/llm-ag
|
|
|
206
260
|
They're served three ways, so every MCP client can reach them:
|
|
207
261
|
|
|
208
262
|
- **Tools:** `edgegap_list_skills` and `edgegap_get_skill`, which loads a skill's `SKILL.md`, or one of its reference documents or templates with `file`.
|
|
209
|
-
- **Prompts:** one per skill, named after it. In Claude Code they show up as slash commands, e.g. `/
|
|
263
|
+
- **Prompts:** `deploy-game-server` ("Deploy my game server to Edgegap") is the place to start: it finds the engine and netcode, loads the matching skill and walks the golden path, cleanup included. There is also one prompt per skill, named after it. In Claude Code they show up as slash commands, e.g. `/mcp__edgegap__deploy-game-server`.
|
|
210
264
|
- **Resources:** each skill's `SKILL.md` is listed, at `edgegap-skill://<skill>/SKILL.md`; every other file is read through the `edgegap-skill://{skill}/{+path}` template, e.g. `edgegap-skill://edgegap-unity/references/deploy.md`.
|
|
211
265
|
|
|
212
266
|
Each release bundles the skills at the commit pinned in `scripts/skills-pin.txt`; `edgegap_context` reports which pack is loaded. `edgegap_list_skills` also reads the latest pack version from GitHub (one version number, cached for an hour; `EDGEGAP_SKILLS_CHECK=off` turns it off) and says when a newer one is out, and `edgegap_get_skill` adds the same note under a skill's header.
|
|
@@ -304,7 +358,7 @@ Your API token can do anything in your organization, so the server adds its own
|
|
|
304
358
|
|
|
305
359
|
The server identifies itself with `User-Agent: edgegap-mcp/<version> (<MCP client name>)` on every API call.
|
|
306
360
|
|
|
307
|
-
**Usage analytics.** The local server and the self-hosted Docker image send nothing beyond the API calls themselves. The hosted endpoint at `mcp.edgegap.dev` uses [PostHog MCP Analytics](https://posthog.com/docs/mcp-analytics) (`@posthog/mcp`) and sends usage events to Edgegap's PostHog: which MCP client connected, which tool, prompt or skill resource was used, the names (not values) of the arguments passed, whether a call succeeded
|
|
361
|
+
**Usage analytics.** The local server and the self-hosted Docker image send nothing beyond the API calls themselves. The hosted endpoint at `mcp.edgegap.dev` uses [PostHog MCP Analytics](https://posthog.com/docs/mcp-analytics) (`@posthog/mcp`) and sends usage events to Edgegap's PostHog: which MCP client connected, which tool, prompt or skill resource was used, the names (not values) of the arguments passed, whether a call succeeded, its error code, the stage it failed at and the Edgegap API status, how long it took, whether it was a dry run, a few facts about the call (how a wait for a deployment ended, a validation result, which skill was loaded), which golden-path step was reached, plus the server version and Cloudflare's country code. On a failed call it also sends the error message, after removing your token, the values of the arguments you passed, and anything shaped like a credential, an IP address or an ID, cut to 300 characters. Deployment IDs are only sent as a keyed hash. Only named metadata properties are let through. It never sends your token, tool argument values (IP addresses, env vars, app or image names) or results, and GeoIP is off. It adds no parameters to the tools. Events from one token are grouped under a keyed, non-reversible hash of it. The full list is in [docs/analytics.md](docs/analytics.md). To opt out, send the header `X-Edgegap-Telemetry: off` (or `DNT: 1`), or use the local server.
|
|
308
362
|
|
|
309
363
|
## 🚨 Troubleshooting
|
|
310
364
|
|
|
@@ -326,6 +380,14 @@ Edgegap could not pull your container image. Check the repository, image name, a
|
|
|
326
380
|
|
|
327
381
|
Edgegap only gives registry credentials to the quick-start token the Unity and Unreal plugins use, so with a regular API token your agent can't retrieve them and asks you instead. Copy the Project, Username and Token from the [dashboard](https://app.edgegap.com) under **Container Registry**, or push to another registry Edgegap can pull from (Docker Hub, GitHub, AWS ECR, GCP, GitLab). See [External Registries](https://docs.edgegap.com/docs/tools-and-integrations/docker/external-registries).
|
|
328
382
|
|
|
383
|
+
### "status": "empty" or "not_configured"
|
|
384
|
+
|
|
385
|
+
Not an error. A list with nothing in it (no applications yet, no deployments running, an image never pushed) or a feature this organization has not set up (relays, a registry this token cannot read) comes back as a normal result with `status` and a `next_step`. Your agent should do the next step instead of retrying.
|
|
386
|
+
|
|
387
|
+
### No Token Yet
|
|
388
|
+
|
|
389
|
+
The skills (`edgegap_list_skills`, `edgegap_get_skill`), `edgegap_context`, `edgegap_generate_dockerfile` and `edgegap_validate_server_config` work without a token, so an agent can prepare the server build first. Create an account at [app.edgegap.com](https://app.edgegap.com) and a token under [User Settings → Tokens](https://app.edgegap.com/user-settings?tab=tokens). `edgegap_context` with `check_token: true` says whether the session's token is present and accepted, and shows its last four characters so you can find it on that page.
|
|
390
|
+
|
|
329
391
|
### Server Starts Locally but Not on Edgegap
|
|
330
392
|
|
|
331
393
|
Ask your agent to validate your server configuration, or to generate a new Dockerfile. The most common causes are an image built on Apple Silicon without `docker build --platform linux/amd64`, a server listening on a different port than the version exposes, or a UDP transport configured as TCP.
|
package/dist/auth.js
CHANGED
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
*/
|
|
40
40
|
import { stripTokenPrefix } from './config.js';
|
|
41
41
|
export class TokenUnavailableError extends Error {
|
|
42
|
+
reason;
|
|
43
|
+
constructor(message, reason = 'absent') {
|
|
44
|
+
super(message);
|
|
45
|
+
this.reason = reason;
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
/** Shown to the developer at the moment they are asked to hand over a token. */
|
|
44
49
|
export const PRIVILEGE_WARNING = 'This token grants full access to your entire Edgegap organization: every ' +
|
|
@@ -141,7 +146,10 @@ export class TokenProvider {
|
|
|
141
146
|
'This MCP client does not support interactive prompts, so the token has ' +
|
|
142
147
|
'to be supplied up front. Add it to your MCP client config:\n\n' +
|
|
143
148
|
' "env": { "EDGEGAP_API_TOKEN": "your-token" }\n\n' +
|
|
144
|
-
'Generate a token at https://app.edgegap.com/user-settings?tab=tokens
|
|
149
|
+
'Generate a token at https://app.edgegap.com/user-settings?tab=tokens ' +
|
|
150
|
+
'(no Edgegap account yet? Sign up free at https://app.edgegap.com).\n\n' +
|
|
151
|
+
'Until then, edgegap_context, edgegap_list_skills, edgegap_get_skill, edgegap_generate_dockerfile ' +
|
|
152
|
+
'and edgegap_validate_server_config work without a token.\n\n' +
|
|
145
153
|
PRIVILEGE_WARNING);
|
|
146
154
|
}
|
|
147
155
|
const result = await this.server.elicitInput({
|
|
@@ -172,19 +180,19 @@ export class TokenProvider {
|
|
|
172
180
|
if (result.action !== 'accept' || !result.content) {
|
|
173
181
|
throw new TokenUnavailableError('The developer declined to provide an Edgegap API token. Do not retry ' +
|
|
174
182
|
'automatically. Stop and tell them which operation needed it, so they ' +
|
|
175
|
-
'can decide whether to continue.');
|
|
183
|
+
'can decide whether to continue.', 'declined');
|
|
176
184
|
}
|
|
177
185
|
const acknowledged = result.content.acknowledged === true;
|
|
178
186
|
if (!acknowledged) {
|
|
179
187
|
throw new TokenUnavailableError('The token privilege acknowledgement was not accepted, so no token was ' +
|
|
180
188
|
'stored. Nothing has been sent to Edgegap. If the org-wide scope is the ' +
|
|
181
189
|
'concern, the safer setup is a token from a separate non-production ' +
|
|
182
|
-
'organization with EDGEGAP_READ_ONLY=1.');
|
|
190
|
+
'organization with EDGEGAP_READ_ONLY=1.', 'declined');
|
|
183
191
|
}
|
|
184
192
|
const raw = String(result.content.api_token ?? '').trim();
|
|
185
193
|
const token = stripTokenPrefix(raw);
|
|
186
194
|
if (!token) {
|
|
187
|
-
throw new TokenUnavailableError('An empty token was submitted. Nothing was stored.');
|
|
195
|
+
throw new TokenUnavailableError('An empty token was submitted. Nothing was stored.', 'declined');
|
|
188
196
|
}
|
|
189
197
|
this.cached = token;
|
|
190
198
|
return token;
|
|
@@ -193,6 +201,7 @@ export class TokenProvider {
|
|
|
193
201
|
export class StaticTokenProvider {
|
|
194
202
|
token;
|
|
195
203
|
unavailableMessage;
|
|
204
|
+
problem;
|
|
196
205
|
used = false;
|
|
197
206
|
/**
|
|
198
207
|
* @param token credential for this request, if the caller found a usable one
|
|
@@ -202,9 +211,10 @@ export class StaticTokenProvider {
|
|
|
202
211
|
* distinction is the whole difference between a developer who can fix their
|
|
203
212
|
* setup and one staring at a generic 401. Defaults to the generic text.
|
|
204
213
|
*/
|
|
205
|
-
constructor(token, unavailableMessage) {
|
|
214
|
+
constructor(token, unavailableMessage, problem = 'absent') {
|
|
206
215
|
this.token = token;
|
|
207
216
|
this.unavailableMessage = unavailableMessage;
|
|
217
|
+
this.problem = problem;
|
|
208
218
|
}
|
|
209
219
|
get current() {
|
|
210
220
|
return this.token;
|
|
@@ -213,7 +223,7 @@ export class StaticTokenProvider {
|
|
|
213
223
|
if (!this.token) {
|
|
214
224
|
throw new TokenUnavailableError(this.unavailableMessage ??
|
|
215
225
|
'No Edgegap API token on this request. Send it as an Authorization ' +
|
|
216
|
-
'header on the MCP connection.');
|
|
226
|
+
'header on the MCP connection.', this.problem);
|
|
217
227
|
}
|
|
218
228
|
return this.token;
|
|
219
229
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one tool call did, for analytics: success, a stable error code, the
|
|
3
|
+
* stage it failed at, the Edgegap API status, and a few tool-specific facts.
|
|
4
|
+
*
|
|
5
|
+
* Built by the tool wrapper in tools.ts and handed to RegisterOptions.onToolCall.
|
|
6
|
+
* Only the hosted Worker passes that hook (worker/telemetry.ts); the local
|
|
7
|
+
* server and the Docker image send nothing. Nothing here does I/O, so the
|
|
8
|
+
* same rules run in Node and in the Worker and are unit-tested directly.
|
|
9
|
+
*
|
|
10
|
+
* Values in `props` must already be safe to send: names, counts, enums.
|
|
11
|
+
* Values in `hash` are raw identifiers (a deployment request_id) that the
|
|
12
|
+
* telemetry side hashes before sending; they never leave the Worker as-is.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_MESSAGE = 300;
|
|
15
|
+
/**
|
|
16
|
+
* Error text made safe to send: the API token and anything shaped like a
|
|
17
|
+
* credential or an identifier is masked, then it is cut to 300 characters.
|
|
18
|
+
* The tool layer already strips the session's own token; this is the second
|
|
19
|
+
* net, for registry tokens, other UUIDs, JWTs, IPs and long opaque strings.
|
|
20
|
+
*/
|
|
21
|
+
export function sanitizeErrorMessage(text, token, args) {
|
|
22
|
+
if (!text)
|
|
23
|
+
return undefined;
|
|
24
|
+
let out = text;
|
|
25
|
+
if (token && token.length >= 8) {
|
|
26
|
+
for (const needle of [token, token.replace(/-/g, '')]) {
|
|
27
|
+
if (needle.length >= 8)
|
|
28
|
+
out = out.split(needle).join('***');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// The call's own argument values (application and image names, IPs, env
|
|
32
|
+
// values) are the developer's data: replaced by the argument's name.
|
|
33
|
+
for (const [name, value] of argumentStrings(args)) {
|
|
34
|
+
out = out.split(value).join(`<${name}>`);
|
|
35
|
+
}
|
|
36
|
+
out = out
|
|
37
|
+
// "[api.edgegap.com]" host label and "NOTE: ..." first-use notices add nothing.
|
|
38
|
+
.replace(/^\[[^\]\n]+\]\n?/, '')
|
|
39
|
+
.replace(/\n*NOTE: [\s\S]*$/, '')
|
|
40
|
+
.replace(/\b(eyJ[\w-]+\.[\w-]+\.[\w-]+)/g, '***')
|
|
41
|
+
.replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi, '***')
|
|
42
|
+
.replace(/((?:token|password|secret|api[_-]?key|authorization)["']?\s*[:=]\s*["']?)[^\s"',}]+/gi, '$1***')
|
|
43
|
+
.replace(/\b\d{1,3}(?:\.\d{1,3}){3}\b/g, '<ip>')
|
|
44
|
+
.replace(/\b[A-Za-z0-9+/_$-]{32,}={0,2}/g, '***')
|
|
45
|
+
.trim();
|
|
46
|
+
return out.length > MAX_MESSAGE ? `${out.slice(0, MAX_MESSAGE - 1)}…` : out;
|
|
47
|
+
}
|
|
48
|
+
/** Every string value in a call's arguments, longest first, with its top-level name. */
|
|
49
|
+
function argumentStrings(args) {
|
|
50
|
+
const out = [];
|
|
51
|
+
const walk = (name, v) => {
|
|
52
|
+
if (typeof v === 'string') {
|
|
53
|
+
if (v.trim().length >= 3)
|
|
54
|
+
out.push([name, v]);
|
|
55
|
+
}
|
|
56
|
+
else if (Array.isArray(v)) {
|
|
57
|
+
for (const x of v)
|
|
58
|
+
walk(name, x);
|
|
59
|
+
}
|
|
60
|
+
else if (v && typeof v === 'object') {
|
|
61
|
+
for (const x of Object.values(v))
|
|
62
|
+
walk(name, x);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
for (const [k, v] of Object.entries(args ?? {}))
|
|
66
|
+
walk(k, v);
|
|
67
|
+
return out.sort((a, b) => b[1].length - a[1].length);
|
|
68
|
+
}
|
|
69
|
+
/** The error code for an Edgegap API status, given what the tool was looking for. */
|
|
70
|
+
export function codeForStatus(status, notFound, forbidden, message = '') {
|
|
71
|
+
if (/quota|limit reached|exceed|upgrade your plan|plan limit/i.test(message) && [400, 402, 403, 429].includes(status)) {
|
|
72
|
+
return 'QUOTA_REACHED';
|
|
73
|
+
}
|
|
74
|
+
switch (status) {
|
|
75
|
+
case 400:
|
|
76
|
+
return notFound === 'DEPLOYMENT_NOT_FOUND' || notFound === 'LOGS_NOT_FOUND' ? notFound : 'UPSTREAM_REJECTED';
|
|
77
|
+
case 401:
|
|
78
|
+
return 'AUTH_REJECTED';
|
|
79
|
+
case 403:
|
|
80
|
+
return forbidden ?? 'FORBIDDEN';
|
|
81
|
+
case 404:
|
|
82
|
+
return notFound ?? 'NOT_FOUND';
|
|
83
|
+
case 409:
|
|
84
|
+
return 'CONFLICT';
|
|
85
|
+
case 422:
|
|
86
|
+
return 'NO_CAPACITY';
|
|
87
|
+
case 424:
|
|
88
|
+
return 'IMAGE_PULL_FAILED';
|
|
89
|
+
case 429:
|
|
90
|
+
return 'RATE_LIMITED';
|
|
91
|
+
default:
|
|
92
|
+
return status >= 500 ? 'UPSTREAM_ERROR' : 'UPSTREAM_REJECTED';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** The code for a tool's own refusal, read from its wording. */
|
|
96
|
+
export function codeForToolFailure(text) {
|
|
97
|
+
if (/^Refused|refused/.test(text))
|
|
98
|
+
return 'GUARDRAIL_REFUSED';
|
|
99
|
+
if (/No skill named|is not a file in the/.test(text))
|
|
100
|
+
return 'SKILL_NOT_FOUND';
|
|
101
|
+
if (/^Invalid arguments|Input validation error/.test(text))
|
|
102
|
+
return 'VALIDATION_FAILED';
|
|
103
|
+
return 'VALIDATION_FAILED';
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Fills in what the tool did not say itself: the code from the API status or
|
|
107
|
+
* the wording, and the stage from whether, and how, the API was called.
|
|
108
|
+
*/
|
|
109
|
+
export function finishReport(input) {
|
|
110
|
+
const { meta = {}, upstream } = input;
|
|
111
|
+
const statuses = upstream.filter((u) => typeof u === 'number');
|
|
112
|
+
const last = upstream[upstream.length - 1];
|
|
113
|
+
const failedUpstream = upstream.find((u) => typeof u !== 'number' || u >= 400);
|
|
114
|
+
let code = meta.code;
|
|
115
|
+
let stage = meta.stage;
|
|
116
|
+
if (input.isError) {
|
|
117
|
+
if (!code) {
|
|
118
|
+
if (last === 'timeout')
|
|
119
|
+
code = 'TIMEOUT';
|
|
120
|
+
else if (last === 'network')
|
|
121
|
+
code = 'NETWORK';
|
|
122
|
+
else if (typeof failedUpstream === 'number')
|
|
123
|
+
code = codeForStatus(failedUpstream, undefined, undefined, input.text);
|
|
124
|
+
else
|
|
125
|
+
code = codeForToolFailure(input.text);
|
|
126
|
+
}
|
|
127
|
+
if (!stage) {
|
|
128
|
+
if (code.startsWith('AUTH_') && code !== 'AUTH_REJECTED')
|
|
129
|
+
stage = 'pre_flight';
|
|
130
|
+
else if (failedUpstream !== undefined)
|
|
131
|
+
stage = 'upstream';
|
|
132
|
+
else
|
|
133
|
+
stage = upstream.length ? 'post_process' : 'pre_flight';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const props = {};
|
|
137
|
+
for (const [k, v] of Object.entries(meta.props ?? {}))
|
|
138
|
+
if (v !== undefined)
|
|
139
|
+
props[k] = v;
|
|
140
|
+
const hash = {};
|
|
141
|
+
for (const [k, v] of Object.entries(meta.hash ?? {}))
|
|
142
|
+
if (v)
|
|
143
|
+
hash[k] = v;
|
|
144
|
+
return {
|
|
145
|
+
tool: input.tool,
|
|
146
|
+
requestId: input.requestId,
|
|
147
|
+
success: !input.isError,
|
|
148
|
+
...(input.isError ? { error_code: code, error_message: sanitizeErrorMessage(input.text, input.token, input.args), failed_stage: stage } : {}),
|
|
149
|
+
upstream_status: statuses.length ? statuses[statuses.length - 1] : null,
|
|
150
|
+
upstream_calls: upstream.length,
|
|
151
|
+
latency_ms: input.latencyMs,
|
|
152
|
+
...(input.dryRun ? { dry_run: true } : {}),
|
|
153
|
+
props,
|
|
154
|
+
hash,
|
|
155
|
+
milestones: input.isError ? [] : [...new Set(meta.milestones ?? [])],
|
|
156
|
+
};
|
|
157
|
+
}
|
package/dist/client.js
CHANGED
|
@@ -45,6 +45,12 @@ export class EdgegapClient {
|
|
|
45
45
|
config;
|
|
46
46
|
auth;
|
|
47
47
|
options;
|
|
48
|
+
/**
|
|
49
|
+
* Every Edgegap API response this client has seen, in order: the HTTP
|
|
50
|
+
* status, or "timeout"/"network". The tool wrapper reads the entries a call
|
|
51
|
+
* added to report what the API said. Statuses only, never bodies.
|
|
52
|
+
*/
|
|
53
|
+
upstream = [];
|
|
48
54
|
constructor(config, auth, options = {}) {
|
|
49
55
|
this.config = config;
|
|
50
56
|
this.auth = auth;
|
|
@@ -110,13 +116,16 @@ export class EdgegapClient {
|
|
|
110
116
|
}
|
|
111
117
|
catch (err) {
|
|
112
118
|
if (err instanceof Error && err.name === 'AbortError') {
|
|
119
|
+
this.upstream.push('timeout');
|
|
113
120
|
throw new Error(`Request to ${method} ${path} timed out after ${this.config.requestTimeoutMs}ms.`);
|
|
114
121
|
}
|
|
122
|
+
this.upstream.push('network');
|
|
115
123
|
throw new Error(redact(`Network error calling ${method} ${path}: ${err.message}`, token));
|
|
116
124
|
}
|
|
117
125
|
finally {
|
|
118
126
|
clearTimeout(timer);
|
|
119
127
|
}
|
|
128
|
+
this.upstream.push(response.status);
|
|
120
129
|
const raw = await response.text();
|
|
121
130
|
let parsed = undefined;
|
|
122
131
|
if (raw) {
|
package/dist/hosted.js
CHANGED
|
@@ -45,7 +45,10 @@ export function extractToken(header) {
|
|
|
45
45
|
* rather than pointing at docs.
|
|
46
46
|
*/
|
|
47
47
|
export function unavailableMessage(problem) {
|
|
48
|
-
const common = `Get a token at ${TOKEN_URL}
|
|
48
|
+
const common = `Get a token at ${TOKEN_URL} (no Edgegap account yet? Sign up free at https://app.edgegap.com). ` +
|
|
49
|
+
'Until then, edgegap_context, edgegap_list_skills, edgegap_get_skill, edgegap_generate_dockerfile and ' +
|
|
50
|
+
'edgegap_validate_server_config work without one, so you can prepare the server build first.\n\n' +
|
|
51
|
+
'The token is used for the request and discarded — ' +
|
|
49
52
|
'never stored. Edgegap tokens are organization-wide and cannot be scoped, ' +
|
|
50
53
|
'so prefer the local server (npx -y @edgegap/mcp), which keeps the token ' +
|
|
51
54
|
'on your own machine and never sends it through Edgegap infrastructure.';
|
package/dist/http.js
CHANGED
|
@@ -91,7 +91,7 @@ function main() {
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
const { token, problem } = extractToken(req.headers.authorization);
|
|
94
|
-
const auth = new StaticTokenProvider(token, problem ? unavailableMessage(problem) : undefined);
|
|
94
|
+
const auth = new StaticTokenProvider(token, problem ? unavailableMessage(problem) : undefined, problem);
|
|
95
95
|
const server = new McpServer({ name: 'edgegap', version: VERSION }, { instructions: serverInstructions('hosted') });
|
|
96
96
|
const client = new EdgegapClient(config, auth, {
|
|
97
97
|
clientName: () => server.server.getClientVersion()?.name,
|