@abapify/adt-mcp 0.4.15 → 0.4.19
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/dist/bin/adt-mcp-http.mjs +3 -5
- package/dist/bin/adt-mcp-http.mjs.map +1 -1
- package/dist/bin/adt-mcp.mjs +2 -3
- package/dist/index.d.mts +0 -30
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/{server-DcnmjazJ.mjs → server-D2q3SSjJ.mjs} +9 -16
- package/dist/{server-DcnmjazJ.mjs.map → server-D2q3SSjJ.mjs.map} +1 -1
- package/dist/{server-D0-U93Rw.mjs → server-DTLyqZq5.mjs} +115 -229
- package/dist/{server-D0-U93Rw.mjs.map → server-DTLyqZq5.mjs.map} +1 -1
- package/package.json +16 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as startHttpServer } from "../server-
|
|
2
|
+
import { n as startHttpServer } from "../server-D2q3SSjJ.mjs";
|
|
3
3
|
import { loadConfig } from "@abapify/adt-config";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/lib/http/adt-config-loader.ts
|
|
6
6
|
/**
|
|
7
7
|
* adt-config adapter for adt-mcp multi-system registry.
|
|
8
8
|
*
|
|
@@ -94,8 +94,7 @@ async function loadAdtConfigMultiSystem(configPath, cwd) {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
//#region src/bin/adt-mcp-http.ts
|
|
97
|
+
// src/bin/adt-mcp-http.ts
|
|
99
98
|
/**
|
|
100
99
|
* adt-mcp-http — Streamable HTTP entry-point for the MCP server.
|
|
101
100
|
*
|
|
@@ -306,6 +305,5 @@ main().catch((err) => {
|
|
|
306
305
|
process.exit(1);
|
|
307
306
|
});
|
|
308
307
|
|
|
309
|
-
//#endregion
|
|
310
308
|
export { };
|
|
311
309
|
//# sourceMappingURL=adt-mcp-http.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adt-mcp-http.mjs","names":[],"sources":["../../src/lib/http/adt-config-loader.ts","../../src/bin/adt-mcp-http.ts"],"sourcesContent":["/**\n * adt-config adapter for adt-mcp multi-system registry.\n *\n * Loads SAP system definitions from `adt.config.ts` / `adt.config.json`\n * (via `@abapify/adt-config`) and returns a {@link MultiSystemConfig}\n * compatible object that `startHttpServer()` can consume.\n *\n * Only destinations with a resolvable `url` field in their `options`\n * (or the shorthand string URL) are included. Credentials (username /\n * password) are intentionally NOT loaded — they must be supplied at\n * runtime via the `sap_connect` tool call, matching the security policy\n * of the existing multi-system loader.\n */\n\nimport { loadConfig } from '@abapify/adt-config';\nimport type { MultiSystemConfig } from './multi-system.js';\nimport type { ConnectionParams } from '../types.js';\n\n/**\n * Sanitize a URL for safe logging by stripping any embedded credentials\n * (userinfo component) that a user might accidentally include.\n */\nfunction sanitizeUrl(raw: string): string {\n try {\n const u = new URL(raw);\n u.username = '';\n u.password = '';\n return u.toString();\n } catch {\n return '<invalid-url>';\n }\n}\n\n/**\n * Attempt to extract a `baseUrl` from a destination's options object.\n * Handles both `{ url: '...' }` and `{ baseUrl: '...' }` shapes, as\n * different auth plugins use different field names.\n */\nfunction extractBaseUrl(options: unknown): string | undefined {\n if (!options || typeof options !== 'object') return undefined;\n const o = options as Record<string, unknown>;\n if (typeof o.url === 'string' && o.url.length > 0) return o.url;\n if (typeof o.baseUrl === 'string' && o.baseUrl.length > 0) return o.baseUrl;\n return undefined;\n}\n\nfunction extractClient(options: unknown): string | undefined {\n if (!options || typeof options !== 'object') return undefined;\n const o = options as Record<string, unknown>;\n if (typeof o.client === 'string' && o.client.length > 0) return o.client;\n return undefined;\n}\n\n/**\n * Load system definitions from `adt-config` and expose them as a\n * {@link MultiSystemConfig} for the MCP HTTP server.\n *\n * @param configPath Optional explicit path to `adt.config.ts` / `adt.config.json`.\n * When omitted, `@abapify/adt-config` auto-discovers from `cwd`.\n * @param cwd Working directory for auto-discovery. Defaults to `process.cwd()`.\n */\nexport async function loadAdtConfigMultiSystem(\n configPath?: string,\n cwd?: string,\n): Promise<MultiSystemConfig> {\n // Warn when a TypeScript config file is requested but the current runtime\n // is plain Node.js (not Bun). Node cannot `import()` a `.ts` file directly\n // without a loader, so the config would be silently ignored. Bun natively\n // supports TypeScript, so this is only a concern for production Node deployments.\n if (\n configPath?.endsWith('.ts') &&\n typeof (globalThis as Record<string, unknown>).Bun === 'undefined'\n ) {\n throw new Error(\n `ADT_CONFIG_FILE '${configPath}' is TypeScript; plain Node.js cannot load .ts configs. ` +\n `Use adt.config.json, a compiled .mjs config, or run adt-mcp-http with Bun ` +\n `(e.g. bunx nx run adt-mcp:serve).`,\n );\n }\n\n const loaded = await loadConfig({ configPath, cwd });\n const systems: Record<string, { baseUrl: string; client?: string }> = {};\n\n for (const sid of loaded.listDestinations()) {\n const dest = loaded.getDestination(sid);\n if (!dest) continue;\n\n let baseUrl: string | undefined;\n let client: string | undefined;\n\n if (typeof dest === 'string') {\n baseUrl = dest;\n } else {\n baseUrl = extractBaseUrl(dest.options);\n client = extractClient(dest.options);\n }\n\n if (!baseUrl) {\n process.stderr.write(\n `[adt-config-loader] warning: destination '${sid}' has no resolvable URL — skipping.\\n`,\n );\n continue;\n }\n\n systems[sid] = { baseUrl, ...(client ? { client } : {}) };\n process.stderr.write(\n `[adt-config-loader] loaded system '${sid}' → ${sanitizeUrl(baseUrl)}\\n`,\n );\n }\n\n return {\n systems,\n resolve(systemId: string): ConnectionParams | undefined {\n const entry = systems[systemId];\n if (!entry) return undefined;\n return { baseUrl: entry.baseUrl, client: entry.client };\n },\n };\n}\n","#!/usr/bin/env node\n/**\n * adt-mcp-http — Streamable HTTP entry-point for the MCP server.\n *\n * Usage:\n * adt-mcp-http [--port 3000] [--host 127.0.0.1] [--ttl 1800000]\n * [--auth-token <value>] [--trust-forwarded-auth]\n * [--cors-origin <origin>]...\n *\n * Environment:\n * MCP_PORT Listen port (default 3000).\n * MCP_HOST Bind address (default 127.0.0.1).\n * MCP_ALLOWED_HOSTS Comma-separated additional hostnames for the\n * Host-header allowlist.\n * MCP_AUTH_TOKEN Bearer token. Implies --auth-mode=bearer.\n * TRUST_FORWARDED_AUTH Set to \"1\" / \"true\" to enable reverse-proxy\n * (x-forwarded-user) trust mode.\n * MCP_CORS_ORIGIN Comma-separated CORS allow-list.\n * SAP_SYSTEMS_JSON Inline multi-system config as JSON.\n * SAP_SYSTEMS_FILE Path to a multi-system config JSON file.\n * ADT_CONFIG_FILE Path to adt.config.ts/json. When set, system\n * definitions are loaded from adt-config instead\n * of SAP_SYSTEMS_JSON / SAP_SYSTEMS_FILE.\n */\n\nimport { startHttpServer } from '../lib/http/server.js';\nimport type { OAuthOptions } from '../lib/http/oauth.js';\nimport type { MultiSystemConfig } from '../lib/http/multi-system.js';\nimport { loadAdtConfigMultiSystem } from '../lib/http/adt-config-loader.js';\n\ntype AuthMode = 'none' | 'bearer' | 'proxy' | 'oauth';\n\ninterface ParsedArgs {\n port?: number;\n host?: string;\n ttlMs?: number;\n allowedHosts?: string[];\n authToken?: string;\n authMode?: AuthMode;\n trustForwardedAuth?: boolean;\n allowedOrigins?: string[];\n oauthIssuer?: string;\n oauthAudience?: string[];\n oauthJwksUri?: string;\n oauthRequiredScopes?: string[];\n oauthUserClaim?: string;\n adtConfigFile?: string;\n tlsCert?: string;\n tlsKey?: string;\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const out: ParsedArgs = {};\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n const next = () => argv[++i];\n switch (a) {\n case '--port':\n case '-p': {\n const v = Number(next());\n if (Number.isFinite(v)) out.port = v;\n break;\n }\n case '--host':\n case '-H': {\n out.host = next();\n break;\n }\n case '--ttl': {\n const v = Number(next());\n if (Number.isFinite(v)) out.ttlMs = v;\n break;\n }\n case '--allowed-host': {\n const v = next();\n if (v) (out.allowedHosts ??= []).push(v);\n break;\n }\n case '--auth-token': {\n const v = next();\n if (v) {\n out.authToken = v;\n out.authMode = 'bearer';\n }\n break;\n }\n case '--auth-mode': {\n const v = next();\n if (v === 'none' || v === 'bearer' || v === 'proxy' || v === 'oauth') {\n out.authMode = v;\n }\n break;\n }\n case '--trust-forwarded-auth': {\n out.trustForwardedAuth = true;\n out.authMode = 'proxy';\n break;\n }\n case '--oauth-issuer': {\n const v = next();\n if (v) out.oauthIssuer = v;\n break;\n }\n case '--oauth-audience': {\n const v = next();\n if (v) {\n (out.oauthAudience ??= []).push(\n ...v\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0),\n );\n }\n break;\n }\n case '--oauth-jwks-uri': {\n const v = next();\n if (v) out.oauthJwksUri = v;\n break;\n }\n case '--oauth-required-scope': {\n const v = next();\n if (v) {\n (out.oauthRequiredScopes ??= []).push(\n ...v\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0),\n );\n }\n break;\n }\n case '--oauth-user-claim': {\n const v = next();\n if (v) out.oauthUserClaim = v;\n break;\n }\n case '--cors-origin': {\n const v = next();\n if (v) (out.allowedOrigins ??= []).push(v);\n break;\n }\n case '--adt-config': {\n const v = next();\n if (v) out.adtConfigFile = v;\n break;\n }\n case '--tls-cert': {\n const v = next();\n if (v) out.tlsCert = v;\n break;\n }\n case '--tls-key': {\n const v = next();\n if (v) out.tlsKey = v;\n break;\n }\n case '--help':\n case '-h': {\n process.stdout.write(\n 'Usage: adt-mcp-http [--port N] [--host HOST] [--ttl MS]\\n' +\n ' [--allowed-host H ...]\\n' +\n ' [--auth-token TOKEN | --auth-mode MODE]\\n' +\n ' [--trust-forwarded-auth]\\n' +\n ' [--oauth-issuer URL] [--oauth-audience VAL]\\n' +\n ' [--oauth-jwks-uri URL]\\n' +\n ' [--oauth-required-scope SCOPE]\\n' +\n ' [--oauth-user-claim NAME]\\n' +\n ' [--cors-origin ORIGIN ...]\\n' +\n ' [--adt-config PATH]\\n' +\n ' [--tls-cert PATH] [--tls-key PATH]\\n',\n );\n process.exit(0);\n }\n // eslint-disable-next-line no-fallthrough\n default:\n // Unknown flag — ignore for forward compatibility.\n break;\n }\n }\n return out;\n}\n\nfunction isTruthyEnv(v: string | undefined): boolean {\n if (!v) return false;\n return ['1', 'true', 'yes', 'on'].includes(v.toLowerCase());\n}\n\nfunction parseCsvEnv(v: string | undefined): string[] {\n if (!v) return [];\n return v\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\nasync function main(): Promise<void> {\n const args = parseArgs(process.argv.slice(2));\n const envAllowed = parseCsvEnv(process.env.MCP_ALLOWED_HOSTS);\n const envCorsOrigins = parseCsvEnv(process.env.MCP_CORS_ORIGIN);\n const envTrustForwarded = isTruthyEnv(process.env.TRUST_FORWARDED_AUTH);\n\n // CLI flag takes precedence over env. Env MCP_AUTH_TOKEN is used when\n // the flag is absent.\n const authToken = args.authToken ?? process.env.MCP_AUTH_TOKEN;\n let authMode: AuthMode = args.authMode ?? 'none';\n if (authToken && authMode === 'none') authMode = 'bearer';\n // TRUST_FORWARDED_AUTH (env or flag) may only promote a still-unset\n // `authMode` to 'proxy'. An explicit --auth-mode (e.g. oauth) must never\n // be silently downgraded by a stale env var — that would bypass JWT\n // validation. The explicit --trust-forwarded-auth CLI flag also requires\n // authMode to currently be 'none' to win, preserving the \"most specific\n // intent wins, never silently weaken\" rule.\n if ((args.trustForwardedAuth || envTrustForwarded) && authMode === 'none') {\n authMode = 'proxy';\n }\n\n // OAuth config — CLI wins, env fills the gaps.\n const oauthIssuer = args.oauthIssuer ?? process.env.OAUTH_ISSUER;\n const oauthAudience =\n args.oauthAudience ?? parseCsvEnv(process.env.OAUTH_AUDIENCE);\n const oauthJwksUri = args.oauthJwksUri ?? process.env.OAUTH_JWKS_URI;\n const oauthRequiredScopes =\n args.oauthRequiredScopes ?? parseCsvEnv(process.env.OAUTH_REQUIRED_SCOPES);\n const oauthUserClaim = args.oauthUserClaim ?? process.env.OAUTH_USER_CLAIM;\n\n if (authMode === 'none' && oauthIssuer) {\n // If user supplied OAuth config without explicit --auth-mode, assume\n // they meant oauth. Explicit --auth-mode always wins.\n authMode = 'oauth';\n }\n\n // Startup sanity check: bearer mode without a token cannot work.\n if (authMode === 'bearer' && (!authToken || authToken.length === 0)) {\n process.stderr.write(\n '[adt-mcp-http] fatal: MCP_AUTH_TOKEN (or --auth-token) required when --auth-mode=bearer\\n',\n );\n process.exit(1);\n }\n\n // Startup sanity check: oauth mode requires at least an issuer.\n if (authMode === 'oauth' && (!oauthIssuer || oauthIssuer.length === 0)) {\n process.stderr.write(\n '[adt-mcp-http] fatal: --oauth-issuer (or OAUTH_ISSUER) required when --auth-mode=oauth\\n',\n );\n process.exit(1);\n }\n\n let oauthOptions: OAuthOptions | undefined;\n if (authMode === 'oauth' && oauthIssuer) {\n oauthOptions = {\n issuer: oauthIssuer,\n audience:\n oauthAudience && oauthAudience.length > 0\n ? oauthAudience.length === 1\n ? oauthAudience[0]\n : oauthAudience\n : undefined,\n jwksUri: oauthJwksUri,\n requiredScopes:\n oauthRequiredScopes && oauthRequiredScopes.length > 0\n ? oauthRequiredScopes\n : undefined,\n userClaim: oauthUserClaim,\n };\n }\n\n const host = args.host ?? process.env.MCP_HOST ?? '127.0.0.1';\n const isLoopback =\n host === '127.0.0.1' || host === 'localhost' || host === '::1';\n\n if (authMode === 'none' && !isLoopback) {\n process.stderr.write(\n `[adt-mcp-http] WARN: auth disabled and bound to non-loopback host '${host}' — ` +\n 'anyone with network access can use the server. ' +\n 'Set MCP_AUTH_TOKEN or TRUST_FORWARDED_AUTH=1 before exposing.\\n',\n );\n }\n if (authMode === 'proxy' && !isLoopback) {\n process.stderr.write(\n `[adt-mcp-http] WARN: TRUST_FORWARDED_AUTH enabled on non-loopback host '${host}' — ` +\n 'x-forwarded-user is trusted unconditionally. ' +\n 'Only use this mode behind a reverse proxy that strips these headers from untrusted input.\\n',\n );\n }\n\n const adtConfigFile = args.adtConfigFile ?? process.env.ADT_CONFIG_FILE;\n let multiSystem: MultiSystemConfig | undefined;\n if (adtConfigFile) {\n process.stderr.write(\n `[adt-mcp-http] loading system registry from adt-config: ${adtConfigFile}\\n`,\n );\n multiSystem = await loadAdtConfigMultiSystem(adtConfigFile);\n }\n\n const running = await startHttpServer({\n ...(multiSystem ? { multiSystem } : {}),\n port: args.port,\n host: args.host,\n ttlMs: args.ttlMs,\n allowedHosts: [...(args.allowedHosts ?? []), ...envAllowed],\n authMode,\n authToken,\n trustForwardedAuth: args.trustForwardedAuth || envTrustForwarded,\n oauth: oauthOptions,\n allowedOrigins: [...(args.allowedOrigins ?? []), ...envCorsOrigins],\n tlsCert: args.tlsCert,\n tlsKey: args.tlsKey,\n });\n\n if (authMode === 'oauth' && oauthOptions) {\n const audDisplay = Array.isArray(oauthOptions.audience)\n ? oauthOptions.audience.join(',')\n : (oauthOptions.audience ?? '<any>');\n const scopesDisplay = oauthOptions.requiredScopes?.length\n ? oauthOptions.requiredScopes.join(',')\n : '<none>';\n process.stderr.write(\n `[adt-mcp-http] OAuth validation enabled: issuer=${oauthOptions.issuer} audience=${audDisplay} scopes=${scopesDisplay}\\n`,\n );\n }\n\n const shutdown = async (signal: string): Promise<void> => {\n process.stderr.write(`[adt-mcp-http] received ${signal}, shutting down\\n`);\n try {\n await running.close();\n } finally {\n process.exit(0);\n }\n };\n\n process.on('SIGINT', () => void shutdown('SIGINT'));\n process.on('SIGTERM', () => void shutdown('SIGTERM'));\n}\n\nmain().catch((err) => {\n process.stderr.write(\n `[adt-mcp-http] fatal: ${err instanceof Error ? (err.stack ?? err.message) : String(err)}\\n`,\n );\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,YAAY,KAAqB;CACxC,IAAI;EACF,MAAM,IAAI,IAAI,IAAI,GAAG;EACrB,EAAE,WAAW;EACb,EAAE,WAAW;EACb,OAAO,EAAE,SAAS;CACpB,QAAQ;EACN,OAAO;CACT;AACF;;;;;;AAOA,SAAS,eAAe,SAAsC;CAC5D,IAAI,CAAC,WAAW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,IAAI,SAAS,IAAI,UAAW,OAAO,GAAG,EAAE,GAC3F;CACA,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"adt-mcp-http.mjs","names":[],"sources":["../../src/lib/http/adt-config-loader.ts","../../src/bin/adt-mcp-http.ts"],"sourcesContent":["/**\n * adt-config adapter for adt-mcp multi-system registry.\n *\n * Loads SAP system definitions from `adt.config.ts` / `adt.config.json`\n * (via `@abapify/adt-config`) and returns a {@link MultiSystemConfig}\n * compatible object that `startHttpServer()` can consume.\n *\n * Only destinations with a resolvable `url` field in their `options`\n * (or the shorthand string URL) are included. Credentials (username /\n * password) are intentionally NOT loaded — they must be supplied at\n * runtime via the `sap_connect` tool call, matching the security policy\n * of the existing multi-system loader.\n */\n\nimport { loadConfig } from '@abapify/adt-config';\nimport type { MultiSystemConfig } from './multi-system.js';\nimport type { ConnectionParams } from '../types.js';\n\n/**\n * Sanitize a URL for safe logging by stripping any embedded credentials\n * (userinfo component) that a user might accidentally include.\n */\nfunction sanitizeUrl(raw: string): string {\n try {\n const u = new URL(raw);\n u.username = '';\n u.password = '';\n return u.toString();\n } catch {\n return '<invalid-url>';\n }\n}\n\n/**\n * Attempt to extract a `baseUrl` from a destination's options object.\n * Handles both `{ url: '...' }` and `{ baseUrl: '...' }` shapes, as\n * different auth plugins use different field names.\n */\nfunction extractBaseUrl(options: unknown): string | undefined {\n if (!options || typeof options !== 'object') return undefined;\n const o = options as Record<string, unknown>;\n if (typeof o.url === 'string' && o.url.length > 0) return o.url;\n if (typeof o.baseUrl === 'string' && o.baseUrl.length > 0) return o.baseUrl;\n return undefined;\n}\n\nfunction extractClient(options: unknown): string | undefined {\n if (!options || typeof options !== 'object') return undefined;\n const o = options as Record<string, unknown>;\n if (typeof o.client === 'string' && o.client.length > 0) return o.client;\n return undefined;\n}\n\n/**\n * Load system definitions from `adt-config` and expose them as a\n * {@link MultiSystemConfig} for the MCP HTTP server.\n *\n * @param configPath Optional explicit path to `adt.config.ts` / `adt.config.json`.\n * When omitted, `@abapify/adt-config` auto-discovers from `cwd`.\n * @param cwd Working directory for auto-discovery. Defaults to `process.cwd()`.\n */\nexport async function loadAdtConfigMultiSystem(\n configPath?: string,\n cwd?: string,\n): Promise<MultiSystemConfig> {\n // Warn when a TypeScript config file is requested but the current runtime\n // is plain Node.js (not Bun). Node cannot `import()` a `.ts` file directly\n // without a loader, so the config would be silently ignored. Bun natively\n // supports TypeScript, so this is only a concern for production Node deployments.\n if (\n configPath?.endsWith('.ts') &&\n typeof (globalThis as Record<string, unknown>).Bun === 'undefined'\n ) {\n throw new Error(\n `ADT_CONFIG_FILE '${configPath}' is TypeScript; plain Node.js cannot load .ts configs. ` +\n `Use adt.config.json, a compiled .mjs config, or run adt-mcp-http with Bun ` +\n `(e.g. bunx nx run adt-mcp:serve).`,\n );\n }\n\n const loaded = await loadConfig({ configPath, cwd });\n const systems: Record<string, { baseUrl: string; client?: string }> = {};\n\n for (const sid of loaded.listDestinations()) {\n const dest = loaded.getDestination(sid);\n if (!dest) continue;\n\n let baseUrl: string | undefined;\n let client: string | undefined;\n\n if (typeof dest === 'string') {\n baseUrl = dest;\n } else {\n baseUrl = extractBaseUrl(dest.options);\n client = extractClient(dest.options);\n }\n\n if (!baseUrl) {\n process.stderr.write(\n `[adt-config-loader] warning: destination '${sid}' has no resolvable URL — skipping.\\n`,\n );\n continue;\n }\n\n systems[sid] = { baseUrl, ...(client ? { client } : {}) };\n process.stderr.write(\n `[adt-config-loader] loaded system '${sid}' → ${sanitizeUrl(baseUrl)}\\n`,\n );\n }\n\n return {\n systems,\n resolve(systemId: string): ConnectionParams | undefined {\n const entry = systems[systemId];\n if (!entry) return undefined;\n return { baseUrl: entry.baseUrl, client: entry.client };\n },\n };\n}\n","#!/usr/bin/env node\n/**\n * adt-mcp-http — Streamable HTTP entry-point for the MCP server.\n *\n * Usage:\n * adt-mcp-http [--port 3000] [--host 127.0.0.1] [--ttl 1800000]\n * [--auth-token <value>] [--trust-forwarded-auth]\n * [--cors-origin <origin>]...\n *\n * Environment:\n * MCP_PORT Listen port (default 3000).\n * MCP_HOST Bind address (default 127.0.0.1).\n * MCP_ALLOWED_HOSTS Comma-separated additional hostnames for the\n * Host-header allowlist.\n * MCP_AUTH_TOKEN Bearer token. Implies --auth-mode=bearer.\n * TRUST_FORWARDED_AUTH Set to \"1\" / \"true\" to enable reverse-proxy\n * (x-forwarded-user) trust mode.\n * MCP_CORS_ORIGIN Comma-separated CORS allow-list.\n * SAP_SYSTEMS_JSON Inline multi-system config as JSON.\n * SAP_SYSTEMS_FILE Path to a multi-system config JSON file.\n * ADT_CONFIG_FILE Path to adt.config.ts/json. When set, system\n * definitions are loaded from adt-config instead\n * of SAP_SYSTEMS_JSON / SAP_SYSTEMS_FILE.\n */\n\nimport { startHttpServer } from '../lib/http/server.js';\nimport type { OAuthOptions } from '../lib/http/oauth.js';\nimport type { MultiSystemConfig } from '../lib/http/multi-system.js';\nimport { loadAdtConfigMultiSystem } from '../lib/http/adt-config-loader.js';\n\ntype AuthMode = 'none' | 'bearer' | 'proxy' | 'oauth';\n\ninterface ParsedArgs {\n port?: number;\n host?: string;\n ttlMs?: number;\n allowedHosts?: string[];\n authToken?: string;\n authMode?: AuthMode;\n trustForwardedAuth?: boolean;\n allowedOrigins?: string[];\n oauthIssuer?: string;\n oauthAudience?: string[];\n oauthJwksUri?: string;\n oauthRequiredScopes?: string[];\n oauthUserClaim?: string;\n adtConfigFile?: string;\n tlsCert?: string;\n tlsKey?: string;\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const out: ParsedArgs = {};\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n const next = () => argv[++i];\n switch (a) {\n case '--port':\n case '-p': {\n const v = Number(next());\n if (Number.isFinite(v)) out.port = v;\n break;\n }\n case '--host':\n case '-H': {\n out.host = next();\n break;\n }\n case '--ttl': {\n const v = Number(next());\n if (Number.isFinite(v)) out.ttlMs = v;\n break;\n }\n case '--allowed-host': {\n const v = next();\n if (v) (out.allowedHosts ??= []).push(v);\n break;\n }\n case '--auth-token': {\n const v = next();\n if (v) {\n out.authToken = v;\n out.authMode = 'bearer';\n }\n break;\n }\n case '--auth-mode': {\n const v = next();\n if (v === 'none' || v === 'bearer' || v === 'proxy' || v === 'oauth') {\n out.authMode = v;\n }\n break;\n }\n case '--trust-forwarded-auth': {\n out.trustForwardedAuth = true;\n out.authMode = 'proxy';\n break;\n }\n case '--oauth-issuer': {\n const v = next();\n if (v) out.oauthIssuer = v;\n break;\n }\n case '--oauth-audience': {\n const v = next();\n if (v) {\n (out.oauthAudience ??= []).push(\n ...v\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0),\n );\n }\n break;\n }\n case '--oauth-jwks-uri': {\n const v = next();\n if (v) out.oauthJwksUri = v;\n break;\n }\n case '--oauth-required-scope': {\n const v = next();\n if (v) {\n (out.oauthRequiredScopes ??= []).push(\n ...v\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0),\n );\n }\n break;\n }\n case '--oauth-user-claim': {\n const v = next();\n if (v) out.oauthUserClaim = v;\n break;\n }\n case '--cors-origin': {\n const v = next();\n if (v) (out.allowedOrigins ??= []).push(v);\n break;\n }\n case '--adt-config': {\n const v = next();\n if (v) out.adtConfigFile = v;\n break;\n }\n case '--tls-cert': {\n const v = next();\n if (v) out.tlsCert = v;\n break;\n }\n case '--tls-key': {\n const v = next();\n if (v) out.tlsKey = v;\n break;\n }\n case '--help':\n case '-h': {\n process.stdout.write(\n 'Usage: adt-mcp-http [--port N] [--host HOST] [--ttl MS]\\n' +\n ' [--allowed-host H ...]\\n' +\n ' [--auth-token TOKEN | --auth-mode MODE]\\n' +\n ' [--trust-forwarded-auth]\\n' +\n ' [--oauth-issuer URL] [--oauth-audience VAL]\\n' +\n ' [--oauth-jwks-uri URL]\\n' +\n ' [--oauth-required-scope SCOPE]\\n' +\n ' [--oauth-user-claim NAME]\\n' +\n ' [--cors-origin ORIGIN ...]\\n' +\n ' [--adt-config PATH]\\n' +\n ' [--tls-cert PATH] [--tls-key PATH]\\n',\n );\n process.exit(0);\n }\n // eslint-disable-next-line no-fallthrough\n default:\n // Unknown flag — ignore for forward compatibility.\n break;\n }\n }\n return out;\n}\n\nfunction isTruthyEnv(v: string | undefined): boolean {\n if (!v) return false;\n return ['1', 'true', 'yes', 'on'].includes(v.toLowerCase());\n}\n\nfunction parseCsvEnv(v: string | undefined): string[] {\n if (!v) return [];\n return v\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\nasync function main(): Promise<void> {\n const args = parseArgs(process.argv.slice(2));\n const envAllowed = parseCsvEnv(process.env.MCP_ALLOWED_HOSTS);\n const envCorsOrigins = parseCsvEnv(process.env.MCP_CORS_ORIGIN);\n const envTrustForwarded = isTruthyEnv(process.env.TRUST_FORWARDED_AUTH);\n\n // CLI flag takes precedence over env. Env MCP_AUTH_TOKEN is used when\n // the flag is absent.\n const authToken = args.authToken ?? process.env.MCP_AUTH_TOKEN;\n let authMode: AuthMode = args.authMode ?? 'none';\n if (authToken && authMode === 'none') authMode = 'bearer';\n // TRUST_FORWARDED_AUTH (env or flag) may only promote a still-unset\n // `authMode` to 'proxy'. An explicit --auth-mode (e.g. oauth) must never\n // be silently downgraded by a stale env var — that would bypass JWT\n // validation. The explicit --trust-forwarded-auth CLI flag also requires\n // authMode to currently be 'none' to win, preserving the \"most specific\n // intent wins, never silently weaken\" rule.\n if ((args.trustForwardedAuth || envTrustForwarded) && authMode === 'none') {\n authMode = 'proxy';\n }\n\n // OAuth config — CLI wins, env fills the gaps.\n const oauthIssuer = args.oauthIssuer ?? process.env.OAUTH_ISSUER;\n const oauthAudience =\n args.oauthAudience ?? parseCsvEnv(process.env.OAUTH_AUDIENCE);\n const oauthJwksUri = args.oauthJwksUri ?? process.env.OAUTH_JWKS_URI;\n const oauthRequiredScopes =\n args.oauthRequiredScopes ?? parseCsvEnv(process.env.OAUTH_REQUIRED_SCOPES);\n const oauthUserClaim = args.oauthUserClaim ?? process.env.OAUTH_USER_CLAIM;\n\n if (authMode === 'none' && oauthIssuer) {\n // If user supplied OAuth config without explicit --auth-mode, assume\n // they meant oauth. Explicit --auth-mode always wins.\n authMode = 'oauth';\n }\n\n // Startup sanity check: bearer mode without a token cannot work.\n if (authMode === 'bearer' && (!authToken || authToken.length === 0)) {\n process.stderr.write(\n '[adt-mcp-http] fatal: MCP_AUTH_TOKEN (or --auth-token) required when --auth-mode=bearer\\n',\n );\n process.exit(1);\n }\n\n // Startup sanity check: oauth mode requires at least an issuer.\n if (authMode === 'oauth' && (!oauthIssuer || oauthIssuer.length === 0)) {\n process.stderr.write(\n '[adt-mcp-http] fatal: --oauth-issuer (or OAUTH_ISSUER) required when --auth-mode=oauth\\n',\n );\n process.exit(1);\n }\n\n let oauthOptions: OAuthOptions | undefined;\n if (authMode === 'oauth' && oauthIssuer) {\n oauthOptions = {\n issuer: oauthIssuer,\n audience:\n oauthAudience && oauthAudience.length > 0\n ? oauthAudience.length === 1\n ? oauthAudience[0]\n : oauthAudience\n : undefined,\n jwksUri: oauthJwksUri,\n requiredScopes:\n oauthRequiredScopes && oauthRequiredScopes.length > 0\n ? oauthRequiredScopes\n : undefined,\n userClaim: oauthUserClaim,\n };\n }\n\n const host = args.host ?? process.env.MCP_HOST ?? '127.0.0.1';\n const isLoopback =\n host === '127.0.0.1' || host === 'localhost' || host === '::1';\n\n if (authMode === 'none' && !isLoopback) {\n process.stderr.write(\n `[adt-mcp-http] WARN: auth disabled and bound to non-loopback host '${host}' — ` +\n 'anyone with network access can use the server. ' +\n 'Set MCP_AUTH_TOKEN or TRUST_FORWARDED_AUTH=1 before exposing.\\n',\n );\n }\n if (authMode === 'proxy' && !isLoopback) {\n process.stderr.write(\n `[adt-mcp-http] WARN: TRUST_FORWARDED_AUTH enabled on non-loopback host '${host}' — ` +\n 'x-forwarded-user is trusted unconditionally. ' +\n 'Only use this mode behind a reverse proxy that strips these headers from untrusted input.\\n',\n );\n }\n\n const adtConfigFile = args.adtConfigFile ?? process.env.ADT_CONFIG_FILE;\n let multiSystem: MultiSystemConfig | undefined;\n if (adtConfigFile) {\n process.stderr.write(\n `[adt-mcp-http] loading system registry from adt-config: ${adtConfigFile}\\n`,\n );\n multiSystem = await loadAdtConfigMultiSystem(adtConfigFile);\n }\n\n const running = await startHttpServer({\n ...(multiSystem ? { multiSystem } : {}),\n port: args.port,\n host: args.host,\n ttlMs: args.ttlMs,\n allowedHosts: [...(args.allowedHosts ?? []), ...envAllowed],\n authMode,\n authToken,\n trustForwardedAuth: args.trustForwardedAuth || envTrustForwarded,\n oauth: oauthOptions,\n allowedOrigins: [...(args.allowedOrigins ?? []), ...envCorsOrigins],\n tlsCert: args.tlsCert,\n tlsKey: args.tlsKey,\n });\n\n if (authMode === 'oauth' && oauthOptions) {\n const audDisplay = Array.isArray(oauthOptions.audience)\n ? oauthOptions.audience.join(',')\n : (oauthOptions.audience ?? '<any>');\n const scopesDisplay = oauthOptions.requiredScopes?.length\n ? oauthOptions.requiredScopes.join(',')\n : '<none>';\n process.stderr.write(\n `[adt-mcp-http] OAuth validation enabled: issuer=${oauthOptions.issuer} audience=${audDisplay} scopes=${scopesDisplay}\\n`,\n );\n }\n\n const shutdown = async (signal: string): Promise<void> => {\n process.stderr.write(`[adt-mcp-http] received ${signal}, shutting down\\n`);\n try {\n await running.close();\n } finally {\n process.exit(0);\n }\n };\n\n process.on('SIGINT', () => void shutdown('SIGINT'));\n process.on('SIGTERM', () => void shutdown('SIGTERM'));\n}\n\nmain().catch((err) => {\n process.stderr.write(\n `[adt-mcp-http] fatal: ${err instanceof Error ? (err.stack ?? err.message) : String(err)}\\n`,\n );\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,YAAY,KAAqB;CACxC,IAAI;EACF,MAAM,IAAI,IAAI,IAAI,GAAG;EACrB,EAAE,WAAW;EACb,EAAE,WAAW;EACb,OAAO,EAAE,SAAS;CACpB,QAAQ;EACN,OAAO;C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CAAC,OAAO,QAAQ;CACpB,QAAQ,OAAO,MACb,yBAAyB,eAAe,QAAS,IAAI,SAAS,IAAI,UAAW,OAAO,GAAG,EAAE,GAC3F;CACA,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/dist/bin/adt-mcp.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as createMcpServer } from "../server-
|
|
2
|
+
import { t as createMcpServer } from "../server-DTLyqZq5.mjs";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/bin/adt-mcp.ts
|
|
6
6
|
/**
|
|
7
7
|
* adt-mcp – stdio entry-point
|
|
8
8
|
*
|
|
@@ -13,6 +13,5 @@ const server = createMcpServer();
|
|
|
13
13
|
const transport = new StdioServerTransport();
|
|
14
14
|
await server.connect(transport);
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
16
|
export { };
|
|
18
17
|
//# sourceMappingURL=adt-mcp.mjs.map
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,6 @@ import { KeyObject } from "node:crypto";
|
|
|
4
4
|
import { FlowConfig } from "@abapify/adt-config";
|
|
5
5
|
import { CryptoKey } from "jose";
|
|
6
6
|
import http from "node:http";
|
|
7
|
-
//#region src/lib/session/changeset.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Session-scoped changeset state (Wave 3).
|
|
10
9
|
*
|
|
@@ -54,8 +53,6 @@ interface Changeset {
|
|
|
54
53
|
/** Optional free-text description supplied by the caller. */
|
|
55
54
|
description?: string;
|
|
56
55
|
}
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/lib/session/types.d.ts
|
|
59
56
|
interface SapSessionContext {
|
|
60
57
|
/** MCP session id (the value of the `Mcp-Session-Id` header). */
|
|
61
58
|
mcpSessionId: string;
|
|
@@ -81,8 +78,6 @@ interface SapSessionContext {
|
|
|
81
78
|
*/
|
|
82
79
|
close: () => Promise<void>;
|
|
83
80
|
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/lib/session/registry.d.ts
|
|
86
81
|
interface SessionRegistry {
|
|
87
82
|
/**
|
|
88
83
|
* Registers a new session. The caller provides everything except the
|
|
@@ -110,8 +105,6 @@ interface SessionRegistryOptions {
|
|
|
110
105
|
sweepIntervalMs?: number;
|
|
111
106
|
}
|
|
112
107
|
declare function createSessionRegistry(options?: SessionRegistryOptions): SessionRegistry;
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region src/lib/session/destination-registry.d.ts
|
|
115
108
|
interface RequestIdentity {
|
|
116
109
|
principal: string;
|
|
117
110
|
agentId?: string;
|
|
@@ -178,8 +171,6 @@ interface DestinationContextRegistryOptions {
|
|
|
178
171
|
now?: () => number;
|
|
179
172
|
}
|
|
180
173
|
declare function createDestinationContextRegistry(options: DestinationContextRegistryOptions): DestinationContextRegistry;
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/lib/http/invocation.d.ts
|
|
183
174
|
type McpTrustedOperationClass = 'server' | 'read' | 'safe_execute';
|
|
184
175
|
type McpInvocationJsonValue = boolean | number | string | null | readonly McpInvocationJsonValue[] | Readonly<Record<string, McpInvocationJsonValue>>;
|
|
185
176
|
/** Claims proved by a verified, ADT-issued invocation credential. */
|
|
@@ -271,8 +262,6 @@ declare function parseScopedAdtInvocationPolicy(claims: TrustedMcpInvocationClai
|
|
|
271
262
|
* always resolve to `undefined` without logging token-derived information.
|
|
272
263
|
*/
|
|
273
264
|
declare function createMcpInvocationVerifier(options: McpInvocationVerifierOptions): McpInvocationVerifier;
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/lib/tools/scope-catalogue.d.ts
|
|
276
265
|
type McpOperationClass = 'server' | 'read' | 'safe_execute' | 'write';
|
|
277
266
|
interface McpRequestAccess {
|
|
278
267
|
/** Explicit trusted classes. `write` is never inferred from `read`. */
|
|
@@ -335,8 +324,6 @@ declare function operationClassForMcpTool(name: string, arguments_?: Record<stri
|
|
|
335
324
|
/** Registration fails when a newly added tool lacks an explicit catalogue row. */
|
|
336
325
|
declare function assertMcpToolIsClassified(name: string): void;
|
|
337
326
|
declare function isMcpToolAllowed(access: McpRequestAccess | undefined, name: string, arguments_?: Record<string, unknown>): boolean;
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/lib/source-capabilities.d.ts
|
|
340
327
|
interface SourceCapabilityRegistryOptions {
|
|
341
328
|
now?: () => number;
|
|
342
329
|
ttlMs?: number;
|
|
@@ -360,8 +347,6 @@ declare function createSourceCapabilityRegistry(options?: SourceCapabilityRegist
|
|
|
360
347
|
sourceUri: string;
|
|
361
348
|
};
|
|
362
349
|
};
|
|
363
|
-
//#endregion
|
|
364
|
-
//#region src/lib/types.d.ts
|
|
365
350
|
/**
|
|
366
351
|
* Connection parameters that every tool receives.
|
|
367
352
|
*
|
|
@@ -458,8 +443,6 @@ interface ToolContext {
|
|
|
458
443
|
/** Optional server-owned flow config; otherwise workspace config is loaded. */
|
|
459
444
|
flowConfig?: FlowConfig;
|
|
460
445
|
}
|
|
461
|
-
//#endregion
|
|
462
|
-
//#region src/lib/server.d.ts
|
|
463
446
|
interface McpServerOptions {
|
|
464
447
|
/** Override the client factory – useful for injecting a mock client in tests. */
|
|
465
448
|
clientFactory?: (params: ConnectionParams) => AdtClient;
|
|
@@ -504,11 +487,7 @@ interface McpServerOptions {
|
|
|
504
487
|
flowConfig?: ToolContext['flowConfig'];
|
|
505
488
|
}
|
|
506
489
|
declare function createMcpServer(options?: McpServerOptions): McpServer;
|
|
507
|
-
//#endregion
|
|
508
|
-
//#region src/lib/tools/index.d.ts
|
|
509
490
|
declare function registerTools(server: McpServer, ctx: ToolContext): void;
|
|
510
|
-
//#endregion
|
|
511
|
-
//#region src/lib/tools/utils.d.ts
|
|
512
491
|
/**
|
|
513
492
|
* Minimal structural type for the ADT client subset used by resolveObjectUri.
|
|
514
493
|
*
|
|
@@ -538,8 +517,6 @@ type QuickSearchClient = {
|
|
|
538
517
|
* when the object cannot be found.
|
|
539
518
|
*/
|
|
540
519
|
declare function resolveObjectUri(client: QuickSearchClient, objectName: string, objectType?: string): Promise<string | undefined>;
|
|
541
|
-
//#endregion
|
|
542
|
-
//#region src/lib/http/oauth.d.ts
|
|
543
520
|
interface OAuthOptions {
|
|
544
521
|
/** Expected `iss` claim, e.g. `https://company.okta.com/oauth2/default`. */
|
|
545
522
|
issuer: string;
|
|
@@ -564,16 +541,12 @@ interface OAuthOptions {
|
|
|
564
541
|
/** Claim to read as the groups array. Default `groups`. */
|
|
565
542
|
groupsClaim?: string;
|
|
566
543
|
}
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region src/lib/http/auth.d.ts
|
|
569
544
|
type AuthMode = 'none' | 'bearer' | 'proxy' | 'oauth' | 'invocation';
|
|
570
545
|
interface UserHint {
|
|
571
546
|
user: string;
|
|
572
547
|
email?: string;
|
|
573
548
|
groups?: string[];
|
|
574
549
|
}
|
|
575
|
-
//#endregion
|
|
576
|
-
//#region src/lib/http/multi-system.d.ts
|
|
577
550
|
interface SystemEntry {
|
|
578
551
|
baseUrl: string;
|
|
579
552
|
client?: string;
|
|
@@ -583,8 +556,6 @@ interface MultiSystemConfig {
|
|
|
583
556
|
resolve(systemId: string): ConnectionParams | undefined;
|
|
584
557
|
}
|
|
585
558
|
declare function loadMultiSystemConfig(): MultiSystemConfig;
|
|
586
|
-
//#endregion
|
|
587
|
-
//#region src/lib/http/server.d.ts
|
|
588
559
|
interface HttpServerOptions {
|
|
589
560
|
/** Port to listen on. Default: `MCP_PORT` env or 3000. */
|
|
590
561
|
port?: number;
|
|
@@ -702,6 +673,5 @@ declare function createHttpMcpHandler(options?: HttpServerOptions): HttpMcpHandl
|
|
|
702
673
|
* `createHttpMcpHandler` for standalone deployments.
|
|
703
674
|
*/
|
|
704
675
|
declare function startHttpServer(options?: HttpServerOptions): Promise<RunningHttpServer>;
|
|
705
|
-
//#endregion
|
|
706
676
|
export { type ConnectionParams, type DelegatedAssistantReadPolicy, type DestinationContext, type DestinationContextFactory, type DestinationContextRegistry, type DestinationContextRegistryOptions, type DestinationLease, type DestinationLeaseProvider, type HttpMcpHandler, type HttpServerOptions, MCP_TOOL_SCOPE_CATALOGUE, type McpDelegatedAccess, type McpInvocationJsonValue, type McpInvocationVerifier, type McpInvocationVerifierOptions, type McpOperationClass, type McpRequestAccess, type McpServerOptions, type McpToolScope, type McpTrustedOperationClass, type MultiSystemConfig, type RequestIdentity, type RunningHttpServer, type SafeExecutePolicy, type SapSessionContext, type ScopedAdtInvocationPolicy, type SessionRegistry, type SessionRegistryOptions, type SystemEntry, type ToolContext, type TrustedMcpInvocationClaims, assertMcpToolIsClassified, createDestinationContextRegistry, createHttpMcpHandler, createMcpInvocationVerifier, createMcpServer, createSessionRegistry, isMcpToolAllowed, loadMultiSystemConfig, operationClassForMcpTool, parseDelegatedAssistantReadPolicy, parseSafeExecutePolicy, parseScopedAdtInvocationPolicy, registerTools, resolveObjectUri, startHttpServer };
|
|
707
677
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/lib/session/changeset.ts","../src/lib/session/types.ts","../src/lib/session/registry.ts","../src/lib/session/destination-registry.ts","../src/lib/http/invocation.ts","../src/lib/tools/scope-catalogue.ts","../src/lib/source-capabilities.ts","../src/lib/types.ts","../src/lib/server.ts","../src/lib/tools/index.ts","../src/lib/tools/utils.ts","../src/lib/http/oauth.ts","../src/lib/http/auth.ts","../src/lib/http/multi-system.ts","../src/lib/http/server.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_$__auth_js0.UserHint","_$___types_js0.ToolContext"],"sources":["../src/lib/session/changeset.ts","../src/lib/session/types.ts","../src/lib/session/registry.ts","../src/lib/session/destination-registry.ts","../src/lib/http/invocation.ts","../src/lib/tools/scope-catalogue.ts","../src/lib/source-capabilities.ts","../src/lib/types.ts","../src/lib/server.ts","../src/lib/tools/index.ts","../src/lib/tools/utils.ts","../src/lib/http/oauth.ts","../src/lib/http/auth.ts","../src/lib/http/multi-system.ts","../src/lib/http/server.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuBY;UAGK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;;EAEf;;EAEA;;EAEA,QAAQ;;EAER,SAAS;;EAET;;UCtCe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA,QAAQ;;EAER,OAAO;;;;;;EAMP,YAAY;;;;;EAKZ,aAAa;;UCvBE;;;;;;;EAOf,OACE,sBACA,KAAK,KACH,2EAGF,aAAa,gBACZ;EACH,IAAI,uBAAuB;EAC3B,MAAM;;EAEN,OAAO,uBAAuB;EAC9B,QAAQ;;EAER,YAAY;;UAGG;;;;;;EAMf;;EAEA;;iBAKc,sBACd,UAAS,yBACR;UCjDc;EACf;EACA;;;UAIe;EACf;EACA;EACA;;;;;;EAMA;;EAEA,WAAW;;UAGI;EACf,QAAQ;IACN;IACA,UAAU;MACR,QAAQ;;UAGG;EACf;EACA;EACA,OAAO;EACP,QAAQ;EACR,OAAO;EACP,YAAY;EACZ;EACA;;EAEA,aAAa,GAAG,iBAAiB,QAAQ,KAAK,QAAQ;EACtD,SAAS;;UAGM;EACf,OAAO;IACL;IACA;IACA,OAAO;MACL;IACF,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,SAAS;;;UAII;EACf,IACE,sBACA,sBACC;EACH,YACE,sBACA,qBACA,UAAU,kBACT,QAAQ;EACX,MAAM,sBAAsB;EAC5B,QAAQ,sBAAsB,sBAAsB;EACpD,WAAW,uBAAuB;EAClC,QAAQ;EACR,YAAY;;UAGG;EACf,eAAe;EACf,gBAAgB;EAChB;EACA;EACA;;iBA0Bc,iCACd,SAAS,oCACR;KCnES;KAEA,qEAKC,2BACT,SAAS,eAAe;;UAGX;WACN;WACA;WACA;WAMA,kBAAkB;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B,YADhBC;IAIN,gCAAgC,YAHVA;IAMtB,yBAAyB,YAHOA;IAMhC,sBAAsB,YAHGA;;;EAQ3B,OAAO,kCAAkC;;UAG1B;WACN;WACA;WACA;WACA,UAAU;EACnB,SAAS;;;;;;;;;UAUM;WACN,UAAU;EACnB,OAAO,KAAK,KAAK,iBAAiB,KAAK,KAAK,iBAAiB;EAC7D,SAAS;;;;;iBA6aK,qBACd,UAAS,oBACR;;;;;;;;iBAgYmB,gBACpB,UAAS,oBACR,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as operationClassForMcpTool, i as assertMcpToolIsClassified, l as resolveObjectUri, n as registerTools, r as MCP_TOOL_SCOPE_CATALOGUE, s as isMcpToolAllowed, t as createMcpServer } from "./server-
|
|
2
|
-
import { a as parseSafeExecutePolicy, c as createSessionRegistry, i as parseDelegatedAssistantReadPolicy, n as startHttpServer, o as parseScopedAdtInvocationPolicy, r as createMcpInvocationVerifier, s as loadMultiSystemConfig, t as createHttpMcpHandler } from "./server-
|
|
1
|
+
import { c as operationClassForMcpTool, i as assertMcpToolIsClassified, l as resolveObjectUri, n as registerTools, r as MCP_TOOL_SCOPE_CATALOGUE, s as isMcpToolAllowed, t as createMcpServer } from "./server-DTLyqZq5.mjs";
|
|
2
|
+
import { a as parseSafeExecutePolicy, c as createSessionRegistry, i as parseDelegatedAssistantReadPolicy, n as startHttpServer, o as parseScopedAdtInvocationPolicy, r as createMcpInvocationVerifier, s as loadMultiSystemConfig, t as createHttpMcpHandler } from "./server-D2q3SSjJ.mjs";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/lib/session/destination-registry.ts
|
|
5
5
|
const DEFAULT_TTL_MS = 18e5;
|
|
6
6
|
function contextKey(mcpSessionId, destination) {
|
|
7
7
|
return `${mcpSessionId}\u0000${destination}`;
|
|
@@ -159,6 +159,5 @@ function createDestinationContextRegistry(options) {
|
|
|
159
159
|
return registry;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
//#endregion
|
|
163
162
|
export { MCP_TOOL_SCOPE_CATALOGUE, assertMcpToolIsClassified, createDestinationContextRegistry, createHttpMcpHandler, createMcpInvocationVerifier, createMcpServer, createSessionRegistry, isMcpToolAllowed, loadMultiSystemConfig, operationClassForMcpTool, parseDelegatedAssistantReadPolicy, parseSafeExecutePolicy, parseScopedAdtInvocationPolicy, registerTools, resolveObjectUri, startHttpServer };
|
|
164
163
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isMcpDestinationKey, o as isMcpOperationClass, t as createMcpServer } from "./server-
|
|
1
|
+
import { a as isMcpDestinationKey, o as isMcpOperationClass, t as createMcpServer } from "./server-DTLyqZq5.mjs";
|
|
2
2
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
3
3
|
import { randomUUID, timingSafeEqual } from "node:crypto";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
@@ -9,7 +9,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// src/lib/session/registry.ts
|
|
13
13
|
const DEFAULT_TTL_MS = 18e5;
|
|
14
14
|
function createSessionRegistry(options = {}) {
|
|
15
15
|
const ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
|
|
@@ -74,8 +74,7 @@ function createSessionRegistry(options = {}) {
|
|
|
74
74
|
return registry;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
//#region src/lib/http/multi-system.ts
|
|
77
|
+
// src/lib/http/multi-system.ts
|
|
79
78
|
/**
|
|
80
79
|
* Multi-system configuration loader for adt-mcp HTTP transport.
|
|
81
80
|
*
|
|
@@ -142,8 +141,7 @@ function loadMultiSystemConfig() {
|
|
|
142
141
|
};
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
|
|
146
|
-
//#region src/lib/http/oauth.ts
|
|
144
|
+
// src/lib/http/oauth.ts
|
|
147
145
|
/**
|
|
148
146
|
* OAuth 2.1 / OIDC bearer-token validator for the adt-mcp HTTP transport.
|
|
149
147
|
*
|
|
@@ -307,8 +305,7 @@ function createOAuthValidator(opts) {
|
|
|
307
305
|
};
|
|
308
306
|
}
|
|
309
307
|
|
|
310
|
-
|
|
311
|
-
//#region src/lib/http/auth.ts
|
|
308
|
+
// src/lib/http/auth.ts
|
|
312
309
|
function writeUnauthorized(res, oauthError) {
|
|
313
310
|
if (res.headersSent) {
|
|
314
311
|
try {
|
|
@@ -427,8 +424,7 @@ function createAuthMiddleware(options) {
|
|
|
427
424
|
return () => ({ allowed: true });
|
|
428
425
|
}
|
|
429
426
|
|
|
430
|
-
|
|
431
|
-
//#region src/lib/http/invocation.ts
|
|
427
|
+
// src/lib/http/invocation.ts
|
|
432
428
|
const INVOCATION_VERSION = 1;
|
|
433
429
|
const MAX_IDENTIFIER_LENGTH = 256;
|
|
434
430
|
const MAX_COMPONENT_IDENTIFIER_LENGTH = 512;
|
|
@@ -1001,8 +997,7 @@ function createMcpInvocationVerifier(options) {
|
|
|
1001
997
|
} };
|
|
1002
998
|
}
|
|
1003
999
|
|
|
1004
|
-
|
|
1005
|
-
//#region src/lib/http/cors.ts
|
|
1000
|
+
// src/lib/http/cors.ts
|
|
1006
1001
|
const ALLOW_METHODS = "POST, GET, DELETE, OPTIONS";
|
|
1007
1002
|
const ALLOW_HEADERS = "content-type, accept, mcp-session-id, authorization";
|
|
1008
1003
|
const EXPOSE_HEADERS = "mcp-session-id";
|
|
@@ -1044,8 +1039,7 @@ function createCorsHandler(options = {}) {
|
|
|
1044
1039
|
} };
|
|
1045
1040
|
}
|
|
1046
1041
|
|
|
1047
|
-
|
|
1048
|
-
//#region src/lib/http/server.ts
|
|
1042
|
+
// src/lib/http/server.ts
|
|
1049
1043
|
/**
|
|
1050
1044
|
* HTTP transport for the adt-mcp server.
|
|
1051
1045
|
*
|
|
@@ -1556,6 +1550,5 @@ async function startHttpServer(options = {}) {
|
|
|
1556
1550
|
};
|
|
1557
1551
|
}
|
|
1558
1552
|
|
|
1559
|
-
//#endregion
|
|
1560
1553
|
export { parseSafeExecutePolicy as a, createSessionRegistry as c, parseDelegatedAssistantReadPolicy as i, startHttpServer as n, parseScopedAdtInvocationPolicy as o, createMcpInvocationVerifier as r, loadMultiSystemConfig as s, createHttpMcpHandler as t };
|
|
1561
|
-
//# sourceMappingURL=server-
|
|
1554
|
+
//# sourceMappingURL=server-D2q3SSjJ.mjs.map
|