Steward AI for Perfex CRM

Version 1.0.0. AI agent, approval queue, audit trail and MCP server module for Perfex CRM 3.2 and newer.

AI tools were used to assist with parts of the code, documentation and graphics of this item.

Steward AI is an independent module. It is not affiliated with, endorsed by or sponsored by Perfex CRM or its authors, Anthropic, OpenAI, OpenRouter or Ollama.

In one sentence: Steward AI reads your CRM the way your staff can, proposes changes, and nothing is changed until a person with the right Perfex permission approves it.

How Steward AI works

Architecture: staff, automations and external AI apps ask the agent; reads run under Perfex permissions; every change goes to the approval queue; approved changes run through Perfex's own functions; everything is written to the audit trail Staff (assistant)Automations (cron)External AI apps (MCP) Steward agentAI provider + 28 tools Readswith Perfex permissions Approval queuea person decides Perfex modelsapply the change Hash-chained audit trail and spending limits around every step

Staff, automations and external AI apps all go through the same agent. Reading follows each person's Perfex permissions; every change waits in the approval queue and is applied by Perfex itself after a person approves it.

1. Requirements

ItemMinimum
Perfex CRM3.2.0 or newer (developed against the 3.4.x module API)
PHP8.1 to 8.5 (the same range Perfex itself supports)
PHP extensionscURL, OpenSSL, mbstring, JSON (all already required by Perfex)
DatabaseMySQL 5.7+ or MariaDB 10.3+ with InnoDB (Perfex's own database)
CronThe Perfex cron job must run (Setup > Settings > Cron Job). Automations, expiry of old requests and clean-up use it.
AI providerAn account with Anthropic, OpenAI or OpenRouter, or an Ollama server you run yourself
External AI apps (optional)Public HTTPS address for Claude custom connectors; a plain key works from any network for Claude Desktop, Claude Code or Cursor

The module does not need Composer, Node.js or shell access on the server. It ships no third-party PHP libraries.

2. Costs outside the item price

You pay these providers directly, from your own accounts. These costs are not included in the price of the item; who pays is you, to the provider.

3. Installation

  1. Download the item from CodeCanyon and unzip the download on your computer. Inside the upload folder you find steward_ai.zip. Do not unzip that file.
  2. In Perfex, open Setup > Modules, click Upload Module, choose steward_ai.zip and upload it.
  3. Click Activate next to "Steward AI - Agent and MCP Server". Activation creates the module's own database tables (all named tblsteward_ai_*). Perfex's tables are not changed.
  4. A new Steward AI menu appears in the sidebar for administrators.
  5. Continue with Connect an AI provider.

Manual alternative: unzip steward_ai.zip and copy the steward_ai folder into Perfex's modules folder over FTP, then activate it in Setup > Modules.

Quick start: first-run walkthrough

A step-by-step first run after activation, all in the Perfex admin, without code:

  1. Steward AI > Home. The setup checklist shows what is left. It ticks itself as you go.
    Steward AI admin home: AI spend against the monthly limit, the ask box, suggested questions, team playbooks, the setup checklist and requests waiting for approval
    Home briefing (screenshots in this guide show the module on made-up sample data).
  2. Settings > AI provider: choose a provider, paste the key, click Test connection (section 4).
  3. Settings > Spending limits: set a monthly limit before your team starts (section 8).
  4. Setup > Staff > Roles: give the Steward AI permissions to the roles that should use it (section 5).
  5. Steward AI > Assistant: ask "What needs my attention today?", then ask for a change, for example a follow-up task.
    Steward AI admin assistant: an answer with a table of overdue invoices and a proposed task waiting for approval
    An answer with record links and a proposed change.
  6. Steward AI > Approvals: approve, edit or reject the request. Only now is the task created.
    Steward AI admin approval queue with a ticket reply, a lead status change and a task, each with Approve, Reject and Edit
    The approval queue.
  7. Settings > Tools and Settings > Playbooks: switch tools off, allow chosen low-risk tools to apply without approval, and write your team's playbooks. Everything the module offers is customised here in the console, without code.
    Steward AI admin settings, Tools tab: each tool with an on/off switch and, for low-risk tools, Apply without approval
    Settings > Tools.

4. Connect an AI provider

Open Steward AI > Settings > AI provider, choose a provider, paste the key and click Test connection. The test sends one short request and shows the model's answer.

ProviderWhere to get the keyModel field
Anthropic (Claude), defaultconsole.anthropic.com > API keysclaude-opus-5-5 (default), claude-sonnet-5-5 or claude-haiku-5-5 for lower cost
OpenAIplatform.openai.com > API keysAny chat model with function calling that your account can use
OpenRouteropenrouter.ai > KeysAny model id from openrouter.ai/models that supports tools
Ollama (local)No key. Base URL, e.g. http://localhost:11434/v1A local model that supports tool calling, e.g. qwen2.5:7b or llama3.1:8b
Other OpenAI-compatible APIYour gateway's key and base URLAs your gateway names it

Keys are stored encrypted with your Perfex encryption key and are never shown again or written to the audit trail. If you change the provider or base URL without entering a key again, the saved key is removed so it is never sent to a different server.

Fallback provider (optional): used only when the main provider is overloaded, rate limited or unreachable. A wrong key is reported, not hidden behind the fallback.

Reasoning effort (Claude only): medium is the default and a good balance. high gives more careful answers at higher cost; low is faster and cheaper.

Instructions for the assistant: house rules added to every conversation, for example "Answer in German" or "Our VAT rate is 20%".

5. Staff permissions

In Setup > Staff > Roles (or per staff member) Steward AI adds these permissions. Administrators have all of them.

PermissionWhat it allows
Use the assistantChat with the agent, on its page and in the drawer on every admin page; see and withdraw their own requests
Approve or reject requestsDecide on requests from anyone; the change still needs the approver's own Perfex permission for that area
Connect external AI apps (MCP)Create personal API keys and approve OAuth connections that act as themselves
View the audit trailSearch, verify and export the audit trail
Manage settings, automations and keysSettings, usage, automations, and revoking anyone's keys and connections
The agent never has more rights than the person. It uses the staff member's Perfex permissions and the same row rules Perfex applies: assigned or public leads, customers they administer, projects they are a member of, tasks they are assigned to or follow, tickets of their departments (when that Perfex option is on), and invoices by view, view own or sale agent. Only an administrator can make a key or an automation act as another staff member.

6. Using the assistant

Steward AI > Home is a short briefing straight from your CRM, without any AI call: requests waiting for approval, overdue invoices with totals per currency, your tasks due, tickets waiting on your team, new leads and leads that have gone quiet. Each line has an Ask button that opens the assistant with a ready question about that record. Administrators also see a setup checklist that ticks itself as the module is configured.

7. Approvals

Every change (create a lead or task, change a status, add a note or comment, reply to a ticket) becomes a request in Steward AI > Approvals. Approvers also get a Perfex notification.

Version 1.0 contains no delete actions and nothing that moves money.

8. Spending limits

Settings > Spending limits. When a limit is reached the assistant stops and says which limit; nothing more is sent to the provider until it resets or you raise it. 0 switches a limit off.

LimitDefault
Daily tokens, everyone together2,000,000
Daily tokens per staff member300,000
Daily tokens for automations500,000
Monthly spending limit (USD, estimated)50
Model calls per question12

Prices for Claude models are built in. For OpenAI, OpenRouter or a gateway, enter your prices as model = input / output in USD per million tokens, one per line. Ollama costs nothing per token. Steward AI > Usage and limits shows today, this month, cost per model and the last 30 days.

9. Automations and cron

Steward AI > Automations runs the agent in the background. Six templates are included; you can edit them or write your own instructions.

WhenTemplate
A new lead is createdQualify new leads: summary, fit score and next step as a proposed note
A new ticket is openedDraft first reply, grounded in the customer's records
Once a day: overdue invoicesPropose follow-up tasks for overdue customers
A payment is recordedNext step after a paid invoice: propose a task when work was waiting on payment
Once a day: overdue tasksAsk assignees of tasks more than 3 days overdue for a new date
Once a day: daily briefA short brief in the run log

A new lead or ticket only puts a job in a queue; the Perfex cron runs it, so creating a lead never waits for the AI. Each automation runs with the permissions of a chosen staff member and everything it wants to change waits for approval. "Recent runs" shows each run's full transcript.

If the Perfex cron does not run, automations do not run and old requests do not expire. Settings shows when the cron last ran. To set it up, follow Perfex's guide at Setup > Settings > Cron Job.

Notifications in team chat

Settings > Notifications posts new and decided requests to a Slack, Microsoft Teams or Discord incoming webhook, a Telegram group (bot token and chat id, stored encrypted) or any HTTPS endpoint as JSON (useful for n8n, Make or Zapier). Messages link to the request; approving always happens in Perfex, signed in. Send a test message checks the setup.

10. External AI apps (MCP)

Claude, ChatGPT, Cursor and other apps can use your CRM through the Model Context Protocol. Turn it on in Settings > External access, then open Steward AI > External AI apps. The endpoint is:

https://YOUR-CRM-DOMAIN/steward_ai/mcp

It supports MCP protocol 2026-07-28 and the earlier 2025-11-25, 2025-06-18 and 2025-03-26 versions. Whatever an external app wants to change goes to the same approval queue; the app gets the request id and can check it with the get_approval_status tool.

Claude (custom connector, recommended)

  1. Your CRM must be reachable over public HTTPS (Claude connects from Anthropic's servers).
  2. In Claude open Settings > Connectors > Add custom connector and paste the endpoint.
  3. Claude opens your CRM. Sign in to Perfex if asked, choose what Claude may access on the consent page, and click Allow access.

Connected apps are listed under "Apps connected with OAuth", where you can disconnect them. A staff member needs the "Connect external AI apps" permission to approve a connection.

Claude Desktop with a key

Create a key under API keys (it is shown once), then add this to claude_desktop_config.json. It needs Node.js on the computer running Claude Desktop.

{
  "mcpServers": {
    "perfex": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://YOUR-CRM-DOMAIN/steward_ai/mcp",
               "--transport", "http-only", "--header", "Authorization:${STEWARD_AUTH}"],
      "env": { "STEWARD_AUTH": "Bearer stw_your_key_here" }
    }
  }
}

Keep the space inside the env value, not in args; this avoids a quoting problem on Windows.

Claude Code

claude mcp add --transport http perfex https://YOUR-CRM-DOMAIN/steward_ai/mcp --header "Authorization: Bearer stw_your_key_here"

Cursor and other clients

Add a Streamable HTTP server with the endpoint above and the header Authorization: Bearer stw_your_key_here. Keys are never accepted in the URL.

Keys

Root-level discovery (optional)

MCP clients find the sign-in server through a link the endpoint returns, so no server change is needed. A few clients only look at the root of the domain. For those, add these lines to Perfex's .htaccess above the existing rewrite rules:

RewriteRule ^\.well-known/oauth-protected-resource(/.*)?$ steward_ai/oauth/protected_resource [L]
RewriteRule ^\.well-known/oauth-authorization-server/steward_ai/oauth$ steward_ai/oauth/metadata [L]

11. Audit trail

Steward AI > Audit trail records every read, proposal, approval, rejection, execution, failure, sign-in to the MCP endpoint, key change, settings change and limit stop, with who did it (staff member, automation or external app) and from which address.

12. Privacy and safety

13. Tools reference

Switch any tool off in Settings > Tools.

ToolKindPerfex rule
crm_overview, list_staff, get_approval_statusReadCounts only for areas the person can see; get_approval_status shows only their own requests
run_reportReadEach report follows the visibility rule of its area
find_duplicatesReadLeads and customers the person can see
search_knowledge_baseReadKnowledge base view; staff-only articles excluded unless asked
search_leads, get_lead, list_lead_statusesReadLead visibility
search_customers, get_customerReadCustomer admin rule
search_invoices, get_invoiceReadInvoices view / view own / sale agent
search_projects, get_projectReadProject membership
search_tasks, get_taskReadTask assignees, followers, creator, public
search_tickets, get_ticketReadDepartments (when "only assigned departments" is on)
create_lead, update_lead_status, add_lead_noteProposesAny staff member may add leads; editing follows lead visibility
add_customer_noteProposesCustomer visibility
create_task, add_task_commentProposesTasks create; comments on visible tasks
update_task_statusProposesTasks edit, or assignee or creator
reply_to_ticket (medium risk), update_ticket_statusProposesTicket visibility

14. Adding tools from your own module

Any Perfex module can add tools. They get argument validation, permissions, the approval queue and the audit trail without extra code.

hooks()->add_filter('steward_ai_register_tools', function ($tools) {
    $tools[] = new My_module_overdue_contracts_tool(); // implements \StewardAi\Core\Tools\ReadTool
    return $tools;
});

A read tool implements name(), title(), description(), inputSchema() (JSON Schema with "additionalProperties": false), kind() ("read"), feature() (a Perfex permission area), capability() and run(array $args, ToolContext $ctx). A write tool implements WriteTool instead: risk(), preview() returning an ActionPreview with the before/after values, and execute(), which runs only after approval. Look at libraries/Core/Tools/Crm/AddLeadNoteTool.php for a complete example.

15. Updating and uninstalling

16. Troubleshooting

What you seeWhat to do
"Add an AI provider key in Settings"Settings > AI provider: paste the key and click Test connection.
"rejected the API key"The key is wrong, expired or has no credit. Create a new one at the provider.
"does not know the model"Check the model id spelling; for OpenRouter copy it from openrouter.ai/models.
Ollama: "Could not reach localhost"The Perfex server must reach Ollama. If Ollama runs on another computer, use its address and start Ollama with OLLAMA_HOST=0.0.0.0.
The assistant writes tool calls as textThe model does not support tool calling well. Use a larger or tool-capable model.
Ollama answers poorly or ignores toolsOllama uses a 4,096-token context by default, too small for the tool list. Start Ollama with OLLAMA_CONTEXT_LENGTH=16384 (or more) and use a 7B+ model with tool support.
Knowledge base search finds nothingThe staff member needs the Perfex "Knowledge base: view" permission. Articles marked for staff only are left out of customer replies on purpose.
"daily token limit ... has been reached"A spending limit stopped the agent. Raise it in Settings > Spending limits or wait for midnight.
The answer takes long or times outLong questions can take a minute. If your host stops PHP after 30 seconds, ask it to allow 120 seconds for admin requests, or use a faster model or lower effort.
A request "Failed: The record changed..."Someone edited the record after the proposal. Ask the assistant again so it sees the current values.
"High-risk requests need a second person"Another approver must decide. Single-admin installs can allow self-approval in Settings > Safety and privacy.
Automations never runThe Perfex cron is not running. Settings shows the last cron run.
Claude connector: "couldn't connect"The CRM must be on public HTTPS, the MCP endpoint must be on (Settings > External access), and OAuth must be allowed. Some firewalls block requests from Anthropic's servers.
MCP client gets 401Check the header is exactly Authorization: Bearer stw_..., the key is not revoked or expired, the IP is allowed, and the staff member still has "Connect external AI apps".
Apache drops the Authorization headerAdd SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 to .htaccess; Steward AI reads it from there.
Verify chain reports a broken entryAn audit row was edited or deleted directly in the database. Compare with your last CSV export and your database backups.

Commands in this guide that start with claude or npx run on your own computer. On Windows use PowerShell or Git Bash.

17. Changelog

1.0.0 First release: assistant and drawer, home briefing, approval queue with edit, plan approval and reasons, audit trail, spending limits, automations (new lead, new ticket, payment, overdue invoices, overdue tasks, daily brief), team chat notifications, reports, duplicates and knowledge base tools, MCP server with keys and OAuth, team playbooks (/ menu), opt-in "apply without approval" rules for low-risk tools, answers in each staff member's Perfex language.

Support

Support is provided through the item's page on CodeCanyon for six months from purchase, as Envato's item support policy describes. Before contacting support, check Troubleshooting and the Perfex error log (application/logs).