Introducing a new way to review your PRs.

Read the announcement

ever-co / ever-gauzy

Ever® Gauzy™ - Open Business Management Platform (ERP/CRM/HRM/ATS/PM) - https://gauzy.co

View on GitHub

27 documents · Updated Nov 23, 2026

docs / mcp-integration

MCP integration

MCP integration gives AI clients a controlled way to read and change Gauzy data. The shared MCP server library presents Gauzy capabilities as named tools, while standalone and desktop applications provide client-specific ways to host the same capability set.

System purpose

The integration connects an MCP client to Gauzy through the Model Context Protocol (MCP). It keeps access focused on named tools and carries the caller's user, organization, and tenant context into each Gauzy operation.

AI client access

An MCP client first learns the server protocol and its tool capability. It then discovers the tools visible to its caller and sends structured input to a selected tool. The server returns tool data or a protocol error instead of exposing Gauzy as an unrestricted API.

Tool descriptions and input shapes help an AI client choose a safe operation. Tool hints also describe whether a call reads data, changes data, or may have an outside effect; these hints guide client approval and do not replace authorization.

References: packages/…/mcp-server.ts• L38-47 packages/…/mcp-server.ts• L75-190 packages/…/tool-helper.ts• L39-81 packages/…/tool-hints.ts• L1-50

Gauzy capability model

The shared server exposes Gauzy work and business functions as tool groups. The groups cover work planning, people, projects, time, finance, sales, inventory, goals, reporting, and authentication. They support reads and controlled changes when the caller and the tool allow them.

Tools keep organization and tenant context tied to the active login. They also provide common query behavior such as filters, paging, searches, counts, relations, and bulk actions. An action that the Gauzy API does not support remains a visible tool with a clear refusal rather than pretending that the action succeeded.

The optional collaboration surface adds chat, docs, and inbox tools. Deployment enables each group, and caller scopes then limit its read and write tools. A caller does not discover a collaboration tool that its current scope cannot use.

See MCP server capabilities for the detailed tool surface.

References: packages/…/README.md• L102-115 packages/…/README.md• L116-294 packages/…/input-schemas.ts• L9-243 packages/…/utils.ts• L7-15 packages/…/utils.ts• L48-113 packages/…/collaboration-tool.ts• L39-80

Service and desktop forms

The standalone apps/…/index.ts application is the direct entry point for local or hosted MCP use. It uses the shared server package, so its clients receive the same tool and identity model as other server hosts.

The desktop application starts that same server before it creates its status window. Its window reports server state and supports lifecycle actions, but it does not define a second set of Gauzy capabilities.

References: apps/…/README.md• L11-27 apps/…/README.md• L48-93 packages/…/README.md• L1-23 packages/…/mcp-server.ts• L276-360

Request flow

An MCP request moves from a transport boundary to a named Gauzy operation. The transport establishes the caller context, the server exposes only the tools that context may use, and the tool calls Gauzy with that same context.

MCP request flow

The diagram shows how a client request crosses transport, identity, tool selection, validation, and Gauzy API boundaries.

flowchart LR
    C[AI client] --> T[MCP transport]
    T --> A[Authorization or local-caller check]
    A --> S[Session or login context]
    S --> F[Caller tool and scope filter]
    F --> V[Tool input validation]
    V --> G[Registered Gauzy tool]
    G --> API[Gauzy API]
    API --> R[Tool result]
    R --> C

Local process clients use the process identity. Network clients use a session identity or an OAuth subject. A caller without its own login can use the server operator's configured login only in the tightly checked local case.

References: packages/…/mcp-server.ts• L193-273 packages/…/api-client.ts• L52-87 packages/…/utils.ts• L17-37 packages/…/collaboration-tool.ts• L39-80

Tool discovery and execution

The protocol uses initialization, tool listing, and tool calling as its main client interactions. Tool listing gives the client each visible tool's name, description, input shape, and effect hints so the model can form a suitable call.

Execution checks the tool name and input before the registered tool runs. The tool then uses the shared API client to reach Gauzy. This separation keeps protocol handling independent from domain actions and lets unavailable operations return a clear error.

References: packages/…/mcp-server.ts• L75-190 packages/…/mcp-server.ts• L193-273 packages/…/tool-helper.ts• L62-100 packages/…/utils.ts• L136-147

Connection modes

The integration supports a local process stream and network transports. The client and deployment shape decide whether the server runs beside the client or serves remote connections.

Local process connections

The standard input/output mode lets an AI client start the MCP server as a child process and exchange protocol messages through process streams. This mode fits desktop clients that manage a local command and do not need a public endpoint.

The local server speaks for its configured login by default. Optional collaboration tools can be narrowed by the local scope setting before the client discovers them.

References: apps/…/README.md• L50-63 packages/…/config.ts• L3-4 packages/…/mcp-server.ts• L40-47

Network connections

HTTP and WebSocket transports let remote clients share a running MCP service. HTTP handles request and event endpoints. WebSocket keeps a two-way connection and checks its health while it remains open.

Both network forms apply the same high-level rules: protect the endpoint, bind work to a caller, filter tools by caller scope, limit unsafe requests, and return protocol results. A persistent connection must also recheck its identity as the connection continues.

References: apps/…/README.md• L65-93 packages/…/config.ts• L5-39 packages/…/mcp-server.ts• L348-360

Identity boundary

MCP access stays tied to a Gauzy user and its organization and tenant scope. The shared server accepts local credentials, a Gauzy personal API token, or network authorization supplied by the hosting flow; each form must resolve to a Gauzy login before protected tools run.

Gauzy API identity

The API client is the boundary between an MCP tool and Gauzy. It adds the active bearer token to API calls, renews the login when possible, and carries the login's organization and tenant scope. It also sends the tenant in the API header expected by Gauzy, which keeps list requests in the right tenant even when their filters are nested.

The authentication manager keeps the process login separate from keyed network-caller logins. A remote caller cannot inherit the process-wide configured login. It must use its own credentials, token, session, or OAuth identity.

References: packages/…/api-client.ts• L9-25 packages/…/api-client.ts• L52-87 packages/…/auth-manager.ts• L55-68 packages/…/auth-manager.ts• L681-704 packages/…/utils.ts• L17-37

Personal API token login

GAUZY_API_TOKEN lets a local or configured server sign in without storing a Gauzy password. The server checks the token shape before it sends a request, exchanges it for a short-lived access token, and learns the user's organization and tenant from that login.

The exchanged login has no refresh token. When it expires or the API returns 401, the server exchanges the personal token again. A refused token is not retried until the server restarts with a replacement. The token itself is not included in logs, tool answers, or status output.

The token takes precedence over configured email and password values. A user creates or revokes it in Gauzy API token settings, so revocation stops later exchanges while the current access session can remain valid until it ends.

References: packages/…/api-token.ts• L3-76 packages/…/auth-manager.ts• L183-203 packages/…/auth-manager.ts• L257-337 packages/…/auth-manager.ts• L417-500 packages/…/environment.ts• L65-83 packages/…/environment.ts• L118-136

MCP sessions

An MCP session binds a network client to a Gauzy user context. It can include the user, tenant, organization, permissions, session, and connection identifiers. HTTP and WebSocket requests use this context to keep access tied to the correct caller.

Sessions expire, track their connections, and are removed during cleanup or logout. Session identifiers are represented by short hashes in logs rather than by the bearer values themselves.

References: packages/…/auth.ts• L20-65 packages/…/auth.ts• L110-185 packages/…/error-utils.ts• L11-26 packages/…/auth-manager.ts• L623-639

OAuth authorization service

The dedicated apps/mcp-auth application issues OAuth authorization and access tokens for hosted MCP clients. The MCP server is the protected resource: it validates the caller's bearer token and uses the resulting identity and scopes to decide which Gauzy tools the caller may use.

See MCP authentication and client for client entrypoints and the end-to-end authentication flow. See MCP server capabilities for how hosting exposes the tool groups.

References: apps/…/README.md• L688-705 packages/…/README.md• L104-115 packages/…/auth-manager.ts• L163-203

AI chat connection

Gauzy AI chat can use the MCP server as an optional source of tools. This lets chat use the same capability and identity boundary as external MCP clients without making remote MCP availability a requirement for every chat request.

Optional chat tool bridge

When an MCP URL is configured, the chat service creates a remote MCP client for the request and forwards the requesting user's authorization header. It discovers the remote tools and adds them to the model's tool set.

Remote MCP tools need explicit approval in chat because they may change Gauzy state. If the remote service is unavailable, chat keeps its built-in tools and continues without the optional MCP tools.

See MCP server capabilities for the tool surface and hosting behavior.

References: packages/…/mcp-tools.ts• L11-60 packages/…/ai-chat.service.ts• L62-69 packages/…/ai-chat.service.ts• L111-156

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep tool registration, discovery, input validation, and call-time lookup aligned. A tool that is callable but absent from discovery creates an unsafe or unusable client contract.
  • Preserve the identity handoff from each network transport into keyed Gauzy login state. A new transport must not give a remote caller the process-wide configured login.
  • Keep organization and tenant scope in both the bearer login and the API request. The tenant header and nested list filters must continue to describe the same scope.
  • Keep personal-token precedence, exchange behavior, retry limits, and refusal messages aligned across environment loading, authentication, API retry handling, and operator documentation.
  • Keep personal API tokens out of logs, tool results, status values, and error text. Sanitization must cover both direct token values and nested API errors.
  • Keep collaboration deployment switches, scope mapping, discovery filtering, and call-time checks aligned. A tool listed without its scope guard creates a silent access gap.
  • Keep tool effect hints aligned with the real action. A client may use them to decide whether to ask the person before a call.
  • If document tools change, keep Markdown reads and writes on the Markdown routes, pass the page revision on updates, and preserve conflict reporting so a newer edit is not overwritten.
  • If the AI chat bridge changes its merge or approval rules, check that remote MCP tools remain optional and still require approval for state changes.

Important failure modes

TriggerConsequenceGuard
GAUZY_API_TOKEN has the wrong shapeThe server stops before it sends an API requestValidate the token setting at environment load
The personal token is revoked, expired, or unknownThe server cannot create or renew the configured loginReport the refusal without retrying it until restart
Personal API tokens are disabled on the Gauzy APIToken exchange fails even when the value has the right shapeEnable personal API tokens on the Gauzy server or use another login method
A request loses its tenant or organization contextGauzy rejects the request or returns data from the wrong scopeResolve scope from the active login and send the expected tenant header and query context
A remote caller falls back to the process loginOne caller can act as the server operatorKeep process and keyed login state separate and allow sharing only for the checked local case
A collaboration scope is granted but its group is disabledThe caller cannot discover or call the requested toolsEnable the group and grant the matching read or write scope
A tool's input schema differs from its handler or discovery shapeThe AI client sends an invalid call or sees an unusable toolUse the same registered schema for validation and tool listing
A document update uses an old revisionA newer edit is rejected or risks being overwrittenRead the current page and send its revision with the update
A remote MCP service is unavailable during chatChat could fail as a whole if remote tools are treated as requiredKeep MCP tools optional and retain the built-in chat tools

Key files

FileWhy to read it
packages/…/mcp-server.tsShared MCP server contract for registration, discovery, input validation, and calls
packages/…/README.mdHigh-level package role, client forms, authentication choices, and capability groups
apps/…/README.mdStandalone hosting modes and client connection choices
packages/…/api-client.tsGauzy API boundary, bearer handling, tenant scope, and retry behavior
packages/…/auth-manager.tsProcess and per-caller login state, token renewal, and scope identity
packages/…/api-token.tsPersonal API token contract and exchange outcomes
packages/…/environment.tsRuntime login selection and environment validation
packages/…/config.tsLocal, HTTP, and WebSocket transport choices
packages/…/tool-helper.tsCommon tool registration contract
packages/…/tool-hints.tsEffect hints exposed to MCP clients
packages/…/utils.tsShared organization scope, list, paging, and API capability behavior
packages/…/collaboration-tool.tsCollaboration scope checks, user-content handling, and error boundaries
packages/…/chat.tsChat reads, assistant attribution, and approval behavior
packages/…/docs.tsMarkdown document reads, searches, and revision-aware writes
packages/…/inbox.tsInbox reads and caller-owned state changes
packages/…/projects.tsProject management capability and organization-scoped actions
packages/…/tasks.tsTask lifecycle, assignment, filtering, and statistics capability
packages/…/employees.tsEmployee and organization member capability
packages/…/timer.tsUser time-tracking capability
apps/…/mcp-oauth.service.tsOAuth issuer and MCP resource-server registration
packages/…/mcp-tools.tsOptional AI chat bridge to remote MCP tools