feat: Register WP ERP capabilities as WordPress Abilities API entries for MCP users#1575
Open
Copilot wants to merge 9 commits into
Open
feat: Register WP ERP capabilities as WordPress Abilities API entries for MCP users#1575Copilot wants to merge 9 commits into
Copilot wants to merge 9 commits into
Conversation
… for MCP users Agent-Logs-Url: https://github.com/wp-erp/wp-erp/sessions/966164e0-9e72-4c70-9a29-f8c7c763b921 Co-authored-by: iftakharul-islam <88052038+iftakharul-islam@users.noreply.github.com>
… typos in capability names Agent-Logs-Url: https://github.com/wp-erp/wp-erp/sessions/966164e0-9e72-4c70-9a29-f8c7c763b921 Co-authored-by: iftakharul-islam <88052038+iftakharul-islam@users.noreply.github.com>
Agent-Logs-Url: https://github.com/wp-erp/wp-erp/sessions/966164e0-9e72-4c70-9a29-f8c7c763b921 Co-authored-by: iftakharul-islam <88052038+iftakharul-islam@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
iftakharul-islam
May 12, 2026 07:18
View session
Member
|
@copilot how to use this abilities ? add the doc |
Agent-Logs-Url: https://github.com/wp-erp/wp-erp/sessions/bb82021c-4c50-4f5d-a290-44fe6fe0c7d6 Co-authored-by: iftakharul-islam <88052038+iftakharul-islam@users.noreply.github.com>
Contributor
Author
Added full documentation in
A link to the doc was also added to the root |
- HRM create-employee ability now maps flat input (first_name, email, department, etc.) to nested shape expected by Employee::create_employee, and converts wrapper's string error back into WP_Error so MCP surfaces failures instead of returning an empty success payload. - Add 'meta' => ['mcp' => ['public' => true, 'type' => 'tool']] to CRM and Accounting abilities that were missing it so they remain discoverable/callable via MCP.
Extend employee API schema with pay_rate and pay_type (enum) and add dependentRequired so pay_rate requires pay_type. Add a series of input validations for first/last name, department, designation, status, type, pay_rate format, and pay_type validity; ensure pay_type exists on the employee when setting pay_rate if not provided in input. Also update the termination endpoint schema: rename/standardize fields (terminate_date, termination_type, termination_reason, eligible_for_rehire) and update the required fields list accordingly.
Add existence + format + enum validation to ability handlers so
invalid input is rejected with a WP_Error before reaching the
underlying create/update/delete functions, instead of silently
no-oping or corrupting state.
HRM:
- create-employee, update-employee: validate name format, department,
designation, status, type via canonical lists; update-employee
validates pay_rate (currency) and pay_type (enum + dependent on
pay_rate).
- update-employee, delete-employee, terminate-employee,
create-leave-request: replace Employee::is_employee() existence
check (returns true for any user due to constructor-side effects)
with a direct Models\Employee::withTrashed()->where('user_id')
query so unknown user_ids are rejected.
- terminate-employee: schema previously used field names that did not
match Employee::terminate() (terminated_date/type/reason/rehire vs
terminate_date/termination_type/termination_reason/eligible_for_rehire),
fix names and validate each value against
erp_hr_get_terminate_type/reason/rehire_options.
- manage-department: validate id (for updates), lead user, parent
department existence.
- manage-designation: validate id existence on update.
- create-leave-request: validate LeaveEntitlement, dates, date range;
map ability's leave_id input to erp_hr_leave_insert_request()'s
expected leave_policy key.
- manage-leave: explicit status enum check as defense in depth.
CRM:
- update-contact, delete-contact, delete-group: existence checks via
erp_get_people() / Models\ContactGroup::find() before mutation.
Accounting:
- update-customer, delete-customer, update-vendor, delete-vendor:
existence checks via erp_get_people().
- create-account: validate type_id against erp_acct_chart_of_accounts.
Add a .claude suite for developer automation and reviewer guidance: new agent docs (api-designer, security-auditor, wp-plugin-reviewer), command runbooks (add-mcp-ability, add-module-cli, add-rest-endpoint, deploy, fix-issue, review), rules (code-style, database, mcp-abilities, rest-api, testing, wordpress-security), and a skill (mcp-ability). Also add global settings.json and a local settings example, plus top-level CLAUDE.md and CLAUDE.local.md.example. These files codify project conventions, security checklists, testing and release procedures, and allowed/denied CLI permissions; .gitignore was updated accordingly.
…thub.com/wp-erp/wp-erp into copilot/analyze-scope-wp-erp-integration
2701fd0 to
04c4255
Compare
04c4255 to
144a498
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Analyzes the full scope of WP ERP's capability system across all three core modules (HRM, CRM, Accounting) and registers every capability as a first-class WordPress Abilities API entry. This exposes all WP ERP operations to MCP (Model Context Protocol) clients — AI assistants like Claude, Cursor, and VS Code AI extensions — via WordPress 6.9+'s built-in MCP Adapter.
What was analysed
HRM capabilities (existing)
erp_list_employee,erp_create_employee,erp_view_employee,erp_edit_employee,erp_delete_employee,erp_can_terminateerp_manage_department,erp_manage_designation,erp_view_jobinfo,erp_manage_jobinfoerp_leave_create_request,erp_leave_manageerp_crate_announcement(existing typo preserved),erp_view_announcement,erp_manage_announcementCRM capabilities (existing)
erp_crm_list_contact,erp_crm_add_contact,erp_crm_edit_contact,erp_crm_delete_contacterp_crm_manage_groups,erp_crm_create_groups,erp_crm_edit_groups,erp_crm_delete_groupserp_crm_manage_activites(existing typo preserved),erp_crm_manage_schedules,erp_crm_manage_dashboardAccounting capabilities (existing)
erp_ac_*_customer/erp_ac_*_vendorcapserp_ac_view_sale,erp_ac_create_sales_invoice,erp_ac_publish_sales_invoice,erp_ac_create_sales_payment,erp_ac_publish_sales_payment,erp_ac_view_sales_summaryerp_ac_view_expense,erp_ac_create_expenses_voucher,erp_ac_publish_expenses_voucher,erp_ac_create_expenses_credit,erp_ac_publish_expenses_credit,erp_ac_view_expenses_summaryerp_ac_view_account_lists,erp_ac_create_account,erp_ac_edit_account,erp_ac_delete_account,erp_ac_view_journal,erp_ac_create_journal,erp_ac_view_other_journals,erp_ac_view_bank_accounts,erp_ac_create_bank_transfererp_ac_view_reportsChanges
New files
modules/hrm/includes/functions-abilities.phpmodules/crm/includes/functions-abilities.phpmodules/accounting/includes/functions/abilities.phpModified files
modules/hrm/HRM.php—require_oncethe new HRM abilities file after the capabilities filemodules/crm/CRM.php—require_oncethe new CRM abilities file after the capabilities filemodules/accounting/Accounting.php— no change needed; already auto-loads allfunctions/*.phpviaglob()Implementation details
wp_abilities_api_categories_init(categories) andwp_abilities_api_init(abilities) hooksinput_schemaandoutput_schemapermission_callbackmirrors the corresponding existing ERP capability checkexecute_callbackdelegates to existing ERP PHP functions (erp_hr_get_employees(),erp_insert_people(), etc.) or$wpdbfor raw ledger/journal queriesfunction_exists( 'wp_register_ability' )for safe fallback on WordPress < 6.9esc_sql()following WordPress coding standardswp_date()used instead ofdate()for timezone-aware default date generationerp_crate_announcement,erp_crm_manage_activites) preserved with explanatory comments