@alfe.ai/mcp-server 0.1.19 → 0.2.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 +2 -1
- package/dist/bin.js +2 -2
- package/dist/bin.js.map +1 -1
- package/dist/index.cjs +36 -4
- package/dist/index.d.cts +108 -15
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +108 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { fileURLToPath } from 'node:url';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { AgentApiClient } from '@alfe.ai/agent-api-client';\nimport { resolveConfig } from '@alfe.ai/config';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { fileURLToPath } from 'node:url';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { AgentApiClient } from '@alfe.ai/agent-api-client';\nimport { resolveConfig } from '@alfe.ai/config';\nimport {\n registerIntegrationsTools,\n registerMemoryTools,\n registerVoiceTools,\n registerMessagingTools,\n type ToolContext,\n} from '@alfe.ai/mcp-tools';\n\nconst require = createRequire(import.meta.url);\nconst pkg = require('../package.json') as { version: string };\n\n/**\n * Wire shape the bundler advertises this server as — must match the\n * key the CLI registers (`alfe-platform`) so namespacing is consistent\n * across components.\n */\nexport const SERVER_NAME = 'alfe-platform';\n\n/**\n * Single source of truth for the server's own version, read straight\n * from package.json so it can't drift with bumps. The CLI's\n * version-drift hook compares this against the entry stored in\n * `~/.alfe/mcp/servers.json` and re-resolves the command path when\n * they diverge (e.g. after an `npm install -g @alfe.ai/cli`).\n */\nexport const SERVER_VERSION = pkg.version;\n\n/**\n * Absolute path to this package's stdio bin. Computed from\n * `import.meta.url` (always available, regardless of how the package\n * is installed) and resolved to a sibling of the main dist file.\n *\n * Exported so the CLI's `ensureAlfePlatformRegistered` doesn't need\n * to call `require.resolve('@alfe.ai/mcp-server/package.json')`, which\n * trips Node's strict exports-map enforcement when `./package.json`\n * isn't listed in `exports`. The package knows where its own binary\n * lives; consumers shouldn't have to crawl `package.json` for it.\n */\nexport const SERVER_BIN_PATH = fileURLToPath(new URL('./bin.js', import.meta.url));\n\n/**\n * Which tool surface the server exposes.\n *\n * - `default` (the OpenClaw daemon bundler's path — the bin is launched with\n * no `--profile`) registers ONLY the integrations tools. OpenClaw agents\n * consume this same server and already get `memory_*` from the\n * `@alfe.ai/openclaw-memory-cloud` plugin, so registering memory here would\n * DOUBLE their tool surface. Do not add tools to this profile without\n * confirming they don't already ship as an OpenClaw plugin.\n * - `claude-code` additionally registers memory + voice + messaging tools —\n * for a Claude Code session that has no Alfe plugins and needs those\n * capabilities delivered via MCP.\n */\nexport type ServerProfile = 'default' | 'claude-code';\n\nexport interface ServerOptions {\n /**\n * Optional override for the API client — tests inject a fake so the\n * server can be exercised end-to-end without real network I/O.\n */\n client?: AgentApiClient;\n /** Pre-resolved context fields. If omitted, the server calls `whoami()` itself. */\n identity?: { agentId: string; tenantId: string };\n /** Override apiUrl reported in the ToolContext. Defaults to the resolved CLI config. */\n apiUrl?: string;\n /**\n * Tool surface to register. Defaults to `default` (integrations only) so\n * the OpenClaw bundler path is unchanged. `claude-code` adds memory + voice\n * + messaging.\n */\n profile?: ServerProfile;\n /**\n * Optional override for the voice-service client — tests inject a fake.\n * Only consumed by the `claude-code` profile's voice tools. When omitted\n * (and not resolvable from config) the voice tools fall back to `client`.\n */\n voiceClient?: AgentApiClient;\n /** Override voice-service apiUrl. Defaults to the resolved CLI config's `voiceServiceUrl`. */\n voiceApiUrl?: string;\n}\n\n/**\n * Build a configured `McpServer` with all thin-slice tools registered.\n * Pure construction — does not connect a transport. Callers (the bin\n * entry, or tests) attach `StdioServerTransport` or any other transport.\n *\n * `resolveConfig()` is only called when neither `client` nor `apiUrl`\n * is provided — tests can fully construct the server without touching\n * `~/.alfe/config.toml`.\n */\nexport async function createServer(opts: ServerOptions = {}): Promise<McpServer> {\n const profile: ServerProfile = opts.profile ?? 'default';\n\n let client = opts.client;\n let apiUrl = opts.apiUrl;\n let voiceClient = opts.voiceClient;\n let voiceApiUrl = opts.voiceApiUrl;\n // Only touch config when something is unresolved — tests fully construct\n // the server without reading ~/.alfe/config.toml. The voice client is\n // only needed for the claude-code profile, so resolveConfig() stays out\n // of the default path unless apiUrl/client were omitted.\n if (!client || !apiUrl || (profile === 'claude-code' && !voiceClient && !voiceApiUrl)) {\n const cfg = resolveConfig();\n client = client ?? new AgentApiClient({ apiKey: cfg.apiKey, apiUrl: cfg.apiUrl });\n apiUrl = apiUrl ?? cfg.apiUrl;\n voiceApiUrl = voiceApiUrl ?? cfg.voiceServiceUrl;\n voiceClient =\n voiceClient ?? new AgentApiClient({ apiKey: cfg.apiKey, apiUrl: cfg.voiceServiceUrl });\n }\n\n const identity = opts.identity ?? (await client.whoami());\n\n const ctx: ToolContext = {\n client,\n apiUrl,\n agentId: identity.agentId,\n tenantId: identity.tenantId,\n voiceApiUrl,\n voiceClient,\n };\n\n const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION });\n registerIntegrationsTools(server, ctx);\n if (profile === 'claude-code') {\n registerMemoryTools(server, ctx);\n registerVoiceTools(server, ctx);\n registerMessagingTools(server, ctx);\n }\n return server;\n}\n\n/**\n * Parse the server profile out of a raw argv slice. Accepts both\n * `--profile claude-code` and `--profile=claude-code`. Unknown or missing\n * values resolve to `default`, so the OpenClaw bundler (which launches the\n * bin with no args) always gets the integrations-only surface.\n */\nexport function parseProfileArg(argv: string[]): ServerProfile {\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n let value: string | undefined;\n if (arg === '--profile') {\n value = argv[i + 1];\n } else if (arg.startsWith('--profile=')) {\n value = arg.slice('--profile='.length);\n }\n if (value === 'claude-code') return 'claude-code';\n }\n return 'default';\n}\n\n/**\n * Entry point — boot the server on stdio. Used by `bin.ts`. Any\n * startup failure is fatal: log and exit non-zero so the bundler's\n * connection attempt surfaces a clear error rather than a hung\n * handshake.\n */\nexport async function main(opts: { profile?: ServerProfile } = {}): Promise<void> {\n try {\n const server = await createServer({ profile: opts.profile });\n const transport = new StdioServerTransport();\n await server.connect(transport);\n // McpServer keeps the transport alive; node holds the event loop\n // open via stdin until the parent (the bundler) closes the stream.\n } catch (err) {\n process.stderr.write(`[alfe-mcp-server] failed to start: ${errMsg(err)}\\n`);\n process.exit(1);\n }\n}\n\nfunction errMsg(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,MADU,cAAc,OAAO,KAAK,IAAI,CAC1B,kBAAkB;;;;;;AAOtC,MAAa,cAAc;;;;;;;;AAS3B,MAAa,iBAAiB,IAAI;;;;;;;;;;;;AAalC,MAAa,kBAAkB,cAAc,IAAI,IAAI,YAAY,OAAO,KAAK,IAAI,CAAC;;;;;;;;;;AAoDlF,eAAsB,aAAa,OAAsB,EAAE,EAAsB;CAC/E,MAAM,UAAyB,KAAK,WAAW;CAE/C,IAAI,SAAS,KAAK;CAClB,IAAI,SAAS,KAAK;CAClB,IAAI,cAAc,KAAK;CACvB,IAAI,cAAc,KAAK;AAKvB,KAAI,CAAC,UAAU,CAAC,UAAW,YAAY,iBAAiB,CAAC,eAAe,CAAC,aAAc;EACrF,MAAM,MAAM,eAAe;AAC3B,WAAS,UAAU,IAAI,eAAe;GAAE,QAAQ,IAAI;GAAQ,QAAQ,IAAI;GAAQ,CAAC;AACjF,WAAS,UAAU,IAAI;AACvB,gBAAc,eAAe,IAAI;AACjC,gBACE,e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Auto-registered as `alfe-platform` in the bundler store; surfaces Alfe platform tools to the agent runtime via @alfe.ai/mcp-tools using AgentApiClient against public /agent/... endpoints.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
23
23
|
"zod": "^3.25.0",
|
|
24
|
-
"@alfe.ai/agent-api-client": "0.
|
|
24
|
+
"@alfe.ai/agent-api-client": "0.11.0",
|
|
25
25
|
"@alfe.ai/config": "0.3.0",
|
|
26
|
-
"@alfe.ai/mcp-tools": "0.
|
|
26
|
+
"@alfe.ai/mcp-tools": "0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"license": "UNLICENSED",
|
|
29
29
|
"homepage": "https://alfe.ai",
|