@alfe.ai/mcp-server 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/dist/bin.cjs ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ //#region src/bin.ts
3
+ require("./index.cjs").main();
4
+ //#endregion
package/dist/bin.d.cts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "./index.js";
3
+ //#region src/bin.ts
4
+ main();
5
+ //#endregion
6
+ export {};
7
+
8
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { main } from './index.js';\n\nvoid main();\n"],"mappings":";;;AAGK,MAAM"}
package/dist/index.cjs ADDED
@@ -0,0 +1,81 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let node_module = require("node:module");
3
+ let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
4
+ let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
5
+ let _alfe_ai_agent_api_client = require("@alfe.ai/agent-api-client");
6
+ let _alfe_ai_config = require("@alfe.ai/config");
7
+ let _alfe_ai_mcp_tools = require("@alfe.ai/mcp-tools");
8
+ //#region src/index.ts
9
+ const pkg = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("../package.json");
10
+ /**
11
+ * Wire shape the bundler advertises this server as — must match the
12
+ * key the CLI registers (`alfe-platform`) so namespacing is consistent
13
+ * across components.
14
+ */
15
+ const SERVER_NAME = "alfe-platform";
16
+ /**
17
+ * Single source of truth for the server's own version, read straight
18
+ * from package.json so it can't drift with bumps. The CLI's
19
+ * version-drift hook compares this against the entry stored in
20
+ * `~/.alfe/mcp/servers.json` and re-resolves the command path when
21
+ * they diverge (e.g. after an `npm install -g @alfe.ai/cli`).
22
+ */
23
+ const SERVER_VERSION = pkg.version;
24
+ /**
25
+ * Build a configured `McpServer` with all thin-slice tools registered.
26
+ * Pure construction — does not connect a transport. Callers (the bin
27
+ * entry, or tests) attach `StdioServerTransport` or any other transport.
28
+ *
29
+ * `resolveConfig()` is only called when neither `client` nor `apiUrl`
30
+ * is provided — tests can fully construct the server without touching
31
+ * `~/.alfe/config.toml`.
32
+ */
33
+ async function createServer(opts = {}) {
34
+ let client = opts.client;
35
+ let apiUrl = opts.apiUrl;
36
+ if (!client || !apiUrl) {
37
+ const cfg = (0, _alfe_ai_config.resolveConfig)();
38
+ client = client ?? new _alfe_ai_agent_api_client.AgentApiClient({
39
+ apiKey: cfg.apiKey,
40
+ apiUrl: cfg.apiUrl
41
+ });
42
+ apiUrl = apiUrl ?? cfg.apiUrl;
43
+ }
44
+ const identity = opts.identity ?? await client.whoami();
45
+ const ctx = {
46
+ client,
47
+ apiUrl,
48
+ agentId: identity.agentId,
49
+ tenantId: identity.tenantId
50
+ };
51
+ const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
52
+ name: SERVER_NAME,
53
+ version: SERVER_VERSION
54
+ });
55
+ (0, _alfe_ai_mcp_tools.registerIntegrationsTools)(server, ctx);
56
+ return server;
57
+ }
58
+ /**
59
+ * Entry point — boot the server on stdio. Used by `bin.ts`. Any
60
+ * startup failure is fatal: log and exit non-zero so the bundler's
61
+ * connection attempt surfaces a clear error rather than a hung
62
+ * handshake.
63
+ */
64
+ async function main() {
65
+ try {
66
+ const server = await createServer();
67
+ const transport = new _modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
68
+ await server.connect(transport);
69
+ } catch (err) {
70
+ process.stderr.write(`[alfe-mcp-server] failed to start: ${errMsg(err)}\n`);
71
+ process.exit(1);
72
+ }
73
+ }
74
+ function errMsg(err) {
75
+ return err instanceof Error ? err.message : String(err);
76
+ }
77
+ //#endregion
78
+ exports.SERVER_NAME = SERVER_NAME;
79
+ exports.SERVER_VERSION = SERVER_VERSION;
80
+ exports.createServer = createServer;
81
+ exports.main = main;