mirror of
https://github.com/Luchexx/wacrm.git
synced 2026-11-02 17:29:45 +00:00
Introduce mcp-server/ — a stdio Model Context Protocol server that wraps the /api/v1 public API so MCP clients (Claude, Cursor, etc.) can drive a self-hosted wacrm instance in natural language. - Thin wrapper over the existing REST API; all auth, scoping, and rate limiting stay server-side. No new backend surface. - Read-only by default: write and broadcast tools are only registered when WACRM_ENABLE_WRITES / WACRM_ENABLE_BROADCASTS are set, layered on top of the API key's own scopes. send_broadcast also requires an explicit confirm and is marked destructive. - Registry-ready: server.json manifest, package.json mcpName linked to it (io.github.arnasdon/wacrm-mcp), and glama.json for discovery. - Docs: docs/mcp.md + README bullet + mcp-server/README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
// ============================================================
|
|
// Tool registration — decides which tools exist for this process
|
|
// based on the write guards. Reads are always on; writes and
|
|
// broadcasts are opt-in (see config.ts).
|
|
// ============================================================
|
|
|
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
import type { WacrmClient } from '../client.js';
|
|
import type { Config } from '../config.js';
|
|
import { registerReadTools } from './read.js';
|
|
import { registerWriteTools } from './write.js';
|
|
import { registerBroadcastTools } from './broadcast.js';
|
|
|
|
export function registerTools(server: McpServer, client: WacrmClient, config: Config): string[] {
|
|
const enabled: string[] = ['read'];
|
|
registerReadTools(server, client);
|
|
|
|
if (config.enableWrites) {
|
|
registerWriteTools(server, client);
|
|
enabled.push('write');
|
|
}
|
|
|
|
if (config.enableBroadcasts) {
|
|
registerBroadcastTools(server, client);
|
|
enabled.push('broadcast');
|
|
}
|
|
|
|
return enabled;
|
|
}
|