@rbbtsn0w/adg 0.7.1-beta.3 → 0.7.1-beta.5
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { isExposed } from "../components.js";
|
|
4
|
-
import { mcpConfigPath } from "../mcp.js";
|
|
4
|
+
import { extractMcpServers, mcpConfigPath } from "../mcp.js";
|
|
5
5
|
export const ANTIGRAVITY_MCP_CONFIG = "mcp_config.json";
|
|
6
6
|
const ANTIGRAVITY_MCP_SERVER_KEYS = new Set([
|
|
7
7
|
"command",
|
|
@@ -40,15 +40,12 @@ function toAntigravityMcpConfig(source) {
|
|
|
40
40
|
const parsed = JSON.parse(readFileSync(source, "utf8"));
|
|
41
41
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
42
42
|
return parsed;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return config;
|
|
43
|
+
const servers = extractMcpServers(parsed);
|
|
44
|
+
if (!servers)
|
|
45
|
+
return parsed;
|
|
47
46
|
const projected = {
|
|
48
|
-
...config,
|
|
49
47
|
mcpServers: {},
|
|
50
48
|
};
|
|
51
|
-
delete projected.servers;
|
|
52
49
|
for (const [name, value] of Object.entries(servers)) {
|
|
53
50
|
projected.mcpServers[name] = toAntigravityMcpServer(value);
|
|
54
51
|
}
|
package/dist/src/components.js
CHANGED
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
|
2
2
|
import { basename, join } from "node:path";
|
|
3
3
|
import { resolveSkills } from "./skills.js";
|
|
4
4
|
import { COMPONENT_TYPES } from "./types.js";
|
|
5
|
-
import { mcpConfigPath } from "./mcp.js";
|
|
5
|
+
import { extractMcpServers, mcpConfigPath } from "./mcp.js";
|
|
6
6
|
export { COMPONENT_TYPES };
|
|
7
7
|
/** Recursively collect regular (non-dotfile) file basenames, without extension. */
|
|
8
8
|
function collectFiles(dir) {
|
|
@@ -39,14 +39,14 @@ function membersOf(dir, rel) {
|
|
|
39
39
|
return files;
|
|
40
40
|
return [fileMemberName(abs)]; // a single file
|
|
41
41
|
}
|
|
42
|
-
/** Server names declared in an MCP config file (mcpServers/servers map). */
|
|
42
|
+
/** Server names declared in an MCP config file (mcpServers/servers map or flat map). */
|
|
43
43
|
function mcpServers(file) {
|
|
44
44
|
if (!existsSync(file))
|
|
45
45
|
return [];
|
|
46
46
|
try {
|
|
47
47
|
const json = JSON.parse(readFileSync(file, "utf8"));
|
|
48
|
-
const servers = (json
|
|
49
|
-
return servers
|
|
48
|
+
const servers = extractMcpServers(json);
|
|
49
|
+
return servers ? Object.keys(servers).sort() : [];
|
|
50
50
|
}
|
|
51
51
|
catch {
|
|
52
52
|
return [];
|
package/dist/src/default-dsl.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { ADG_SCHEMA_VERSION } from "./types.js";
|
|
5
|
+
import { extractMcpServers } from "./mcp.js";
|
|
5
6
|
import { readSkillDescription } from "./skills.js";
|
|
6
7
|
import { recordTelemetryEvent } from "./telemetry.js";
|
|
7
8
|
/** Convert a repository directory name into the manifest's stable kebab-case identity. */
|
|
@@ -121,11 +122,13 @@ function isRegularFile(path) {
|
|
|
121
122
|
function validMcp(file) {
|
|
122
123
|
if (!validJson(file))
|
|
123
124
|
return false;
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
try {
|
|
126
|
+
const json = JSON.parse(readFileSync(file, "utf8"));
|
|
127
|
+
return extractMcpServers(json) !== undefined;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
126
130
|
return false;
|
|
127
|
-
|
|
128
|
-
return typeof servers === "object" && servers !== null && !Array.isArray(servers);
|
|
131
|
+
}
|
|
129
132
|
}
|
|
130
133
|
function hashTree(hasher, dir, rel) {
|
|
131
134
|
for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
package/dist/src/mcp.js
CHANGED
|
@@ -3,31 +3,52 @@ import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
|
3
3
|
export function mcpConfigPath(manifest) {
|
|
4
4
|
return manifest.mcpServers;
|
|
5
5
|
}
|
|
6
|
+
const MCP_SERVER_DISCRIMINATOR_KEYS = new Set([
|
|
7
|
+
"command",
|
|
8
|
+
"url",
|
|
9
|
+
"serverUrl",
|
|
10
|
+
"type",
|
|
11
|
+
"args",
|
|
12
|
+
"env",
|
|
13
|
+
"headers",
|
|
14
|
+
"http_headers",
|
|
15
|
+
"cwd",
|
|
16
|
+
]);
|
|
17
|
+
function isMcpServerConfig(val) {
|
|
18
|
+
if (val === null || typeof val !== "object" || Array.isArray(val))
|
|
19
|
+
return false;
|
|
20
|
+
const obj = val;
|
|
21
|
+
return Object.keys(obj).some((k) => MCP_SERVER_DISCRIMINATOR_KEYS.has(k));
|
|
22
|
+
}
|
|
23
|
+
/** Extract the MCP servers map from canonical, legacy, or flat server map roots. */
|
|
24
|
+
export function extractMcpServers(json) {
|
|
25
|
+
if (json === null || typeof json !== "object" || Array.isArray(json))
|
|
26
|
+
return undefined;
|
|
27
|
+
const obj = json;
|
|
28
|
+
const servers = obj.mcpServers ?? obj.servers;
|
|
29
|
+
if (servers && typeof servers === "object" && !Array.isArray(servers)) {
|
|
30
|
+
return servers;
|
|
31
|
+
}
|
|
32
|
+
const keys = Object.keys(obj);
|
|
33
|
+
if (keys.length > 0) {
|
|
34
|
+
const isServerMap = keys.every((k) => isMcpServerConfig(obj[k]));
|
|
35
|
+
if (isServerMap)
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
6
40
|
/** Filter the servers defined in the MCP config file. */
|
|
7
41
|
export function filterMcpConfig(file, allowedNames) {
|
|
8
42
|
if (!existsSync(file))
|
|
9
43
|
return;
|
|
10
44
|
try {
|
|
11
45
|
const json = JSON.parse(readFileSync(file, "utf8"));
|
|
12
|
-
|
|
46
|
+
const servers = extractMcpServers(json);
|
|
47
|
+
if (!servers) {
|
|
13
48
|
throw new Error("MCP config root must be an object");
|
|
14
49
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let hasMcpServersOrServers = false;
|
|
18
|
-
for (const key of ["mcpServers", "servers"]) {
|
|
19
|
-
const servers = json[key];
|
|
20
|
-
if (servers !== undefined) {
|
|
21
|
-
if (typeof servers !== "object" || servers === null || Array.isArray(servers)) {
|
|
22
|
-
throw new Error(`MCP config "${key}" must be an object`);
|
|
23
|
-
}
|
|
24
|
-
hasMcpServersOrServers = true;
|
|
25
|
-
for (const name of Object.keys(servers)) {
|
|
26
|
-
definedNames.add(name);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (allowedNames.length > 0 && !hasMcpServersOrServers) {
|
|
50
|
+
const definedNames = new Set(Object.keys(servers));
|
|
51
|
+
if (allowedNames.length > 0 && definedNames.size === 0) {
|
|
31
52
|
throw new Error("MCP config does not define any servers");
|
|
32
53
|
}
|
|
33
54
|
const missing = allowedNames.filter((name) => !definedNames.has(name));
|
|
@@ -35,24 +56,31 @@ export function filterMcpConfig(file, allowedNames) {
|
|
|
35
56
|
throw new Error(`selected mcp server(s) not declared: ${missing.join(", ")}`);
|
|
36
57
|
}
|
|
37
58
|
const allowed = new Set(allowedNames);
|
|
59
|
+
const newServers = {};
|
|
38
60
|
let changed = false;
|
|
39
|
-
for (const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (allowed.has(name)) {
|
|
46
|
-
newObj[name] = config;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
changed = true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
json[key] = newObj;
|
|
61
|
+
for (const [name, config] of Object.entries(servers)) {
|
|
62
|
+
if (allowed.has(name)) {
|
|
63
|
+
newServers[name] = config;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
changed = true;
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
69
|
if (changed) {
|
|
70
|
+
const root = json;
|
|
71
|
+
if (root.mcpServers && typeof root.mcpServers === "object") {
|
|
72
|
+
root.mcpServers = newServers;
|
|
73
|
+
}
|
|
74
|
+
else if (root.servers && typeof root.servers === "object") {
|
|
75
|
+
root.servers = newServers;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Flat server map: update in-place
|
|
79
|
+
for (const key of Object.keys(root)) {
|
|
80
|
+
if (!allowed.has(key))
|
|
81
|
+
delete root[key];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
56
84
|
writeFileSync(file, JSON.stringify(json, null, 2), "utf8");
|
|
57
85
|
}
|
|
58
86
|
}
|
|
@@ -79,6 +79,10 @@ plugin root. The ADG adapter materializes files at these conventional locations.
|
|
|
79
79
|
and `disabled_tools` to Antigravity's schema. Unsupported source-runtime fields
|
|
80
80
|
are omitted. If the source IS already `mcp_config.json`, it is treated as a
|
|
81
81
|
native override and left unchanged.
|
|
82
|
+
- **Authentication boundary**: The adapter passes through explicitly authored
|
|
83
|
+
native `oauth` configuration, but never synthesizes OAuth client credentials or
|
|
84
|
+
overrides Dynamic Client Registration. Compatibility workarounds belong in the
|
|
85
|
+
authored MCP transport (for example, a stdio bridge), not in ADG's DSL.
|
|
82
86
|
|
|
83
87
|
---
|
|
84
88
|
|