[MCP] Add codeunit APIs as MCP tools in MCP configuration - #10008
Conversation
Adds Codeunit as a new object type in the MCP configuration alongside API pages and queries: unified Select APIs lookup, Add by API Group, per-tool 'Allow Actions' permission (renamed from Allow Bound Actions), version handling, missing-object warning, and export/import. First-version behavior matches API codeunits by the 'Microsoft.API.Codeunits' namespace and hardcodes microsoft/codeunits/beta until CodeUnit Metadata exposes the API fields (AB#641822). Fixes AB#643238 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb90ebfd-967b-4ba4-98ec-57b054806669
…code The commented restore-when-AB#641822-ships code matched API codeunits by EntityName (the query heuristic). API codeunits are identified by the new codeunit SubType 'API' (analogous to PageType::API), so switch the deferred filters and validation to SubType and drop the spurious Microsoft.API.V1 exclusion. Interim live code still matches by the Microsoft.API.Codeunits namespace. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb90ebfd-967b-4ba4-98ec-57b054806669
Extend API Overview Buffer (table 812) with a Codeunit object type and load API codeunits alongside API pages and queries, matched by the Microsoft.API.Codeunits namespace in the first version (SubType-based once AB#641822 ships). Adds an API Codeunits view. The URL column is blank for codeunit rows because each procedure is its own unbound-action endpoint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb90ebfd-967b-4ba4-98ec-57b054806669
Strip all non-alphanumeric characters from the codeunit name when deriving the API entity name in page 812, matching the MCP module. Adds the System.Utilities using and a Regex codeunit variable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb90ebfd-967b-4ba4-98ec-57b054806669
When the Select APIs lookup is opened from a tool row's Object Id field it now filters to that row's object type; the Select APIs action stays unfiltered. Codeunit API entity names are derived by stripping all non-alphanumeric characters via Regex instead of removing spaces only. Update the MCP test library wrapper for the new LookupAPIObjects signature. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb90ebfd-967b-4ba4-98ec-57b054806669
…643238-codeunit-mcp-tools
SetPermissions() early-exits for Query/Codeunit rows (no Page Metadata match), which previously left AllowCreate/Modify/DeleteEditable holding the prior Page row's values. Reset all three to false up front so stale editability can't leak across row types if the field-level Object Type guards ever change. Addresses PR review feedback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb90ebfd-967b-4ba4-98ec-57b054806669
…643238-codeunit-mcp-tools
…643238-codeunit-mcp-tools
Replace Page/Query/CodeUnit Metadata with the Api Web Service table as the source for MCP API page, query and codeunit tools. Assumes the platform exposes ObjectName, ALNamespace, InsertAllowed, ModifyAllowed and DeleteAllowed on Api Web Service. Microsoft/standard beta pages (publisher microsoft or empty) are excluded while third-party beta pages remain available. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d333ffa5-b544-46f0-a32e-410452089eaf
2ea0e24 to
02c41b5
Compare
Align the API Overview page (812) with the MCP configuration, which now reads API object metadata from the "Api Web Service" table. The codeunit rows no longer rely on the interim "CodeUnit Metadata" namespace match with hard-coded microsoft/codeunits/beta values and a regex-derived entity name (AB#641822); instead they use the real publisher, group, version, service (entity) name and object name from the published web services. A codeunit published under several versions is listed once, with its versions aggregated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1b34da29-3e61-4831-9999-c4e3cce5f128
Complete the move to the "Api Web Service" table as the single source for the API Overview page (812), matching the MCP configuration. Pages and queries are no longer read from "Page Metadata"/"Query Metadata"; all three object types (pages, queries, codeunits) are now enumerated from the published web services through a shared AddAPIObjects helper. An object published under several versions is listed once, with its versions aggregated. As a result the Entity column now shows the entity set name (Api Web Service "Service Name", e.g. postedSalesInvoices) that appears in the API URL, instead of the singular EntityName from Page/Query Metadata. Tests updated accordingly: - TestAPIOverviewIncludesKnownAPIPage now expects postedSalesInvoices. - TestAPIOverviewListsEveryAPIPage counts distinct published API pages from Api Web Service instead of Page Metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1b34da29-3e61-4831-9999-c4e3cce5f128
|
Behavior change worth confirming (non-blocking). |
|
. Nit (non-blocking). |
|
Confirm ordering (non-blocking). This upgrade path depends on |
|
The facade/caption were renamed Page→"Allow Actions", but the backing table field remains "Allow Bound Actions" and is now reused as the invoke toggle for codeunit tools — whose endpoints this PR explicitly documents as unbound actions (see the APIOverview GetApiUrl comment "one endpoint per procedure (unbound action)"). The persisted field name is now semantically inaccurate for codeunit rows. |
|
The new permission tests insert an MCP Configuration Tool directly with a random Object Id, bypassing CreateCodeunitAPITool / ValidateAPICodeunitTool. So the new public facade CreateCodeunitAPITool and its guards (CodeunitNotFoundErr, InvalidCodeunitTypeErr) are untested — the only genuinely new creation logic in the PR has no test asserting it rejects a non-existent codeunit or a non-API codeunit, nor that it stamps the highest codeunit version. |
Pull request was closed
|
The lookup coverage still exercises only the unfiltered path. Agent judgement — not directly backed by a BCQuality knowledge article. Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.34.4 |
Fixes AB#643238
Summary
Adds Codeunit as a new object type in the MCP configuration UI, at parity with API pages and queries, and sources all API metadata from the Api Web Service table.
CreateCodeunitAPITool;GetAPIToolIdobject type extended toCodeunit.AllowActions, withAllowBoundActionsdeprecated behind#if not CLEAN29). For codeunit tools Allow Actions is the invoke toggle; Read/Create/Modify/Delete are not applicable.Metadata source: Api Web Service
API metadata for all three object types now comes from the Api Web Service table, replacing the separate
Page Metadata,Query MetadataandCodeUnit Metadatalookups in both the MCP configuration and the API Overview page:Object Type+Object ID, exposingPublisher/Group/Version,Service Name(entity set name),ObjectName,ALNamespace, and theInsertAllowed/ModifyAllowed/DeleteAllowedcapability flags.Microsoft.API.V1) and the Base Application beta customer/vendor queries (5480/5481) remain excluded from the MCP selection.This removes the previous codeunit-specific handling (namespace matching, regex-derived entity names and fixed
microsoft/codeunits/betavalues); codeunits now carry their real publisher, group, version and entity name, and page create/modify/delete editability reads the capability flags directly.API Overview page (812)
The API Overview page now uses Api Web Service as its single source for all object types, so pages and queries are no longer read from
Page Metadata/Query Metadata(and codeunits no longer use the interimCodeUnit Metadatanamespace match). A sharedAddAPIObjectshelper enumerates the published web services per object type, and an object published under several versions is listed once with its versions aggregated.Service Name(e.g.postedSalesInvoices) - the value that appears in the API URL - instead of the singularEntityNamepreviously read from metadata.Beta APIs
Microsoft and standard beta pages (publisher
microsoftor empty) are excluded from the selection lookup, bulk add, the publisher list and the version picker. Third-party beta pages stay available. Beta queries and codeunits are unaffected.Test plan
TestCodeunitToolDoesNotAllowRead/Create/Modify/Delete,TestCodeunitToolAllowsActions) plus aCreateMCPCodeunitConfigToolhelper.AllowActions.LookupAPIObjectswrapper and theGetHighestAPIPageVersionhelper (now takes an object id) for the new signatures.TestAPIOverviewIncludesKnownAPIPagenow asserts the entity set name (postedSalesInvoices), andTestAPIOverviewListsEveryAPIPagecounts distinct published API pages from Api Web Service.