# cognigy/cognigy-plugin architecture

> Architecture diagram of the GitHub repository cognigy/cognigy-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cognigy/cognigy-plugin
- Repository: https://github.com/cognigy/cognigy-plugin

## Overview

#### Purpose and Runtime Entry Points
NiCE Cognigy Plugin is a TypeScript MCP server engine that lets AI-client plugins manage Cognigy.AI resources through its REST API. It is distributed as host-native plugin/extension packages for Claude, Codex, Gemini, Cursor, Antigravity, and Agent Plugins hosts.

Primary runtime entry points are the MCP server in `src/index.ts`, configuration/bootstrap in `src/setup.ts`, and the install-manager CLI surface under `src/install/`. Node.js 20+ is the material runtime.

#### Host Packaging and Client Boundary
The engine is packaged separately from client-facing manifests. `plugin/mcp.json` and `plugin/plugin.json` describe the common plugin; host-specific manifests adapt it to their plugin systems, including `plugin/.claude-plugin/plugin.json` and `plugin/.codex-plugin/mcp.json`.

The `plugin/skills/` and `plugin/agents/` content is declarative guidance executed or loaded by capable hosts, not server business logic. They direct clients toward the MCP tools and Cognigy workflows.

#### Configuration, Credentials, and Installation
Configuration resolves Cognigy API URL/key from environment first, then a protected user configuration file. Core resolution and validation are in `src/config.ts` and `src/userConfigFile.ts`.

The installer is a multi-client orchestration boundary: `src/setup.ts` selects clients and delegates platform-specific registration to modules such as `src/install/claudeCode.ts`, `src/install/claudeDesktop.ts`, `src/install/codex.ts`, and `src/install/gemini.ts`. Shell bootstrap scripts, `install.sh` and `install.ps1`, launch the published setup package.

#### MCP Tool Registry and Request Pipeline
`src/index.ts` initializes the MCP server and exposes the tool surface. `src/tools/definitions.ts` declares tool metadata/schema associations; `src/tools/handlers.ts` maps calls to operations; `src/schemas/tools.ts` provides Zod validation contracts.

The critical request pipeline is: host invokes an MCP tool → schema validation → rate-limit and context setup → handler execution → Cognigy REST request/response translation. This boundary ensures credentials are not passed as tool parameters and malformed calls do not reach Cognigy.

#### Cognigy API Integration and Audit Context
`src/api/client.ts` is the outbound HTTP boundary to the configured Cognigy.AI REST API. It is responsible for authenticated API calls and platform-facing error behavior.

Per-run session IDs and per-tool task IDs are constructed through `src/utils/actorContext.ts` and attached for Cognigy audit attribution. `src/utils/rateLimiter.ts` protects the API from excessive tool calls; `src/utils/logger.ts` provides controlled operational logging.

#### Resource and Agent Lifecycle Operations
General resource reads/deletes, agent creation/update, LLM setup, agent conversation, knowledge, tools, and flow-node changes are centralized in `src/tools/handlers.ts`, with node-specific validation/lookup in `src/tools/nodeRegistry.ts` and `src/tools/toolParameters.ts`.

The defining workflow is AI-agent provisioning: create agent resources, flow, AI Agent Job node, and REST endpoint; then permit iterative `talk_to_agent` and update operations. Flow visualization/rendering is handled at `src/render/flowRender.ts`.

#### Deployment, Portability, and Specialized Workflows
Package import/export/download behavior is isolated in `src/tools/packageManagement.ts`; snapshot creation/restore rollback is isolated in `src/tools/snapshotManagement.ts`. These are state-transfer and recovery boundaries around Cognigy projects.

Specialized deployment configuration is implemented through `src/tools/webchatSettings.ts` (Webchat), `src/tools/voiceChecklist.ts` (voice audit/go-live), and the central handlers. These operations configure Cognigy endpoints, voice gateway/WebRTC capability, and project-level AI settings rather than hosting any frontend or voice service locally.

#### External Services and Delivery
The sole runtime external service is the configured Cognigy.AI REST API, including its resource, package, endpoint, knowledge, settings, and audit-event APIs. Documentation lookup is packaged as plugin guidance under `plugin/skills/docs-lookup/SKILL.md`.

Release delivery is npm/package-based, with plugin manifest consistency enforced by `scripts/check-plugin-manifest.mjs` and version synchronization by `scripts/sync-plugin-version.mjs`. GitHub Actions workflows in `.github/workflows/release.yml` publish release artifacts.

Main entry points: [`src/tools/handlers.ts`](https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/handlers.ts) (Tool handlers), [`src/index.ts`](https://github.com/cognigy/cognigy-plugin/blob/main/src/index.ts) (MCP server), [`src/utils/rateLimiter.ts`](https://github.com/cognigy/cognigy-plugin/blob/main/src/utils/rateLimiter.ts) (Request controls), [`plugin/mcp.json`](https://github.com/cognigy/cognigy-plugin/blob/main/plugin/mcp.json) (Common manifests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hosts["Plugin Hosts"]
  node_host_clients(("AI plugin hosts<br/>client hosts"))
  node_common_manifest["Common manifests<br/>plugin manifests<br/>[mcp.json]"]
  node_host_manifests["Host-specific manifests<br/>plugin manifests<br/>[plugin.json]"]
  node_host_guidance["Skills and agents<br/>declarative guidance"]
end

subgraph group_runtime["MCP Runtime"]
  node_mcp_server{{"MCP server<br/>TypeScript server<br/>[index.ts]"}}
  node_tool_definitions["Tool registry<br/>tool metadata<br/>[definitions.ts]"]
  node_tool_schemas["Tool contracts<br/>Zod schemas<br/>[tools.ts]"]
  node_request_controls["Request controls<br/>context and rate limit<br/>[rateLimiter.ts]"]
  node_config_credentials["Configuration and credentials<br/>secure configuration<br/>[config.ts]"]
  node_installer["Setup installer<br/>multi-client CLI<br/>[setup.ts]"]
  node_bootstrap_scripts["Shell bootstrap<br/>install launchers<br/>[install.sh]"]
end

subgraph group_operations["Cognigy Operations"]
  node_handlers["Tool handlers<br/>operation dispatcher<br/>[handlers.ts]"]
  node_node_operations["Node operations<br/>node validation<br/>[nodeRegistry.ts]"]
  node_agent_provisioning["Agent provisioning<br/>lifecycle workflow<br/>[handlers.ts]"]
  node_flow_renderer["Flow rendering<br/>visualization<br/>[flowRender.ts]"]
  node_state_transfer["Package and snapshots<br/>portability and recovery"]
  node_deployment_settings["Webchat and voice settings<br/>deployment configuration<br/>[webchatSettings.ts]"]
end

subgraph group_delivery["Packaging &amp; Release"]
  node_release_pipeline{{"Release pipeline<br/>GitHub Actions<br/>[release.yml]"}}
  node_manifest_checks["Manifest/version checks<br/>release scripts"]
end

node_cognigy_api[("Cognigy.AI REST API<br/>external service")]

node_host_clients -->|"loads"| node_host_manifests
node_host_manifests -->|"adapts"| node_common_manifest
node_host_clients -.->|"loads guidance"| node_host_guidance
node_host_clients -->|"invokes MCP tools"| node_mcp_server
node_common_manifest -->|"declares"| node_mcp_server
node_mcp_server -->|"exposes"| node_tool_definitions
node_tool_definitions -->|"uses"| node_tool_schemas
node_mcp_server -->|"sets up request"| node_request_controls
node_request_controls -->|"permits execution"| node_handlers
node_tool_schemas -->|"validates calls"| node_handlers
node_handlers -->|"validates nodes"| node_node_operations
node_handlers -->|"drives"| node_agent_provisioning
node_handlers -->|"renders flows"| node_flow_renderer
node_handlers -->|"transfers and restores"| node_state_transfer
node_handlers -->|"configures"| node_deployment_settings
node_handlers -->|"REST operations"| node_cognigy_api
node_config_credentials -.->|"supplies authentication"| node_cognigy_api
node_request_controls -.->|"attaches audit context"| node_cognigy_api
node_bootstrap_scripts -->|"launches"| node_installer
node_installer -->|"registers with"| node_host_clients
node_release_pipeline -->|"runs"| node_manifest_checks
node_release_pipeline -.->|"publishes package"| node_common_manifest

click node_common_manifest "https://github.com/cognigy/cognigy-plugin/blob/main/plugin/mcp.json"
click node_host_manifests "https://github.com/cognigy/cognigy-plugin/blob/main/plugin/.claude-plugin/plugin.json"
click node_mcp_server "https://github.com/cognigy/cognigy-plugin/blob/main/src/index.ts"
click node_tool_definitions "https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/definitions.ts"
click node_tool_schemas "https://github.com/cognigy/cognigy-plugin/blob/main/src/schemas/tools.ts"
click node_request_controls "https://github.com/cognigy/cognigy-plugin/blob/main/src/utils/rateLimiter.ts"
click node_handlers "https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/handlers.ts"
click node_node_operations "https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/nodeRegistry.ts"
click node_agent_provisioning "https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/handlers.ts"
click node_flow_renderer "https://github.com/cognigy/cognigy-plugin/blob/main/src/render/flowRender.ts"
click node_state_transfer "https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/packageManagement.ts"
click node_deployment_settings "https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/webchatSettings.ts"
click node_config_credentials "https://github.com/cognigy/cognigy-plugin/blob/main/src/config.ts"
click node_installer "https://github.com/cognigy/cognigy-plugin/blob/main/src/setup.ts"
click node_bootstrap_scripts "https://github.com/cognigy/cognigy-plugin/blob/main/install.sh"
click node_release_pipeline "https://github.com/cognigy/cognigy-plugin/blob/main/.github/workflows/release.yml"
click node_manifest_checks "https://github.com/cognigy/cognigy-plugin/blob/main/scripts/check-plugin-manifest.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_host_clients,node_common_manifest,node_host_manifests,node_host_guidance toneBlue
class node_mcp_server,node_tool_definitions,node_tool_schemas,node_request_controls,node_config_credentials,node_installer,node_bootstrap_scripts toneAmber
class node_handlers,node_node_operations,node_agent_provisioning,node_flow_renderer,node_state_transfer,node_deployment_settings toneMint
class node_release_pipeline,node_manifest_checks toneRose
class node_cognigy_api toneNeutral
```

## Components

### Plugin Hosts

- **AI plugin hosts**: client hosts · Claude, Codex, Gemini, Cursor, Antigravity, and Agent Plugins hosts.
- [Common manifests](https://github.com/cognigy/cognigy-plugin/blob/main/plugin/mcp.json): plugin manifests · `plugin/mcp.json`
- [Host-specific manifests](https://github.com/cognigy/cognigy-plugin/blob/main/plugin/.claude-plugin/plugin.json): plugin manifests · `plugin/.claude-plugin/plugin.json`
- **Skills and agents**: declarative guidance · Host-loaded instructions direct clients to MCP tools and Cognigy workflows.

### MCP Runtime

- [MCP server](https://github.com/cognigy/cognigy-plugin/blob/main/src/index.ts): TypeScript server · Primary Node.js 20+ runtime entry point and tool surface. · `src/index.ts`
- [Tool registry](https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/definitions.ts): tool metadata · Associates MCP tool metadata with schemas and operations. · `src/tools/definitions.ts`
- [Tool contracts](https://github.com/cognigy/cognigy-plugin/blob/main/src/schemas/tools.ts): Zod schemas · `src/schemas/tools.ts`
- [Request controls](https://github.com/cognigy/cognigy-plugin/blob/main/src/utils/rateLimiter.ts): context and rate limit · Creates audit context and limits excessive tool calls before execution. · `src/utils/rateLimiter.ts`
- [Configuration and credentials](https://github.com/cognigy/cognigy-plugin/blob/main/src/config.ts): secure configuration · Resolves API URL and key from environment or protected user configuration. · `src/config.ts`
- [Setup installer](https://github.com/cognigy/cognigy-plugin/blob/main/src/setup.ts): multi-client CLI · Selects clients and registers the published MCP package per platform. · `src/setup.ts`
- [Shell bootstrap](https://github.com/cognigy/cognigy-plugin/blob/main/install.sh): install launchers · `install.sh`

### Cognigy Operations

- [Tool handlers](https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/handlers.ts): operation dispatcher · Centralizes resource, agent, conversation, knowledge, and flow operations. · `src/tools/handlers.ts`
- [Node operations](https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/nodeRegistry.ts): node validation · `src/tools/nodeRegistry.ts`
- [Agent provisioning](https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/handlers.ts): lifecycle workflow · Creates agents, flows, AI Agent Job nodes, and REST endpoints. · `src/tools/handlers.ts`
- [Flow rendering](https://github.com/cognigy/cognigy-plugin/blob/main/src/render/flowRender.ts): visualization · `src/render/flowRender.ts`
- [Package and snapshots](https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/packageManagement.ts): portability and recovery · Handles package transfer and snapshot rollback. · `src/tools/packageManagement.ts`
- [Webchat and voice settings](https://github.com/cognigy/cognigy-plugin/blob/main/src/tools/webchatSettings.ts): deployment configuration · Configures endpoints, voice capability, and project AI settings. · `src/tools/webchatSettings.ts`

### Packaging & Release

- [Release pipeline](https://github.com/cognigy/cognigy-plugin/blob/main/.github/workflows/release.yml): GitHub Actions · Publishes npm/package release artifacts. · `.github/workflows/release.yml`
- [Manifest/version checks](https://github.com/cognigy/cognigy-plugin/blob/main/scripts/check-plugin-manifest.mjs): release scripts · Enforces manifest consistency and synchronized versions. · `scripts/check-plugin-manifest.mjs`

### Other components

- **Cognigy.AI REST API**: external service · Authenticated resource, endpoint, package, knowledge, settings, and audit API boundary.

## Connections

- AI plugin hosts → Host-specific manifests: loads
- Host-specific manifests → Common manifests: adapts
- AI plugin hosts → Skills and agents: loads guidance
- AI plugin hosts → MCP server: invokes MCP tools
- Common manifests → MCP server: declares
- MCP server → Tool registry: exposes
- Tool registry → Tool contracts: uses
- MCP server → Request controls: sets up request
- Request controls → Tool handlers: permits execution
- Tool contracts → Tool handlers: validates calls
- Tool handlers → Node operations: validates nodes
- Tool handlers → Agent provisioning: drives
- Tool handlers → Flow rendering: renders flows
- Tool handlers → Package and snapshots: transfers and restores
- Tool handlers → Webchat and voice settings: configures
- Tool handlers → Cognigy.AI REST API: REST operations
- Configuration and credentials → Cognigy.AI REST API: supplies authentication
- Request controls → Cognigy.AI REST API: attaches audit context
- Shell bootstrap → Setup installer: launches
- Setup installer → AI plugin hosts: registers with
- Release pipeline → Manifest/version checks: runs
- Release pipeline → Common manifests: publishes package
