agent-gateway-mcp 0.1.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 +303 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +272 -0
- package/dist/auth.js.map +1 -0
- package/dist/caller.d.ts +9 -0
- package/dist/caller.d.ts.map +1 -0
- package/dist/caller.js +110 -0
- package/dist/caller.js.map +1 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +288 -0
- package/dist/config.js.map +1 -0
- package/dist/discovery.d.ts +6 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +97 -0
- package/dist/discovery.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +509 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +3 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +206 -0
- package/dist/init.js.map +1 -0
- package/dist/types.d.ts +143 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +27 -0
- package/src/auth.ts +329 -0
- package/src/caller.ts +130 -0
- package/src/config.ts +340 -0
- package/src/discovery.ts +144 -0
- package/src/index.ts +610 -0
- package/src/init.ts +254 -0
- package/src/types.ts +165 -0
- package/tsconfig.json +19 -0
package/dist/init.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import http from "http";
|
|
3
|
+
import { loadConfig, storeIdentity, isInitialized, getIdentity, syncTokensFromCloud, setRegistryUrl, } from "./config.js";
|
|
4
|
+
const IDENTITY_PROVIDERS = {
|
|
5
|
+
google: "Google",
|
|
6
|
+
github: "GitHub",
|
|
7
|
+
microsoft: "Microsoft",
|
|
8
|
+
};
|
|
9
|
+
function parseArgs() {
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const opts = {};
|
|
12
|
+
for (let i = 0; i < args.length; i++) {
|
|
13
|
+
if (args[i] === "--registry" && args[i + 1]) {
|
|
14
|
+
opts.registry = args[i + 1];
|
|
15
|
+
i++;
|
|
16
|
+
}
|
|
17
|
+
if (args[i] === "--provider" && args[i + 1]) {
|
|
18
|
+
opts.provider = args[i + 1];
|
|
19
|
+
i++;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return opts;
|
|
23
|
+
}
|
|
24
|
+
async function init() {
|
|
25
|
+
const opts = parseArgs();
|
|
26
|
+
if (opts.registry) {
|
|
27
|
+
setRegistryUrl(opts.registry);
|
|
28
|
+
}
|
|
29
|
+
const config = loadConfig();
|
|
30
|
+
const registryUrl = config.registry_url;
|
|
31
|
+
console.log("");
|
|
32
|
+
console.log(" ╔══════════════════════════════════════╗");
|
|
33
|
+
console.log(" ║ Agent Gateway — Setup ║");
|
|
34
|
+
console.log(" ╚══════════════════════════════════════╝");
|
|
35
|
+
console.log("");
|
|
36
|
+
if (isInitialized()) {
|
|
37
|
+
const identity = getIdentity();
|
|
38
|
+
console.log(` Already signed in as ${identity.email} (${identity.provider})`);
|
|
39
|
+
console.log("");
|
|
40
|
+
// Sync connections
|
|
41
|
+
console.log(" Syncing connections from cloud...");
|
|
42
|
+
const sync = await syncTokensFromCloud();
|
|
43
|
+
if (sync.success) {
|
|
44
|
+
console.log(` Synced ${sync.count} new connection(s).`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(` Sync skipped: ${sync.error}`);
|
|
48
|
+
}
|
|
49
|
+
console.log("");
|
|
50
|
+
console.log(" You're all set! Your agent can now use the gateway.");
|
|
51
|
+
console.log("");
|
|
52
|
+
printMcpConfig(registryUrl);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Determine provider
|
|
56
|
+
const provider = opts.provider ?? "google";
|
|
57
|
+
const providerName = IDENTITY_PROVIDERS[provider] ?? provider;
|
|
58
|
+
console.log(` Signing in with ${providerName}...`);
|
|
59
|
+
console.log("");
|
|
60
|
+
// Start OAuth flow with registry
|
|
61
|
+
const port = config.auth_callback_port;
|
|
62
|
+
const redirectUri = `http://localhost:${port}/callback`;
|
|
63
|
+
const state = Math.random().toString(36).substring(2, 15);
|
|
64
|
+
const authUrl = `${registryUrl}/auth/init?provider=${provider}&redirect_uri=${encodeURIComponent(redirectUri)}&state=${state}`;
|
|
65
|
+
// Start local callback server
|
|
66
|
+
const identityPromise = new Promise((resolve, reject) => {
|
|
67
|
+
const timeout = setTimeout(() => {
|
|
68
|
+
server.close();
|
|
69
|
+
reject(new Error("Authentication timeout — no callback received within 120 seconds."));
|
|
70
|
+
}, 120000);
|
|
71
|
+
const server = http.createServer(async (req, res) => {
|
|
72
|
+
const url = new URL(req.url ?? "/", `http://localhost:${port}`);
|
|
73
|
+
if (url.pathname !== "/callback") {
|
|
74
|
+
res.writeHead(404);
|
|
75
|
+
res.end("Not found");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const error = url.searchParams.get("error");
|
|
79
|
+
if (error) {
|
|
80
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
81
|
+
res.end(html("Authentication Failed", `<p>${error}</p><p>You can close this tab.</p>`));
|
|
82
|
+
clearTimeout(timeout);
|
|
83
|
+
server.close();
|
|
84
|
+
reject(new Error(`Auth error: ${error}`));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const returnedState = url.searchParams.get("state");
|
|
88
|
+
if (returnedState !== state) {
|
|
89
|
+
res.writeHead(400, { "Content-Type": "text/html" });
|
|
90
|
+
res.end(html("Invalid Callback", "<p>State mismatch. Please try again.</p>"));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Registry returns identity data in the callback
|
|
94
|
+
const registryToken = url.searchParams.get("token");
|
|
95
|
+
const refreshToken = url.searchParams.get("refresh_token");
|
|
96
|
+
const email = url.searchParams.get("email");
|
|
97
|
+
const name = url.searchParams.get("name");
|
|
98
|
+
const providerId = url.searchParams.get("provider_id");
|
|
99
|
+
if (!registryToken || !email || !providerId) {
|
|
100
|
+
res.writeHead(400, { "Content-Type": "text/html" });
|
|
101
|
+
res.end(html("Invalid Callback", "<p>Missing authentication data. Please try again.</p>"));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const identity = {
|
|
105
|
+
provider,
|
|
106
|
+
provider_id: providerId,
|
|
107
|
+
email,
|
|
108
|
+
name: name ?? undefined,
|
|
109
|
+
registry_token: registryToken,
|
|
110
|
+
registry_refresh_token: refreshToken ?? undefined,
|
|
111
|
+
connected_at: new Date().toISOString(),
|
|
112
|
+
};
|
|
113
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
114
|
+
res.end(html("Connected to Agent Gateway!", `<p>Signed in as <strong>${email}</strong></p><p>You can close this tab and return to your terminal.</p>`));
|
|
115
|
+
clearTimeout(timeout);
|
|
116
|
+
server.close();
|
|
117
|
+
resolve(identity);
|
|
118
|
+
});
|
|
119
|
+
server.listen(port, () => {
|
|
120
|
+
// Server ready
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
// Open browser
|
|
124
|
+
try {
|
|
125
|
+
const open = (await import("open")).default;
|
|
126
|
+
await open(authUrl);
|
|
127
|
+
console.log(" Browser opened for sign-in.");
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
console.log(` Open this URL in your browser:`);
|
|
131
|
+
console.log("");
|
|
132
|
+
console.log(` ${authUrl}`);
|
|
133
|
+
}
|
|
134
|
+
console.log("");
|
|
135
|
+
console.log(` Waiting for sign-in on http://localhost:${port}/callback...`);
|
|
136
|
+
console.log("");
|
|
137
|
+
try {
|
|
138
|
+
const identity = await identityPromise;
|
|
139
|
+
storeIdentity(identity);
|
|
140
|
+
console.log(` Signed in as ${identity.email}`);
|
|
141
|
+
console.log("");
|
|
142
|
+
// Sync existing connections from cloud
|
|
143
|
+
console.log(" Syncing connections from cloud...");
|
|
144
|
+
const sync = await syncTokensFromCloud();
|
|
145
|
+
if (sync.success) {
|
|
146
|
+
if (sync.count > 0) {
|
|
147
|
+
console.log(` Restored ${sync.count} connection(s) from your account.`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
console.log(" No existing connections found. Start fresh!");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
console.log(" Cloud sync skipped (will retry on next run).");
|
|
155
|
+
}
|
|
156
|
+
console.log("");
|
|
157
|
+
console.log(" Setup complete! Add this to your MCP client config:");
|
|
158
|
+
console.log("");
|
|
159
|
+
printMcpConfig(registryUrl);
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
console.error(` Setup failed: ${err instanceof Error ? err.message : "unknown error"}`);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function printMcpConfig(registryUrl) {
|
|
167
|
+
const config = {
|
|
168
|
+
mcpServers: {
|
|
169
|
+
gateway: {
|
|
170
|
+
command: "agent-gateway-mcp",
|
|
171
|
+
args: registryUrl !== "https://agentdns.dev"
|
|
172
|
+
? ["--registry", registryUrl]
|
|
173
|
+
: [],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
console.log(" " + JSON.stringify(config, null, 2).split("\n").join("\n "));
|
|
178
|
+
console.log("");
|
|
179
|
+
}
|
|
180
|
+
function html(title, body) {
|
|
181
|
+
return `<!DOCTYPE html>
|
|
182
|
+
<html>
|
|
183
|
+
<head>
|
|
184
|
+
<meta charset="utf-8">
|
|
185
|
+
<title>${title}</title>
|
|
186
|
+
<style>
|
|
187
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; background: #0a0a0a; color: #e5e5e5; }
|
|
188
|
+
.card { text-align: center; padding: 3rem; border: 1px solid #262626; border-radius: 12px; background: #171717; max-width: 400px; }
|
|
189
|
+
h2 { color: #10b981; margin-bottom: 1rem; }
|
|
190
|
+
p { color: #a3a3a3; line-height: 1.6; }
|
|
191
|
+
strong { color: #e5e5e5; }
|
|
192
|
+
</style>
|
|
193
|
+
</head>
|
|
194
|
+
<body>
|
|
195
|
+
<div class="card">
|
|
196
|
+
<h2>${title}</h2>
|
|
197
|
+
${body}
|
|
198
|
+
</div>
|
|
199
|
+
</body>
|
|
200
|
+
</html>`;
|
|
201
|
+
}
|
|
202
|
+
init().catch((err) => {
|
|
203
|
+
console.error(`Fatal error: ${err}`);
|
|
204
|
+
process.exit(1);
|
|
205
|
+
});
|
|
206
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,UAAU,EAEV,aAAa,EACb,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,MAAM,kBAAkB,GAAqC;IAC3D,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;CACvB,CAAC;AAOF,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,IAAI,GAAgB,EAAE,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,YAAY,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5B,CAAC,EAAE,CAAC;QACN,CAAC;QACD,IAAI,IAAI,CA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AAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export interface ManifestCapability {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
detail_url: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ManifestAuth {
|
|
7
|
+
type: "oauth2" | "api_key" | "none";
|
|
8
|
+
authorization_url?: string;
|
|
9
|
+
token_url?: string;
|
|
10
|
+
scopes?: string[];
|
|
11
|
+
header?: string;
|
|
12
|
+
prefix?: string;
|
|
13
|
+
setup_url?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ManifestPricing {
|
|
16
|
+
type: "free" | "freemium" | "paid";
|
|
17
|
+
plans?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
price: string;
|
|
20
|
+
limits: string;
|
|
21
|
+
}>;
|
|
22
|
+
plans_url?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface Manifest {
|
|
25
|
+
spec_version: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
base_url: string;
|
|
29
|
+
auth: ManifestAuth;
|
|
30
|
+
pricing?: ManifestPricing;
|
|
31
|
+
capabilities: ManifestCapability[];
|
|
32
|
+
}
|
|
33
|
+
export interface CapabilityDetail {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
endpoint: string;
|
|
37
|
+
method: string;
|
|
38
|
+
parameters: Array<{
|
|
39
|
+
name: string;
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
required: boolean;
|
|
43
|
+
example: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
request_example: {
|
|
46
|
+
method: string;
|
|
47
|
+
url: string;
|
|
48
|
+
headers: Record<string, string>;
|
|
49
|
+
body?: unknown;
|
|
50
|
+
};
|
|
51
|
+
response_example: {
|
|
52
|
+
status: number;
|
|
53
|
+
body: unknown;
|
|
54
|
+
};
|
|
55
|
+
auth_scopes?: string[];
|
|
56
|
+
rate_limits?: {
|
|
57
|
+
requests_per_minute?: number;
|
|
58
|
+
daily_limit?: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export type IdentityProvider = "google" | "github" | "microsoft";
|
|
62
|
+
export interface UserIdentity {
|
|
63
|
+
provider: IdentityProvider;
|
|
64
|
+
provider_id: string;
|
|
65
|
+
email: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
avatar_url?: string;
|
|
68
|
+
registry_token: string;
|
|
69
|
+
registry_refresh_token?: string;
|
|
70
|
+
connected_at: string;
|
|
71
|
+
}
|
|
72
|
+
export interface StoredToken {
|
|
73
|
+
domain: string;
|
|
74
|
+
type: "oauth2" | "api_key";
|
|
75
|
+
access_token: string;
|
|
76
|
+
refresh_token?: string;
|
|
77
|
+
expires_at?: number;
|
|
78
|
+
scopes?: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface Connection {
|
|
81
|
+
domain: string;
|
|
82
|
+
service_name: string;
|
|
83
|
+
auth_type: string;
|
|
84
|
+
token?: StoredToken;
|
|
85
|
+
subscription?: {
|
|
86
|
+
plan: string;
|
|
87
|
+
status: "active" | "cancelled";
|
|
88
|
+
};
|
|
89
|
+
connected_at: string;
|
|
90
|
+
}
|
|
91
|
+
export interface CloudSyncState {
|
|
92
|
+
last_synced_at?: string;
|
|
93
|
+
sync_token?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface CloudTokenBundle {
|
|
96
|
+
tokens: Record<string, StoredToken>;
|
|
97
|
+
connections: Record<string, Connection>;
|
|
98
|
+
synced_at: string;
|
|
99
|
+
}
|
|
100
|
+
export interface CacheEntry<T> {
|
|
101
|
+
data: T;
|
|
102
|
+
cached_at: number;
|
|
103
|
+
ttl: number;
|
|
104
|
+
}
|
|
105
|
+
export declare const CACHE_TTLS: {
|
|
106
|
+
readonly manifest: number;
|
|
107
|
+
readonly capability: number;
|
|
108
|
+
readonly discovery: number;
|
|
109
|
+
};
|
|
110
|
+
export interface GatewayConfig {
|
|
111
|
+
registry_url: string;
|
|
112
|
+
auth_callback_port: number;
|
|
113
|
+
identity?: UserIdentity;
|
|
114
|
+
cloud_sync?: CloudSyncState;
|
|
115
|
+
}
|
|
116
|
+
export interface DiscoverResult {
|
|
117
|
+
service: {
|
|
118
|
+
name: string;
|
|
119
|
+
domain: string;
|
|
120
|
+
description: string;
|
|
121
|
+
base_url: string;
|
|
122
|
+
auth_type: string;
|
|
123
|
+
pricing_type: string;
|
|
124
|
+
verified: boolean;
|
|
125
|
+
};
|
|
126
|
+
matching_capabilities: Array<{
|
|
127
|
+
name: string;
|
|
128
|
+
description: string;
|
|
129
|
+
detail_url: string;
|
|
130
|
+
}>;
|
|
131
|
+
all_capabilities: Array<{
|
|
132
|
+
name: string;
|
|
133
|
+
description: string;
|
|
134
|
+
detail_url: string;
|
|
135
|
+
}>;
|
|
136
|
+
}
|
|
137
|
+
export interface RegistryDiscoverResponse {
|
|
138
|
+
success: boolean;
|
|
139
|
+
query: string;
|
|
140
|
+
result_count: number;
|
|
141
|
+
data: DiscoverResult[];
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM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,GAAG;IACxB,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAI,WAAW;IAC5C,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAQ,SAAS;IAC3C,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAS,aAAa;CACvC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-gateway-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The only MCP server you need. One gateway to discover and use any API.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agent-gateway-mcp": "./dist/index.js",
|
|
8
|
+
"agent-gateway": "./dist/init.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"init": "node dist/init.js"
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["mcp", "agent", "discovery", "gateway", "ai", "agent-gateway"],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
20
|
+
"node-fetch": "^3.3.2",
|
|
21
|
+
"open": "^11.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^25.3.2",
|
|
25
|
+
"typescript": "^5.9.3"
|
|
26
|
+
}
|
|
27
|
+
}
|