9aefba5e by Ean Schuessler

Add workflow indexing and improve documentation

- Index business process workflows from BUSINESS_PROCESSES wiki space
- Add workflow support to search and help tools
- Improve documentation with better organized help content
- Add type attributes to seed data files
- Enhance error handling for workflow loading
1 parent d6d8f38c
......@@ -12,7 +12,7 @@
<http://creativecommons.org/publicdomain/zero/1.0/>.
-->
<entity-facade-xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-facade-3.xsd">
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-facade-3.xsd" type="seed">
<!-- MCP Prompts Wiki Space -->
<moqui.resource.wiki.WikiSpace wikiSpaceId="MCP_PROMPTS"
......
......@@ -12,7 +12,7 @@
<http://creativecommons.org/publicdomain/zero/1.0/>.
-->
<entity-facade-xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-facade-3.xsd">
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-facade-3.xsd" type="seed">
<!-- MCP Screen Documentation Wiki Space -->
<moqui.resource.wiki.WikiSpace wikiSpaceId="MCP_SCREEN_DOCS"
......@@ -114,15 +114,55 @@ Use the following discovery tools to explore available functionality:
versionName="v1">
<fileData><![CDATA[# Moqui MCP Server
This server provides access to Moqui ERP through MCP. Typically you will be searching for a product by name or by a feature like size or color.
If it is a feature based query it is probably best to use the FindFeature screen to locate the feature and then use FindProduct to search for products with that feature.
This server provides access to Moqui ERP through MCP. Use the following tools to discover functionality and get help with common tasks.
## Getting Started
## Help & Discovery Tools
Use the following discovery tools to explore available functionality:
- `moqui_browse_screens`: Browse Moqui screen hierarchy
- `moqui_search_screens`: Search for screens by name to find their paths
- `moqui_get_screen_details`: Get input parameters for specific screens
Use these tools to find information:
- **`moqui_search_screens`**: Search for screens and workflows by name
- Example: `moqui_search_screens(query="variant")` finds the Product Variant Creation workflow
- Returns both screens and business process workflows
- **`moqui_browse_screens`**: Browse Moqui screen hierarchy
- Use empty path for root: `moqui_browse_screens(path="")`
- Navigate deep: `moqui_browse_screens(path="PopCommerce/Catalog/Product/FindProduct")`
- Execute actions: `moqui_browse_screens(path="...", action="createProduct", parameters={...})`
- **`moqui_get_screen_details`**: Get dropdown options and field details
- Use before submitting forms to understand available options
- Example: `moqui_get_screen_details(path="PopCommerce/Party/EditParty", fieldName="countryGeoId")`
- **`moqui_get_help`**: Get extended documentation
- Screen help: `moqui_get_help(uri="wiki:screen:EditProduct")`
- Service help: `moqui_get_help(uri="wiki:service:Product")`
- **Workflow help**: `moqui_get_help(uri="wiki:workflow:Product-Variant-Creation")`
## Business Process Workflows
Complex multi-step operations are documented as workflows. Use `moqui_search_screens` to find them:
**Example: Creating a Product Variant**
1. Search for variant workflow:
```
moqui_search_screens(query="variant")
```
Returns: `{"path": "wiki:workflow:Product-Variant-Creation", ...}`
2. Get workflow documentation:
```
moqui_get_help(uri="wiki:workflow:Product-Variant-Creation")
```
Returns: Complete 8-step guide with exact tool calls and parameters
3. Execute each step using the provided tool calls:
- Clone parent product
- Apply distinguishing features (e.g., ColorPurple, SizeSmall)
- Set pricing (Current and List prices)
- Link variant to virtual parent
The workflow documentation includes exact tool calls, expected responses, and troubleshooting guidance.
## Common Screen Paths
......@@ -148,15 +188,16 @@ Use the following discovery tools to explore available functionality:
### System & Developer Tools
- `/tools/Tools`: Developer tools, entity data editing, and service references
- `/tools/System`: System administration, cache management, and security settings
## Tips for LLM Clients
- All screens support parameterized queries for filtering results
- Use `moqui_render_screen` with screen path to execute screens
- Screen paths use forward slash notation (e.g., `/PopCommerce/PopCommerceAdmin/Catalog/Product`)
- Check `moqui_get_screen_details` for required parameters before rendering
- Use `renderMode: "mcp"` for structured JSON output or `"text"` for human-readable format]]></fileData>
- **Actions are NOT services** - Use screen actions, not direct service calls
- **Use exact parameter names** - Tool calls in workflows use precise field names
- **Extract IDs from responses** - Create operations return internal IDs (not pseudoIds) for use in subsequent steps
- **Check dropdown options** - Use `moqui_get_screen_details` to see valid values before submitting
- **Use `renderMode: "compact"`** for efficient structured output
- **Check validation errors** - Action responses include `validationErrors` with field-specific messages
- **Read `help` fields** - Actions include `help` URIs (e.g., `wiki:service:ProductAssoc`) for detailed documentation]]></fileData>
</moqui.resource.DbResourceFile>
<!-- PopCommerce Root Screen Documentation -->
......
......@@ -11,7 +11,7 @@
<https://creativecommons.org/publicdomain/zero/1.0/>. -->
<entity-facade-xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-facade-3.xsd">
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-facade-3.xsd" type="seed-initial">
<!-- MCP User Groups -->
<moqui.security.UserGroup userGroupId="McpUser" description="MCP Server Users"/>
......
......@@ -2838,6 +2838,66 @@ def wikiInstructions = getWikiInstructions(inputScreenPath)
walkScreenTree(webrootSd, "", 0)
}
// Index workflows from BUSINESS_PROCESSES wiki space
try {
ec.artifactExecution.disableAuthz()
def workflowPageList = ec.entity.find("moqui.resource.wiki.WikiPage")
.condition("wikiSpaceId", "BUSINESS_PROCESSES")
.list()
for (def wp in workflowPageList) {
// Skip root page
if (wp.pagePath == "root") continue
def title = wp.pagePath
def description = ""
try {
def dbResource = ec.entity.find("moqui.resource.DbResource")
.condition("parentResourceId", "WIKI_BUSINESS_PROCESSES")
.condition("filename", wp.pagePath + ".md")
.one()
if (dbResource) {
def dbResourceFile = ec.entity.find("moqui.resource.DbResourceFile")
.condition("resourceId", dbResource.resourceId)
.one()
if (dbResourceFile && dbResourceFile.fileData) {
def content = new String(dbResourceFile.fileData.getBytes(1L, dbResourceFile.fileData.length() as int), "UTF-8")
// Extract title from first heading
def titleMatch = content =~ /^#\s+(.+)$/
if (titleMatch.find()) {
title = titleMatch.group(1)
}
// Extract first paragraph as description
def lines = content.split('\n')
for (line in lines) {
line = line.trim()
if (line && !line.startsWith('#')) {
description = line.take(200)
break
}
}
}
}
} catch (Exception e) {
ec.logger.debug("SearchScreens: Error loading workflow ${wp.pagePath}: ${e.message}")
}
screenIndex << [
path: "wiki:workflow:${wp.pagePath}",
name: title,
description: description,
type: "workflow"
]
}
ec.logger.info("SearchScreens: Indexed ${workflowPageList.size()} workflows")
} catch (Exception e) {
ec.logger.warn("SearchScreens: Error indexing workflows: ${e.message}")
}
// Cache the index
mcpCache.put(cacheKey, screenIndex)
ec.logger.info("SearchScreens: Built index with ${screenIndex.size()} screens")
......@@ -2875,8 +2935,11 @@ def wikiInstructions = getWikiInstructions(inputScreenPath)
}
// Prefer shallower screens (more likely to be entry points)
// Workflows have no depth penalty
if (score > 0) {
if (screen.type != "workflow") {
score -= (screen.depth ?: 0) * 2
}
scored << [screen: screen, score: score]
}
}
......@@ -2896,7 +2959,7 @@ def wikiInstructions = getWikiInstructions(inputScreenPath)
// Add hint if no matches
def hint = null
if (matches.isEmpty()) {
hint = "No screens found matching '${query}'. Try broader terms like 'product', 'order', 'party', or use moqui_browse_screens to explore."
hint = "No screens or workflows found matching '${query}'. Try broader terms like 'product', 'order', 'party', or use moqui_browse_screens to explore."
} else if (matches.size() >= 15) {
hint = "Showing top 15 results. Refine your search for more specific matches."
}
......@@ -3084,6 +3147,10 @@ def wikiInstructions = getWikiInstructions(inputScreenPath)
wikiSpaceId = "MCP_SERVICE_DOCS"
pagePath = pageName
break
case "workflow":
wikiSpaceId = "BUSINESS_PROCESSES"
pagePath = pageName
break
default:
wikiSpaceId = "MCP_SCREEN_DOCS"
pagePath = pageName
......@@ -3107,7 +3174,17 @@ def wikiInstructions = getWikiInstructions(inputScreenPath)
if (wikiPage) {
// Use direct DbResource/DbResourceFile lookup (like BrowseScreens does)
def parentResourceId = (wikiType == "service") ? "WIKI_MCP_SERVICE_DOCS" : "WIKI_MCP_SCREEN_DOCS"
def parentResourceId
switch (wikiType) {
case "workflow":
parentResourceId = "WIKI_BUSINESS_PROCESSES"
break
case "service":
parentResourceId = "WIKI_MCP_SERVICE_DOCS"
break
default:
parentResourceId = "WIKI_MCP_SCREEN_DOCS"
}
def dbResource = ec.entity.find("moqui.resource.DbResource")
.condition("parentResourceId", parentResourceId)
......